/* ============================================
   EDITOR.CSS - Code Editor & Output Panel
   ============================================ */

/* ============================================
   CODE EDITOR PANEL
   ============================================ */
.code-panel {
    position: relative;  /* Positioning anchor for celebration toast */
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-purple);
}

.code-header {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    color: white;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.code-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--gradient-success);
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: var(--transition-standard);
}

.control-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* ============================================
   CODEMIRROR EDITOR
   ============================================ */
.editor-container {
    flex: 1;
    overflow: hidden;
}

.CodeMirror {
    height: 100% !important;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 16px !important;
    line-height: 1.6 !important;
}

.CodeMirror-lines {
    padding: 4px 0 !important;
}

.CodeMirror pre {
    padding-left: 8px !important;
}

/* ============================================
   OUTPUT SECTION
   ============================================ */
.output-section {
    background: #0f172a;
    border-top: 2px solid rgba(139, 92, 246, 0.3);
    min-height: 160px;
    max-height: 220px;
    display: flex;
    flex-direction: column;
}

.output-header {
    background: var(--gradient-primary);
    color: white;
    padding: 10px 16px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clear-output-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition-standard);
}

.clear-output-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.output-display {
    flex: 1;
    padding: 14px;
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
}

/* Subtle success animation for subsequent challenge completions */
@keyframes slideInFromTop {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   COACH PANEL
   ============================================ */
.coach-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: relative;
    box-shadow: var(--shadow-purple);
}

.coach-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 14px;
    border-bottom: 2px solid #ede9fe;
}

.coach-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.coach-info {
    flex: 1;
}

.coach-name {
    font-weight: 600;
    font-size: 17px;
    color: #5b21b6;
}

.coach-status {
    font-size: 16px;
    color: #64748b;
}

.lesson-objective {
    background: #f0f9ff;
    border-left: 4px solid #3b82f6;
    padding: 14px;
    border-radius: var(--radius-sm);
}

.lesson-objective h4 {
    font-size: 16px;
    color: #1e40af;
    margin-bottom: 8px;
    font-weight: 600;
}

.lesson-objective p {
    font-size: 17px;
    color: #334155;
}

.hints-section h4 {
    font-size: 16px;
    color: #334155;
    margin-bottom: 10px;
    font-weight: 600;
}

.hint-btn {
    padding: 10px 16px;
    margin: 6px 6px 6px 0;
    border-radius: var(--radius-sm);
    border: 1px solid #8b5cf6;
    background: white;
    color: #7c3aed;
    cursor: pointer;
    font-size: 16px;
    display: inline-block;
    transition: var(--transition-standard);
}

.hint-btn:hover {
    background: #f5f3ff;
    transform: scale(1.05);
}

/* ============================================
   SPEECH BUBBLE
   ============================================ */
.speech-bubble {
    position: absolute;
    top: -10px;
    right: 100px;
    background: white;
    border: 2px solid #8b5cf6;
    border-radius: 14px;
    padding: 16px 18px;
    font-size: 17px;
    line-height: 1.6;
    max-width: 340px;
    min-width: 260px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    box-shadow: var(--shadow-purple-lg);
    animation: popIn 0.3s ease-out;
    z-index: 9999;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 22px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 10px solid #8b5cf6;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    right: -7px;
    top: 23px;
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 9px solid white;
    z-index: 1;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: translateX(20px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.speech-bubble.success {
    background: #dcfce7;
    border-color: #10b981;
}

.speech-bubble.success::after {
    border-left-color: #10b981;
}

.speech-bubble.success::before {
    border-left-color: #dcfce7;
}

/* ============================================
   CODE SNIPPETS IN HINTS
   ============================================ */
.hint-code {
    display: block;
    background: #1e293b;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 16px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
    border-left: 3px solid #8b5cf6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.success-criteria {
    background: #f3f4f6;
    padding: 14px;
    border-radius: var(--radius-sm);
}

.success-criteria h4 {
    font-size: 16px;
    color: #334155;
    margin-bottom: 10px;
    font-weight: 600;
}

.criterion {
    font-size: 16px;
    padding: 6px 0;
    color: #64748b;
}

.criterion.pass {
    color: #10b981;
    font-weight: 500;
}

.criterion.fail {
    color: #ef4444;
    font-weight: 500;
}

.check-btn {
    width: 100%;
    padding: 12px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    font-size: 17px;
    transition: var(--transition-standard);
}

.check-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-purple-lg);
}

/* ============================================
   AI CHAT PANEL
   ============================================ */
.ai-chat-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: none;
    flex-direction: column;
    gap: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-purple);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f9fafb;
    border-radius: 10px;
}

.ai-message {
    padding: 12px 16px;
    margin: 10px 0;
    border-radius: 14px;
    max-width: 90%;
    font-size: 17px;
    line-height: 1.6;
}

.ai-message.user {
    background: var(--gradient-primary);
    color: white;
    margin-left: auto;
}

.ai-message.assistant {
    background: white;
    border: 1px solid #e5e7eb;
}

.ai-input-area {
    display: flex;
    gap: 10px;
}

.ai-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #ede9fe;
    border-radius: 10px;
    font-size: 17px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    resize: none;
    min-height: 44px;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.5;
}

.ai-send-btn {
    padding: 12px 24px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 17px;
}

/* ============================================
   THINKING ANIMATION
   ============================================ */
.ai-thinking {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 14px;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.thinking-avatar {
    font-size: 18px;
    animation: pulse 1.5s ease-in-out infinite;
}

.thinking-text {
    color: #8b5cf6;
    font-size: 16px;
    font-weight: 500;
}

.thinking-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ============================================
   IDE MODE LAYOUT
   ============================================ */
.challenge-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    padding: 30px;
    min-height: calc(100vh - 70px); /* Viewport height minus header */
}

.challenge-editor-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

.output-panel {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    min-height: 200px;
    box-shadow: var(--shadow-purple);
}

.output-panel .output-header {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

/* ============================================
   CHALLENGE MODE LAYOUT (mainContainer)
   ============================================ */
.container {
    display: grid;
    grid-template-columns: 1fr 400px 300px; /* Code | Coach | Ads */
    gap: 20px;
    padding: 30px;
    min-height: calc(100vh - 70px);
}
