:root {
    --primary: #334155; /* Slate */
    --primary-dark: #1e293b; /* Deep Navy */
    --success: #10b981;
    --danger: #ef4444;
    --dark: #0f172a; /* Base Canvas */
    --light: #f8fafc;
    --gray: #64748b;
    --accent: #f59e0b; /* Warm Gold/Amber */
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; }
body { background: #0f172a; color: var(--light); min-height: 100vh; display: flex; flex-direction: column; }
header { background: #1e293b; padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #334155; position: sticky; top: 0; z-index: 1000; }
h1 { font-size: 1.5rem; color: #38bdf8; }
.badge { background: #334155; padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.875rem; }

main { flex: 1; padding: 2rem; max-width: 1000px; width: 100%; margin: 0 auto; }
.card { background: #1e293b; border-radius: 12px; padding: 2rem; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3); border: 1px solid #334155; margin-bottom: 2rem; }
.hidden { display: none !important; }

/* Auth Screen grid */
.auth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; margin-top: 2rem; }

.shake-animation {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}
.btn-profile { background: #293548; border: 2px solid #475569; padding: 2rem; border-radius: 12px; color: white; font-size: 1.25rem; cursor: pointer; transition: all 0.2s; text-align: center;}
.btn-profile:hover { border-color: var(--primary); background: #334155; transform: translateY(-2px); }

/* Controls & Elements */
.btn { background: var(--primary); color: white; border: none; padding: 0.75rem 1.5rem; border-radius: 6px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.btn:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }

#timer-display { font-size: 3rem; font-weight: bold; font-family: monospace; text-align: center; margin: 1rem 0; color: var(--accent); }
.topic-header { font-size: 1.5rem; margin-bottom: 1rem; color: #e2e8f0; border-left: 4px solid var(--primary); padding-left: 0.75rem; }

/* Quiz layouts */
.quiz-option { display: block; background: #293548; border: 1px solid #475569; padding: 1rem; border-radius: 8px; margin-bottom: 0.75rem; cursor: pointer; transition: background 0.2s; }
.quiz-option:hover { background: #334155; }
.quiz-option.selected { border-color: var(--accent); background: #1e3a8a; outline: 2px solid var(--accent); }
.quiz-option.correct { background: var(--success); border-color: var(--success); color: var(--dark); }
.quiz-option.incorrect { background: var(--danger); border-color: var(--danger); color: var(--light); }

/* Progress bars */
.progress-track { background: #334155; height: 10px; border-radius: 5px; overflow: hidden; margin: 1rem 0; }
.progress-fill { background: var(--success); height: 100%; width: 0%; transition: width 0.3s; }

.status-box { padding: 1rem; border-radius: 8px; background: #293548; margin-top: 1rem; display: flex; justify-content: space-between; }
.passed { color: var(--success); font-weight: bold; }
.pending { color: #f59e0b; font-weight: bold; }

/* Progress Map Grid - Updated for Phases */
.progress-map-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    background: #111827;
    border-radius: 12px;
}

.phase-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.phase-title {
    font-size: 0.9rem;
    font-weight: bold;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #334155;
}

.phase-squares {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
}

.session-square {
    background: var(--gray);
    color: var(--light);
    padding: 0.5rem;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    height: 45px;
    border: 1px solid rgba(255,255,255,0.1);
}
.session-square:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: var(--accent);
}

/* Status Colors */
.status-completed { background-color: var(--success); border-color: #065f46; }
.status-teaching { background-color: #38bdf8; color: #082f49; border-color: #0ea5e9; animation: pulse-blue 2s infinite; }
.status-quizzing { background-color: var(--accent); color: #451a03; border-color: #d97706; animation: pulse-amber 2s infinite; }
.status-locked { background-color: #1f2937; color: #4b5563; border-color: #374151; opacity: 0.5; cursor: not-allowed; }

@keyframes pulse-blue { 0%, 100% { box-shadow: 0 0 0 0px rgba(56, 189, 248, 0.4); } 50% { box-shadow: 0 0 0 6px rgba(56, 189, 248, 0); } }
@keyframes pulse-amber { 0%, 100% { box-shadow: 0 0 0 0px rgba(245, 158, 11, 0.4); } 50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); } }

/* Tooltip Styles */
.tooltip {
    visibility: hidden;
    background-color: #1e293b;
    color: #fff;
    text-align: left;
    border-radius: 8px;
    padding: 12px;
    position: absolute;
    z-index: 100;
    bottom: 125%; /* Position above the session square */
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.1s ease-out; /* Quicker appearance */
    min-width: 220px;
    max-width: 300px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    white-space: normal; /* Allow text wrapping for rich content */
    border: 1px solid #334155;
    pointer-events: none;
    font-size: 0.85rem;
    line-height: 1.4;
}

.tooltip-title {
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 4px;
    display: block;
    font-size: 0.9rem;
    border-bottom: 1px solid #334155;
    padding-bottom: 4px;
}

.tooltip-meta {
    display: block;
    color: #94a3b8;
    margin-top: 4px;
    font-style: italic;
}

.session-square:hover .tooltip, .session-square.active-hover .tooltip {
    visibility: visible;
    opacity: 1;
}

.tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #334155 transparent transparent transparent;
}

/* Session Details Panel (for click) */
.session-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1500;
}

.session-detail-panel {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slide-up 0.3s ease-out;
}

@keyframes slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #334155;
}

.detail-header h3 {
    color: var(--accent);
    margin: 0;
}

.close-detail {
    background: none;
    border: none;
    color: var(--gray);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.detail-body {
    color: #cbd5e1;
}

.detail-section {
    margin-bottom: 1rem;
}

.detail-label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.detail-value {
    font-size: 1rem;
    line-height: 1.5;
}

/* Tablet Landscape Ergonomics & Orientation Lock Simulation */
@media screen and (orientation: portrait) {
    body::before {
        content: "🔄 Please rotate your tablet to landscape mode for the best experience.";
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: var(--dark);
        color: var(--accent);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 2rem;
        text-align: center;
        z-index: 9999;
        font-size: 1.5rem;
        font-weight: bold;
        border-color: #334155 transparent transparent transparent;
    }
}

@media screen and (min-width: 768px) and (orientation: landscape) {
    main {
        padding: 1rem;
        max-width: 1300px;
    }
    .card {
        padding: 1.5rem;
    }
    .btn, .btn-profile, .quiz-option {
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.05rem;
    }
    .auth-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Teacher Dashboard Layout */
    .teacher-grid {
        display: grid;
        grid-template-columns: 1fr 400px;
        gap: 1.5rem;
        align-items: start;
    }
    .teacher-sidebar {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }
    #lesson-details-container {
        background: #f8fafc; /* Light background for the "script" */
        color: #1e293b;
        border-radius: 12px;
        padding: 2rem !important;
        margin-top: 0 !important;
        border: none !important;
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
        max-height: 75vh;
        overflow-y: auto;
    }
    #lesson-details-container h3 { color: #0f172a; border-bottom: 2px solid var(--primary); display: inline-block; margin-bottom: 1.5rem; }
    .timeline-item { background: #eff6ff; border-left: 5px solid #3b82f6; border-radius: 4px; padding: 0; margin-bottom: 1rem; transition: all 0.3s; }
    .timeline-item-header { padding: 1rem; user-select: none; }
    .timeline-item-content { padding: 0 1rem 1rem 1rem; }
    .timeline-item.collapsed .timeline-item-content { display: none; }
    .timeline-item.collapsed .collapse-icon { transform: rotate(-90deg); }
    .collapse-icon { transition: transform 0.3s; display: inline-block; color: var(--gray); }
    .timeline-item .script-text { font-size: 1.2rem; color: #0f172a; line-height: 1.6; margin: 0.5rem 0; }
    .timeline-item .tip-text { font-size: 0.95rem; color: #475569; background: #fef3c7; padding: 0.75rem; border-radius: 4px; border-left: 3px solid var(--accent); }

    /* Visual Cues for "What to Write" */
    .write-on-board-highlight {
        background-color: #dcfce7;
        border: 1px dashed #22c55e;
        padding: 2px 6px;
        border-radius: 4px;
        display: inline-flex;
        align-items: center;
        gap: 5px;
        color: #166534;
        font-weight: 600;
    }
    .chalkboard-icon::before {
        content: "📋"; /* Simplified icon for now, can be replaced with SVG */
        font-style: normal;
    }
}

/* Session Progress Bar */
.session-progress-container {
    margin-bottom: 1.5rem;
    background: #e2e8f0;
    border-radius: 9999px;
    height: 12px;
    position: relative;
    overflow: hidden;
}
.session-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #3b82f6);
    width: 0%;
    transition: width 0.5s ease-out;
}

/* Student Mini Progress */
.student-mini-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}
.mini-progress-track {
    flex: 1;
    height: 6px;
    background: #334155;
    border-radius: 3px;
    overflow: hidden;
}
.mini-progress-fill {
    height: 100%;
    background: var(--success);
    width: 0%;
    transition: width 0.3s;
}

/* Confirmation Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.8);
    display: flex; justify-content: center; align-items: center; z-index: 2000;
}
.modal-content {
    background: #1e293b;
    padding: 2rem;
    border-radius: 12px;
    max-width: 450px;
    width: 90%;
    border: 1px solid #334155;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}
.modal-title { font-size: 1.5rem; margin-bottom: 1rem; color: var(--danger); }
.modal-body { margin-bottom: 1.5rem; color: #cbd5e1; }
.modal-input {
    width: 100%;
    padding: 0.75rem;
    background: #0f172a;
    border: 1px solid #475569;
    border-radius: 6px;
    color: white;
    margin-bottom: 1rem;
    font-size: 1rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 1rem; }

/* PIN Pad Overlay Styles */
.pin-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.95);
    display: none; justify-content: center; align-items: center; z-index: 1000;
}
.pin-pad { width: 300px; text-align: center; }
.pin-display { font-size: 2.5rem; letter-spacing: 1rem; margin-bottom: 1.5rem; color: var(--accent); height: 3.5rem; }
.pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.pin-btn {
    background: var(--primary-dark); border: 1px solid #475569;
    padding: 1.25rem; border-radius: 0.5rem; font-size: 1.5rem; font-weight: bold;
    cursor: pointer; color: var(--light);
}
.pin-btn:active { background: var(--accent); color: black; }

/* Quiz Option Pulse Animation */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.quiz-option.pulsate {
    animation: pulse 0.3s ease-out;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.toast-message {
    background: rgba(var(--primary-dark), 0.9);
    color: var(--light);
    padding: 10px 20px;
    border-radius: 8px;
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
    transform: translateY(20px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-message.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-message.success {
    background: var(--success);
    color: var(--dark);
}

.toast-message.error {
    background: var(--danger);
    color: var(--light);
}

/* Button States */
.btn {
    transition: all 0.2s ease-in-out;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn:disabled, .btn-loading {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Specific button color adjustments */
.btn-primary {
    background: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: var(--dark);
}
.btn-success:hover {
    background: #0d9488; /* Slightly darker green */
}
.btn-success:active {
    background: var(--success);
}

.btn-danger {
    background: var(--danger);
    color: var(--light);
}
.btn-danger:hover {
    background: #dc2626; /* Slightly darker red */
}
.btn-danger:active {
    background: var(--danger);
}

.lock-animation {
    font-size: 3rem;
    color: var(--accent);
    animation: lock-pulse 1.5s infinite ease-in-out;
}

@keyframes lock-pulse {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0.7; }
}

.hint-flash {
    animation: hint-flash 0.8s ease-in-out;
}

@keyframes hint-flash {
    0%, 100% { background-color: transparent; }
    50% { background-color: #f59e0b40; } /* Subtle amber flash */
}

.quiz-completion-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--success);
    color: white;
    padding: 2rem 4rem;
    border-radius: 15px;
    font-size: 2.5rem;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    animation: slide-in-fade-out 2s forwards ease-out;
    z-index: 1000;
}

@keyframes slide-in-fade-out {
    0% {
        opacity: 0;
        transform: translate(-50%, -70%) scale(0.8);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -30%) scale(0.9);
    }
}

.teacher-celebration-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--accent);
    color: var(--dark);
    padding: 3rem 6rem;
    border-radius: 20px;
    font-size: 3rem;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 0 50px rgba(245, 158, 11, 0.5);
    animation: teacher-celebrate-bounce 3s forwards ease-in-out;
    z-index: 2000;
}

@keyframes teacher-celebrate-bounce {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    30% { transform: translate(-50%, -50%) scale(1); }
    45% { transform: translate(-50%, -50%) scale(1.1); }
    60% { transform: translate(-50%, -50%) scale(1); }
    85% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}
