:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --accent: #22d3ee;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-card);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    padding: 2rem;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.brand i {
    font-size: 2rem;
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary-glow);
}

.brand h1 {
    font-size: 1.2rem;
    line-height: 1.2;
    text-transform: uppercase;
    font-weight: 800;
}

.brand span {
    color: var(--accent);
}

.user-stats {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.xp-container {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.text-warning {
    color: var(--warning);
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    box-shadow: 0 0 10px var(--primary-glow);
    transition: width 0.5s ease-out;
}

.level-indicator {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.level-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
}

/* Custom Scrollbar for Level List */
.level-list::-webkit-scrollbar {
    width: 6px;
}

.level-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

.level-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.level-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.level-item {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid transparent;
}

.level-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.level-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--primary);
}

.level-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.level-item i {
    font-size: 1.2rem;
}

.settings-btn {
    margin-top: auto;
    padding: 1rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-btn:hover {
    color: var(--text-main);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.1), transparent 40%);
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 3rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.ai-mentor-btn {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 20px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-mentor-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 3rem;
}

/* Typography & Layouts in Content */
.lesson-view {
    max-width: 800px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease;
}

.lesson-view h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(90deg, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lesson-view h2 {
    font-size: 1.8rem;
    margin: 2rem 0 1rem;
    color: var(--accent);
}

.lesson-view p {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.info-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 4px solid var(--primary);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 2rem 0;
}

.info-card strong {
    color: var(--primary);
}

/* T-Account Styles */
.t-account-container {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 2rem;
    margin: 2rem 0;
}

.t-account {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 1rem;
    width: 300px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.t-title {
    text-align: center;
    font-weight: 700;
    border-bottom: 2px solid var(--text-main);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.t-body {
    display: flex;
}

.t-side {
    flex: 1;
    text-align: center;
    min-height: 100px;
}

.t-left {
    border-right: 2px solid var(--text-main);
}

.t-header {
    font-weight: bold;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.3rem;
    margin-bottom: 0.5rem;
}

.t-entries {
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    text-align: right;
    padding-right: 0.5rem;
}

.t-left .t-entries {
    text-align: left;
    padding-left: 0.5rem;
}


/* Buttons */
.btn {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.btn-large {
    font-size: 1.2rem;
    padding: 1rem 2rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
}

.glow {
    box-shadow: 0 0 20px var(--primary-glow);
}

/* Task / Quiz Area */
.quiz-question {
    font-size: 1.4rem;
    margin-bottom: 2rem;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.option-btn {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: left;
    font-size: 1.1rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
    transform: translateX(5px);
}

.option-btn.correct {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
}

.option-btn.wrong {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
}

/* Draggable / Match tasks */
.droppable-area {
    background: rgba(0, 0, 0, 0.2);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    min-height: 80px;
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.droppable-area.drag-over {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.draggable-item {
    background: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: grab;
    font-weight: bold;
}

/* AI Sidebar */
.ai-sidebar {
    position: absolute;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100%;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    z-index: 50;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}

.ai-sidebar.open {
    right: 0;
}

.ai-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-main);
}

.ai-chat {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    padding: 1rem;
    border-radius: 12px;
    max-width: 85%;
    line-height: 1.5;
}

.ai-message {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    align-self: flex-start;
    border-bottom-left-radius: 0;
}

.user-message {
    background: var(--primary);
    align-self: flex-end;
    border-bottom-right-radius: 0;
}

.ai-input {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 0.5rem;
}

.ai-input input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 0.8rem 1.2rem;
    color: white;
    font-family: inherit;
}

.ai-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.ai-input button {
    background: var(--primary);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-input button:hover {
    background: #2563eb;
    transform: scale(1.05);
}

/* Modals */
.hidden {
    display: none !important;
}

.modal-overlay,
.feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 16px;
    width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.form-group input {
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
}

.form-group small {
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.feedback-content {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    border: 2px solid transparent;
    animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback-content.success {
    border-color: var(--success);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}

.feedback-content.success h1 {
    color: var(--success);
}

.feedback-content.wrong {
    border-color: var(--danger);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
}

.feedback-content.wrong h1 {
    color: var(--danger);
}

/* Auth Overlay Styles */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, var(--bg-card), var(--bg-dark));
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.auth-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    padding: 3rem;
    border-radius: 20px;
    width: 450px;
    display: flex;
    flex-direction: column;
}

#auth-title {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 2rem;
    color: var(--accent);
}

#auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: bold;
    margin-left: 0.5rem;
}

.auth-error {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 0.8rem;
    border-radius: 8px;
    text-align: center;
    margin: 1rem 0;
    border: 1px solid var(--danger);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    font-weight: bold;
}

.user-profile i {
    font-size: 1.5rem;
    color: var(--accent);
}

.bottom-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.text-danger {
    color: #fca5a5 !important;
}

.text-danger:hover {
    color: var(--danger) !important;
    background: rgba(239, 68, 68, 0.1);
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    body {
        flex-direction: column;
        overflow-y: auto;
    }

    .app-container {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -320px;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .top-nav {
        padding: 1rem;
        gap: 0.5rem;
    }

    #chapter-title {
        font-size: 1.2rem;
        flex: 1;
        text-align: center;
    }

    .mobile-menu-btn {
        display: block;
        background: transparent;
        border: none;
        color: var(--text-main);
        font-size: 1.5rem;
        cursor: pointer;
    }

    .ai-mentor-btn {
        padding: 0.5rem 1rem;
    }

    .ai-btn-text {
        display: none;
    }

    .content-wrapper {
        padding: 1.5rem;
    }

    .lesson-view h1 {
        font-size: 1.8rem;
    }

    .info-card {
        padding: 1rem;
        margin: 1rem 0;
    }

    .t-account {
        width: 100%;
        margin-bottom: 1rem;
    }

    .auth-card {
        width: 90%;
        padding: 2rem;
    }

    .ai-sidebar {
        width: 100%;
        right: -100%;
    }

    .modal-content {
        width: 90%;
        padding: 1.5rem;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 1rem !important;
    }

    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }

    .mobile-overlay.active {
        display: block;
    }
}

/* Hide mobile menu button on desktop */
@media screen and (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }

    .mobile-overlay {
        display: none !important;
    }
}