/* =================================================================
   CEBUANO LEARNING PLATFORM - THEME & RESPONSIVE STYLES
   Version 3.1 - November 2025
   Dark mode, mobile detection, and responsive design
   ================================================================= */

/* =================================================================
   MOBILE DETECTION & BASE ADJUSTMENTS
   ================================================================= */

body.mobile-phone,
body.mobile-tablet {
    --spacing-base: 12px;
    --spacing-small: 6px;
    --spacing-large: 16px;
}

/* Mobile header adjustments */
body.mobile-phone .header-content {
    flex-direction: column;
    align-items: flex-start;
}

body.mobile-phone .header-title h1 {
    font-size: 18px;
}

body.mobile-phone .logo-image {
    width: 24px;
    height: 24px;
}

body.mobile-tablet .logo-image {
    width: 32px;
    height: 32px;
}

body.mobile-phone .header-controls {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
}

body.mobile-phone .select-control {
    min-width: 120px;
    font-size: 13px;
    padding: 6px 10px;
}

body.mobile-phone .version-badge {
    font-size: 10px;
    padding: 2px 8px;
}

/* Mobile header title - allow construction badge to wrap below */
body.mobile-phone .header-title {
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
}

/* Mobile construction badge - thin horizontal bar below title */
body.mobile-phone .construction-badge {
    order: 10; /* Force to end/new row */
    width: 100%;
    margin-left: 0;
    padding: 4px 12px;
    font-size: 11px;
    text-align: center;
    border-radius: 6px;
    animation: none; /* Disable pulse animation on mobile for performance */
    box-shadow: 0 2px 6px rgba(255, 111, 0, 0.3);
}

/* =================================================================
   TOUCH DEVICE OPTIMIZATIONS
   ================================================================= */

body.touch-device button,
body.touch-device .btn,
body.touch-device .nav-tab {
    min-height: 44px;
    min-width: 44px;
}

/* =================================================================
   MOBILE PHONE STYLES
   ================================================================= */

body.mobile-phone {
    font-size: 14px;
}

body.mobile-phone .container {
    padding: 0 12px 24px;
}

body.mobile-phone .header {
    padding: 12px 0;
}

/* Navigation Tabs - Wrap into 2 rows on mobile */
body.mobile-phone .nav-tabs {
    gap: 4px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

body.mobile-phone .nav-tab {
    padding: 10px 12px;
    font-size: 12px;
    gap: 4px;
    flex: 0 0 calc(33.33% - 6px);
    min-width: 0;
    justify-content: center;
}

body.mobile-phone .nav-tab i {
    font-size: 14px;
}

/* Buttons - Larger on mobile */
body.mobile-phone #startBtn,
body.mobile-phone button[id*="restart"],
body.mobile-phone button[id*="Restart"] {
    padding: 16px 32px;
    font-size: 18px;
    width: 100%;
    max-width: 300px;
}

/* Prevent iOS zoom on inputs */
body.mobile-phone input,
body.mobile-phone textarea {
    font-size: 16px;
}

/* Mobile: Filter button and modal */
body.mobile-phone #advancedFilterBtn {
    padding: 6px 12px;
    font-size: 12px;
}

body.mobile-phone #advancedFilterBtn span {
    display: none;
}

body.mobile-phone .filter-modal {
    width: 95%;
    max-width: none;
}

body.mobile-phone .filter-modal .modal-body {
    padding: 16px;
    max-height: 50vh;
}

body.mobile-phone .lesson-range-row {
    flex-direction: column;
    gap: 16px;
}

body.mobile-phone .filter-footer {
    flex-direction: column;
    gap: 8px;
}

body.mobile-phone .filter-footer .btn {
    width: 100%;
}

/* Tablet filter adjustments */
body.mobile-tablet .filter-modal {
    max-width: 500px;
}

/* =================================================================
   MODALS - MOBILE RESPONSIVE
   ================================================================= */

body.mobile-phone .modal-content,
body.mobile-tablet .modal-content {
    width: 95%;
    max-width: none;
    max-height: 85vh;
    overflow-y: auto;
    margin: 20px;
}

body.mobile-phone .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
}

body.mobile-tablet .stats-grid {
    grid-template-columns: repeat(2, 1fr);
}

body.mobile-phone .modal-header h2 {
    font-size: 18px;
}

body.mobile-phone .preview-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Instruction modal mobile */
body.mobile-phone .instruction-modal,
body.mobile-tablet .instruction-modal {
    width: 90%;
    max-width: none;
}

body.mobile-phone .instruction-modal .modal-header h2 {
    font-size: 16px;
}

body.mobile-phone .instruction-modal .modal-header {
    padding: 16px;
}

body.mobile-phone .instruction-body {
    padding: 20px 16px;
    font-size: 14px;
}

body.mobile-phone .instruction-footer {
    padding: 16px;
}

body.mobile-phone .instruction-footer .btn {
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
}

