/* AI Tutor Panel Styles - Light & Dark Theme Support */

.ai-tutor-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark theme */
.dark-theme .ai-tutor-container,
body.dark-theme .ai-tutor-container {
    background: #1e1e1e;
    color: #e0e0e0;
}

/* Header - Compact */
.ai-tutor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: 2px solid rgba(255,255,255,0.2);
}

.tutor-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tutor-icon {
    font-size: 1.3em;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.tutor-title {
    font-weight: 600;
    font-size: 0.85em;
}

.tutor-quota {
    font-size: 0.85em;
    padding: 4px 10px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.tutor-quota.low {
    background: rgba(255, 193, 7, 0.3);
    animation: blink 1s infinite;
}

.tutor-quota.depleted {
    background: rgba(220, 53, 69, 0.3);
}

.tutor-quota.byok {
    background: rgba(40, 167, 69, 0.3);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Job Badge */
.tutor-job-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8em;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tutor-job-badge i {
    font-size: 0.9em;
}

.tutor-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 12px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.dark-theme .quick-actions,
body.dark-theme .quick-actions {
    background: #2d2d2d;
    border-bottom-color: #3d3d3d;
}

.quick-action-btn {
    padding: 10px 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.dark-theme .quick-action-btn,
body.dark-theme .quick-action-btn {
    background: linear-gradient(135deg, #2d2d2d 0%, #3d3d3d 100%);
    border-color: #4d4d4d;
    color: #e0e0e0;
}

.quick-action-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.quick-action-btn i {
    font-size: 1.1em;
}

/* Messages Area */
.ai-tutor-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.ai-tutor-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-tutor-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.dark-theme .ai-tutor-messages::-webkit-scrollbar-track,
body.dark-theme .ai-tutor-messages::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.ai-tutor-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.ai-tutor-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.dark-theme .welcome-message,
body.dark-theme .welcome-message {
    background: #2d2d2d;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.welcome-icon {
    font-size: 3em;
    color: #667eea;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-message h4 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-weight: 600;
}

.dark-theme .welcome-message h4,
body.dark-theme .welcome-message h4 {
    color: #e0e0e0;
}

.welcome-message p {
    color: #6c757d;
    margin-bottom: 8px;
    line-height: 1.6;
}

.dark-theme .welcome-message p,
body.dark-theme .welcome-message p {
    color: #a0a0a0;
}

.welcome-message .tip {
    margin-top: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-left: 3px solid #667eea;
    border-radius: 4px;
    font-size: 0.9em;
}

.dark-theme .welcome-message .tip,
body.dark-theme .welcome-message .tip {
    background: #1e1e1e;
}

/* Auth Required Message */
.auth-required-message {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.dark-theme .auth-required-message,
body.dark-theme .auth-required-message {
    color: #a0a0a0;
}

.auth-required-message i {
    color: #dee2e6;
    margin-bottom: 20px;
}

.dark-theme .auth-required-message i,
body.dark-theme .auth-required-message i {
    color: #4d4d4d;
}

.auth-required-message h4 {
    color: #495057;
    margin-bottom: 12px;
}

.dark-theme .auth-required-message h4,
body.dark-theme .auth-required-message h4 {
    color: #c0c0c0;
}

/* Chat Messages */
.ai-tutor-message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
    max-width: 100%;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-tutor-message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1em;
}

.ai-tutor-message.user .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-tutor-message.assistant .message-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.message-content {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    transition: all 0.3s ease;
    font-size: 13px;
}

.ai-tutor-message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-tutor-message.assistant .message-content {
    background: white;
    color: #2c3e50;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.dark-theme .ai-tutor-message.assistant .message-content,
body.dark-theme .ai-tutor-message.assistant .message-content {
    background: #2d2d2d;
    color: #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.message-content strong {
    font-weight: 600;
    color: inherit;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: rgba(0,0,0,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.ai-tutor-message.user .message-content code {
    background: rgba(255,255,255,0.2);
}

.dark-theme .message-content code,
body.dark-theme .message-content code {
    background: rgba(255,255,255,0.1);
}

.message-content pre {
    background: #282c34;
    color: #abb2bf;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.ai-tutor-message.loading .message-content {
    background: #e9ecef;
    color: #6c757d;
}

.dark-theme .ai-tutor-message.loading .message-content,
body.dark-theme .ai-tutor-message.loading .message-content {
    background: #3d3d3d;
    color: #a0a0a0;
}

/* Feedback Buttons */
.message-feedback {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dark-theme .message-feedback,
body.dark-theme .message-feedback {
    border-top-color: #3d3d3d;
}

.feedback-label {
    font-size: 0.85em;
    color: #6c757d;
    margin-right: 4px;
}

.dark-theme .feedback-label,
body.dark-theme .feedback-label {
    color: #a0a0a0;
}

.feedback-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #6c757d;
}

.dark-theme .feedback-btn,
body.dark-theme .feedback-btn {
    background: #2d2d2d;
    border-color: #4d4d4d;
    color: #a0a0a0;
}

.feedback-btn:hover {
    transform: scale(1.1);
}

.feedback-btn.feedback-yes:hover {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

.feedback-btn.feedback-no:hover {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
}

.feedback-thanks {
    font-size: 0.85em;
    color: #28a745;
    font-weight: 500;
}

/* Input Area */
.ai-tutor-input-area {
    padding: 12px;
    background: white;
    border-top: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.dark-theme .ai-tutor-input-area,
body.dark-theme .ai-tutor-input-area {
    background: #2d2d2d;
    border-top-color: #3d3d3d;
}

.tutor-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95em;
    resize: none;
    transition: all 0.2s;
    background: #f8f9fa;
    color: #2c3e50;
}

.dark-theme .tutor-input,
body.dark-theme .tutor-input {
    background: #1e1e1e;
    color: #e0e0e0;
    border-color: #4d4d4d;
}

.tutor-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.dark-theme .tutor-input:focus,
body.dark-theme .tutor-input:focus {
    background: #2d2d2d;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.input-actions .btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.input-actions .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.input-actions .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.input-actions .btn-primary:active {
    transform: translateY(0);
}

.input-hints {
    font-size: 0.8em;
    color: #6c757d;
}

.dark-theme .input-hints,
body.dark-theme .input-hints {
    color: #a0a0a0;
}

.hint {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hint i {
    color: #ffc107;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .quick-actions {
        grid-template-columns: 1fr;
    }

    .quick-action-btn {
        justify-content: center;
    }

    .message-content {
        font-size: 0.9em;
    }
}

/* System dark mode preference (fallback) */
@media (prefers-color-scheme: dark) {
    body:not(.light-theme) .ai-tutor-container {
        background: #1e1e1e;
        color: #e0e0e0;
    }

    body:not(.light-theme) .quick-actions {
        background: #2d2d2d;
        border-bottom-color: #3d3d3d;
    }

    body:not(.light-theme) .quick-action-btn {
        background: linear-gradient(135deg, #2d2d2d 0%, #3d3d3d 100%);
        border-color: #4d4d4d;
        color: #e0e0e0;
    }

    body:not(.light-theme) .ai-tutor-message.assistant .message-content {
        background: #2d2d2d;
        color: #e0e0e0;
    }

    body:not(.light-theme) .welcome-message {
        background: #2d2d2d;
    }

    body:not(.light-theme) .welcome-message h4 {
        color: #e0e0e0;
    }

    body:not(.light-theme) .ai-tutor-input-area {
        background: #2d2d2d;
        border-top-color: #3d3d3d;
    }

    body:not(.light-theme) .tutor-input {
        background: #1e1e1e;
        color: #e0e0e0;
        border-color: #4d4d4d;
    }

    body:not(.light-theme) .tutor-input:focus {
        background: #2d2d2d;
    }
}

/* Message Edit Button */
.message-edit-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #666;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0;
}

.ai-tutor-message.user {
    position: relative;
}

.ai-tutor-message.user:hover .message-edit-btn {
    opacity: 1;
}

.message-edit-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
    color: #667eea;
    transform: scale(1.05);
}

/* Dark theme edit button */
body:not(.light-theme) .message-edit-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #aaa;
}

body:not(.light-theme) .message-edit-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.4);
    color: #8899ff;
}

/* Edit Message Input */
.edit-message-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95em;
    resize: vertical;
    min-height: 60px;
    margin-bottom: 10px;
    background: white;
    color: #333;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.edit-message-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

body:not(.light-theme) .edit-message-input {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #667eea;
}

body:not(.light-theme) .edit-message-input:focus {
    background: #1e1e1e;
}

/* Edit Actions */
.edit-message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.edit-message-actions .btn {
    padding: 6px 12px;
    font-size: 0.9em;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.edit-message-actions .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.edit-message-actions .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.edit-message-actions .btn-secondary {
    background: #6c757d;
    color: white;
}

.edit-message-actions .btn-secondary:hover {
    background: #5a6268;
}

.edit-message-actions .btn-sm {
    font-size: 0.85em;
    padding: 5px 10px;
}

/* ==================== COMPACT MODE STYLES ==================== */

/* Compact Quick Actions */
.quick-actions-compact {
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.dark-theme .quick-actions-compact,
body.dark-theme .quick-actions-compact {
    background: #2d2d2d;
    border-bottom-color: #3d3d3d;
}

.quick-action-btn-compact {
    padding: 6px 10px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    color: #495057;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    min-width: 32px;
}

.dark-theme .quick-action-btn-compact,
body.dark-theme .quick-action-btn-compact {
    background: linear-gradient(135deg, #2d2d2d 0%, #3d3d3d 100%);
    border-color: #4d4d4d;
    color: #e0e0e0;
}

.quick-action-btn-compact:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.quick-action-btn-compact i {
    font-size: 1.1em;
}

/* Compact Input Area */
.ai-tutor-input-area-compact {
    padding: 8px;
    background: white;
    border-top: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.dark-theme .ai-tutor-input-area-compact,
body.dark-theme .ai-tutor-input-area-compact {
    background: #2d2d2d;
    border-top-color: #3d3d3d;
}

.input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.tutor-input-compact {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9em;
    resize: none;
    transition: all 0.2s;
    background: #f8f9fa;
    color: #2c3e50;
    line-height: 1.4;
}

.dark-theme .tutor-input-compact,
body.dark-theme .tutor-input-compact {
    background: #1e1e1e;
    color: #e0e0e0;
    border-color: #4d4d4d;
}

.tutor-input-compact:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.dark-theme .tutor-input-compact:focus,
body.dark-theme .tutor-input-compact:focus {
    background: #2d2d2d;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.btn-send-compact {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    min-width: 42px;
    height: 38px;
}

.btn-send-compact:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
}

.btn-send-compact:active {
    transform: translateY(0);
}

.btn-send-compact i {
    font-size: 1.1em;
}

/* Compact Messages */
.ai-tutor-messages {
    padding: 12px;
    gap: 12px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    font-size: 1em;
}

.message-content {
    padding: 10px 14px;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Compact Welcome Message */
.welcome-message {
    padding: 30px 16px;
}

.welcome-icon {
    font-size: 2.5em;
    margin-bottom: 12px;
}

.welcome-message h4 {
    margin-bottom: 10px;
    font-size: 1.1em;
}

.welcome-message p {
    margin-bottom: 6px;
    font-size: 0.9em;
    line-height: 1.5;
}

.welcome-message .tip {
    margin-top: 12px;
    padding: 10px;
    font-size: 0.85em;
}
