/* Educational Platform Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #06b6d4;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.page {
    min-height: 100vh;
}

/* Loading Spinner */
.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(248, 250, 252, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    margin-top: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.login-card {
    background: var(--surface-color);
    padding: 48px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.logo-section h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.logo-section p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.login-button {
    width: 100%;
    padding: 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
}

.login-button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.login-icon {
    font-size: 18px;
}

.email-password-form {
    margin-bottom: 24px;
}

.email-password-form input {
    width: 100%;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 16px;
    background: var(--surface-color);
    transition: var(--transition);
}

.email-password-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.email-password-form input::placeholder {
    color: var(--text-secondary);
}

.error-display {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--error-color);
    padding: 12px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    font-size: 14px;
}

.login-features {
    text-align: left;
    margin-bottom: 24px;
}

.feature {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

.feature-icon {
    color: var(--success-color);
    font-weight: bold;
}

.login-footer p {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Dashboard Page */
.dashboard-header {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header h1, .lessons-header h1, .games-list-header h1, .game-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.share-button, .logout-button {
    padding: 8px 16px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.share-button {
    background: var(--secondary-color);
    color: white;
}

.share-button:hover {
    background: #0891b2;
}

.logout-button {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.logout-button:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

.dashboard-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.grades-container h2 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 32px;
    text-align: center;
}

.grades-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.grade-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 20px;
}

.grade-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.grade-number {
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    flex-shrink: 0;
}

.grade-info {
    flex: 1;
}

.grade-info h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.grade-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

.grade-arrow {
    color: var(--primary-color);
    font-size: 20px;
    font-weight: bold;
}

/* Lesson Viewer */
.dashboard-header, .lessons-header, .games-list-header, .game-header {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
}

/* Header layout now handled by .header-content class */

.back-button {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-button:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

.lesson-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.lessons-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

/* Games List (reuses lesson card styling) */
/* Games list header styling handled above in combined rule */

.games-list-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.lesson-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 16px;
}

.lesson-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--secondary-color);
}

.lesson-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.lesson-info {
    flex: 1;
}

.lesson-info h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0;
}

.lesson-info p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.lesson-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
}

.lesson-duration {
    color: var(--primary-color);
    font-weight: 500;
}

.lesson-difficulty {
    color: var(--secondary-color);
    font-weight: 500;
}

.lesson-arrow {
    color: var(--secondary-color);
    font-size: 24px;
}

/* Game Viewer */
/* Game header styling handled above in combined rule */

.game-main {
    background: var(--background-color);
    padding: 20px;
    min-height: calc(100vh - 80px);
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--surface-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    min-height: 600px;
    position: relative;
}

.iframe-wrapper {
    width: 100%;
    height: 600px;
    position: relative;
}

.protected-iframe {
    width: 100%;
    height: 100%;
    border: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.iframe-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--background-color);
    z-index: 10;
}