/* Login modal mobile */
body.mobile-phone .login-modal {
    width: 95%;
    max-width: none;
}

body.mobile-phone .login-modal .modal-header h2 {
    font-size: 18px;
}

body.mobile-phone .login-modal .modal-body {
    padding: 20px 16px;
}

/* =================================================================
   DESKTOP RESPONSIVE
   ================================================================= */

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-title h1 {
        font-size: 20px;
    }

    .nav-tabs {
        overflow-x: auto;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* =================================================================
   ACCESSIBILITY - REDUCED MOTION
   ================================================================= */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Simpler shadows on mobile for performance */
body.mobile-phone .card,
body.mobile-phone .btn {
    box-shadow: var(--shadow-sm);
}

body.mobile-phone .card:hover,
body.mobile-phone .btn:hover {
    box-shadow: var(--shadow-md);
}

/* =================================================================
   WELCOME MODAL
   ================================================================= */

.welcome-modal {
    z-index: 10000;
    background: rgba(0, 0, 0, 0.85);
}

.welcome-modal-content {
    background: var(--bg-primary);
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

.welcome-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 32px 24px;
    text-align: center;
}

.welcome-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
    border-radius: 12px;
    background: white;
    padding: 8px;
}

.welcome-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.welcome-subtitle {
    font-size: 16px;
    opacity: 0.9;
    margin: 0;
}

.welcome-body {
    padding: 24px;
}

.welcome-prompt {
    text-align: center;
    color: var(--text-secondary);
    margin: 0 0 20px 0;
    font-size: 15px;
}

.welcome-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.welcome-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.welcome-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.welcome-btn i {
    font-size: 32px;
    margin-bottom: 8px;
}

.welcome-btn span {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.welcome-btn small {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

.welcome-btn-student {
    border-color: #3b82f6;
}
.welcome-btn-student:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}
.welcome-btn-student i {
    color: #3b82f6;
}

.welcome-btn-teacher {
    border-color: #10b981;
}
.welcome-btn-teacher:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
}
.welcome-btn-teacher i {
    color: #10b981;
}

.welcome-btn-admin {
    border-color: #8b5cf6;
}
.welcome-btn-admin:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: #8b5cf6;
}
.welcome-btn-admin i {
    color: #8b5cf6;
}

.welcome-btn-preview {
    border-color: #f59e0b;
}
.welcome-btn-preview:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: #f59e0b;
}
.welcome-btn-preview i {
    color: #f59e0b;
}

.welcome-btn-register {
    border-color: #ec4899;
}
.welcome-btn-register:hover {
    background: rgba(236, 72, 153, 0.1);
    border-color: #ec4899;
}
.welcome-btn-register i {
    color: #ec4899;
}

.welcome-footer {
    padding: 16px 24px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.welcome-footer p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

.welcome-footer i {
    margin-right: 6px;
    color: var(--primary);
}

/* Preview mode indicator */
.preview-mode-banner {
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 8px 16px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    display: none;
}

.preview-mode-banner.visible {
    display: block;
}

.preview-mode-banner a {
    color: white;
    text-decoration: underline;
    cursor: pointer;
    margin-left: 8px;
}

/* Mobile welcome modal */
body.mobile-phone .welcome-modal-content {
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

body.mobile-phone .welcome-header {
    padding: 24px 16px;
}

body.mobile-phone .welcome-header h1 {
    font-size: 18px;
}

body.mobile-phone .welcome-logo {
    width: 60px;
    height: 60px;
}

body.mobile-phone .welcome-buttons {
    grid-template-columns: 1fr;
    gap: 12px;
}

body.mobile-phone .welcome-btn {
    flex-direction: row;
    justify-content: flex-start;
    padding: 16px;
    gap: 16px;
}

body.mobile-phone .welcome-btn i {
    font-size: 24px;
    margin-bottom: 0;
}

body.mobile-phone .welcome-btn span {
    text-align: left;
}

body.mobile-phone .welcome-btn small {
    text-align: left;
}

/* ===================================
   Registration Modal Styles
   =================================== */
.register-modal {
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
}

.register-intro {
    color: var(--text-secondary);
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.register-section {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.register-section h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.register-section h3 i {
    color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.required {
    color: #ef4444;
}

.checkbox-group {
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.helper-fields {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border-color);
}

.helper-fields.hidden {
    display: none;
}

.register-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.register-error.hidden {
    display: none;
}

.register-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #16a34a;
    padding: 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.6;
}

.register-success.hidden {
    display: none;
}

.register-success i {
    margin-right: 8px;
}

/* Mobile registration modal */
body.mobile-phone .register-modal {
    width: 95%;
    max-height: 95vh;
}

body.mobile-phone .form-row {
    grid-template-columns: 1fr;
}

body.mobile-phone .register-section {
    padding: 16px;
}

.welcome-footer a {
    color: var(--primary);
    text-decoration: none;
}

.welcome-footer a:hover {
    text-decoration: underline;
}
