/* Physics Quest - CSS Styles */
/* Color Theme: Scientific Blue/Purple */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #7c3aed;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--surface);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.stats-bar {
    display: flex;
    gap: 2rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-icon {
    font-size: 1.25rem;
}

.stat-value {
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
    background: var(--surface);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-back {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
}

.btn-back:hover {
    color: var(--primary);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-block {
    width: 100%;
}

.btn-hint {
    background: var(--warning);
    color: white;
}

/* Main Content */
.main-content {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.screen-header {
    text-align: center;
    margin-bottom: 2rem;
}

.screen-header h2 {
    font-size: 2rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.screen-header p {
    color: var(--text-secondary);
}

/* Topic Grid */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.topic-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 4px 6px var(--shadow);
}

.topic-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 8px 16px var(--shadow);
}

.topic-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.topic-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.topic-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.topic-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 3rem;
    text-align: right;
}

/* Difficulty Grid */
.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.difficulty-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 4px 6px var(--shadow);
}

.difficulty-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}

.diff-level {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    background: var(--gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.difficulty-card h3 {
    margin-bottom: 0.5rem;
}

.difficulty-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.xp-badge {
    display: inline-block;
    background: var(--success);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Quest Screen */
.quest-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.quest-info {
    display: flex;
    gap: 0.5rem;
}

.quest-topic-badge, .quest-diff-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
}

.quest-topic-badge {
    background: var(--primary-light);
    color: white;
}

.quest-diff-badge {
    background: var(--secondary);
    color: white;
}

.quest-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.quest-timer.warning {
    color: var(--warning);
}

.quest-timer.danger {
    color: var(--danger);
    animation: pulse 1s infinite;
}

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

.quest-content {
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 6px var(--shadow);
}

.quest-question {
    font-size: 1.25rem;
    line-height: 1.8;
    margin-bottom: 2rem;
}

.quest-question .MathJax {
    font-size: 1.1em;
}

.quest-options {
    margin-bottom: 2rem;
}

.option-btn {
    display: block;
    width: 100%;
    padding: 1rem 1.5rem;
    margin-bottom: 0.75rem;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 12px;
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-btn:hover {
    border-color: var(--primary);
    background: white;
}

.option-btn.selected {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
}

.option-btn.correct {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.option-btn.incorrect {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.answer-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.125rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s;
}

.answer-input:focus {
    border-color: var(--primary);
}

.quest-hints {
    margin-bottom: 2rem;
}

.hints-list {
    margin-top: 1rem;
}

.hint-item {
    padding: 1rem;
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid var(--warning);
    border-radius: 0 8px 8px 0;
    margin-bottom: 0.5rem;
}

.quest-actions {
    text-align: center;
}

/* Result Screen */
.result-container {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
    background: var(--surface);
    border-radius: 16px;
    padding: 3rem;
    box-shadow: 0 4px 6px var(--shadow);
}

.result-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.result-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.result-icon.failure {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.result-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.result-message {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--background);
    border-radius: 12px;
}

.result-stat {
    text-align: center;
}

.result-stat .stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.result-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
}

.result-explanation {
    text-align: left;
    padding: 1.5rem;
    background: var(--background);
    border-radius: 12px;
    margin-bottom: 2rem;
}

.result-explanation h4 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Daily Challenge */
.daily-challenge-card {
    background: var(--gradient);
    color: white;
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    margin-top: 2rem;
}

.daily-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.daily-icon {
    font-size: 2rem;
}

.daily-header h3 {
    font-size: 1.5rem;
}

.daily-desc {
    opacity: 0.9;
    margin-bottom: 1rem;
}

.daily-challenge-card .btn {
    background: white;
    color: var(--primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

/* Formula Tabs */
.formula-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: var(--background);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn:hover, .tab-btn.active {
    background: var(--primary);
    color: white;
}

.formula-content {
    display: grid;
    gap: 1rem;
}

.formula-card {
    background: var(--background);
    border-radius: 12px;
    padding: 1rem;
}

.formula-card h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.formula-latex {
    font-size: 1.25rem;
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: white;
    border-radius: 8px;
    text-align: center;
}

.formula-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.formula-example {
    margin-top: 0.5rem;
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* AI Tutor */
.ai-tutor-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: var(--gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    transition: transform 0.2s;
    z-index: 900;
}

.ai-tutor-fab:hover {
    transform: scale(1.1);
}

.ai-tutor-panel {
    display: none;
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 380px;
    max-height: 500px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 900;
    flex-direction: column;
}

.ai-tutor-panel.active {
    display: flex;
}

.tutor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.tutor-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.tutor-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    max-height: 300px;
}

.tutor-message {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    max-width: 85%;
}

.tutor-message.assistant {
    background: var(--background);
    margin-right: auto;
}

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

.tutor-input {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.tutor-input input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
}

.tutor-input input:focus {
    border-color: var(--primary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1100;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-icon {
    font-size: 2rem;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.toast-message {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Auth Pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient);
    padding: 2rem;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: block;
    margin-bottom: 1rem;
}

.auth-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
}

.auth-form {
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-footer {
    text-align: center;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer p {
    margin-bottom: 0.5rem;
}

/* Alert */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

/* Profile Page */
.profile-page {
    min-height: 100vh;
    background: var(--background);
}

.profile-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

.profile-header-section {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: var(--surface);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px var(--shadow);
}

.profile-avatar {
    width: 100px;
    height: 100px;
    background: var(--gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-icon {
    font-size: 3rem;
}

.profile-info h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.profile-email {
    color: var(--text-secondary);
}

.profile-since {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px var(--shadow);
}

.stat-card .stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stat-details {
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    display: block;
}

.stat-card .stat-label {
    color: var(--text-secondary);
}

.stat-sub {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.topic-mastery-section, .recent-activity-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px var(--shadow);
}

.topic-mastery-section h2, .recent-activity-section h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.mastery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.mastery-card {
    background: var(--background);
    border-radius: 12px;
    padding: 1rem;
}

.mastery-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.mastery-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--background);
    border-radius: 8px;
}

.activity-icon {
    font-size: 1.25rem;
}

.activity-details {
    flex: 1;
}

.activity-quest {
    font-weight: 500;
    display: block;
}

.activity-time {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.xp-gain {
    color: var(--success);
    font-weight: 600;
}

.profile-actions {
    text-align: center;
    margin-top: 2rem;
}

.no-stats {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .stats-bar {
        gap: 1rem;
    }

    .main-content {
        padding: 1rem;
    }

    .topic-grid, .difficulty-grid {
        grid-template-columns: 1fr;
    }

    .result-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .ai-tutor-panel {
        width: calc(100% - 2rem);
        right: 1rem;
        left: 1rem;
    }

    .profile-header-section {
        flex-direction: column;
        text-align: center;
    }

    .formula-tabs {
        justify-content: center;
    }
}