.iframe-error, .game-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.iframe-error h3, .game-error h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.iframe-error p, .game-error p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.retry-button {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.retry-button:hover {
    background: var(--primary-hover);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.share-link-container {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.share-link-container input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: monospace;
    background: var(--background-color);
}

.copy-button {
    padding: 12px 20px;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.copy-button:hover {
    background: #059669;
}

.share-warning {
    font-size: 14px;
    color: var(--warning-color);
    font-weight: 500;
    margin: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .login-card {
        padding: 32px 24px;
        margin: 20px;
    }

    .header-content {
        padding: 0 16px;
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }

    .header-actions {
        justify-content: center;
    }

    .dashboard-main,
    .lesson-main {
        padding: 24px 16px;
    }

    .grades-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .grade-card {
        padding: 20px;
    }

    .lessons-container,
    .games-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .lesson-card {
        padding: 20px;
        flex-direction: column;
        text-align: center;
    }

    .game-main {
        padding: 16px;
    }

    .iframe-wrapper {
        height: 500px;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    .modal-header,
    .modal-body {
        padding: 20px;
    }

    .share-link-container {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .grade-card {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .lesson-card {
        gap: 12px;
    }

    .iframe-wrapper {
        height: 400px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.grade-card,
.lesson-card {
    animation: fadeIn 0.5s ease forwards;
}

.grade-card:nth-child(1) { animation-delay: 0.1s; }
.grade-card:nth-child(2) { animation-delay: 0.2s; }
.grade-card:nth-child(3) { animation-delay: 0.3s; }
.grade-card:nth-child(4) { animation-delay: 0.4s; }

.lesson-card:nth-child(1) { animation-delay: 0.1s; }
.lesson-card:nth-child(2) { animation-delay: 0.2s; }
.lesson-card:nth-child(3) { animation-delay: 0.3s; }

/* Focus states for accessibility */
button:focus,
input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.grade-card:focus,
.lesson-card:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Share Button Styles */
.share-button {
    background: linear-gradient(135deg, var(--secondary-color), #0891b2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.share-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, #0891b2, var(--secondary-color));
}

.share-button .share-icon {
    font-size: 16px;
}

.grades-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.grades-header h2 {
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Share Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.share-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.share-link-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.share-link-input {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: monospace;
    background: var(--background-color);
    color: var(--text-primary);
}

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

.copy-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.copy-btn:hover {
    background: var(--primary-hover);
}

.copy-icon {
    font-size: 16px;
}

.share-info {
    background: var(--background-color);
    border-radius: var(--border-radius);
    padding: 16px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.info-item:last-child {
    margin-bottom: 0;
}

.info-icon {
    font-size: 18px;
}

/* ============================================================================
   ADMIN DASHBOARD - ONLINE STATUS INDICATORS
   ============================================================================ */

/* Online status badges */
.online-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.online-status-online {
    background: #d4edda;
    color: #155724;
}

.online-status-idle {
    background: #fff3cd;
    color: #856404;
}

.online-status-offline {
    background: #f8f9fa;
    color: #6c757d;
}

/* Online status indicator dot */
.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.online-dot-online {
    background: #28a745;
    box-shadow: 0 0 6px rgba(40, 167, 69, 0.6);
    animation: pulse-online 2s infinite;
}

.online-dot-idle {
    background: #ffc107;
    box-shadow: 0 0 4px rgba(255, 193, 7, 0.4);
}

.online-dot-offline {
    background: #6c757d;
}

@keyframes pulse-online {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 6px rgba(40, 167, 69, 0.6);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 12px rgba(40, 167, 69, 0.8);
    }
}

/* Session info tooltip/hover */
.session-info-icon {
    cursor: help;
    color: #6c757d;
    font-size: 14px;
    margin-left: 4px;
    display: inline-block;
    transition: color 0.2s;
}

.session-info-icon:hover {
    color: var(--primary-color);
}

.session-info-tooltip {
    position: relative;
    display: inline-block;
}

.session-info-tooltip:hover .session-info-content {
    visibility: visible;
    opacity: 1;
}

.session-info-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    z-index: 1000;
    background: #24292e;
    color: white;
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
    white-space: nowrap;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    transition: opacity 0.3s, visibility 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.session-info-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #24292e transparent transparent transparent;
}

/* Activity event badges */
.event-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.event-badge-login {
    background: #d4edda;
    color: #155724;
}

.event-badge-logout {
    background: #f8f9fa;
    color: #6c757d;
}

.event-badge-session-invalidated,
.event-badge-session_invalidated {
    background: #fff3cd;
    color: #856404;
}

.event-badge-session-expired,
.event-badge-session_expired {
    background: #f8d7da;
    color: #721c24;
}

.event-badge-admin-action,
.event-badge-admin_action {
    background: #cfe2ff;
    color: #084298;
}

/* Force logout button styling */
.btn-force-logout {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-force-logout:hover {
    background: #c82333;
}

/* Session table enhancements */
.session-duration {
    font-size: 11px;
    color: #6c757d;
}

.device-info {
    font-size: 11px;
    color: #6c757d;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}