/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; background: #f0f2f5; color: #333; line-height: 1.6; }
a { color: #4a90d9; text-decoration: none; }
a:hover { text-decoration: none; }
img { max-width: 100%; height: auto; }

/* ===== CONTAINER ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* ===== LANDING PAGE ===== */
.landing { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 20px; }
.landing-box { text-align: center; background: white; padding: 60px 50px; border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); max-width: 500px; width: 100%; }
.landing-box h1 { color: #333; margin-bottom: 10px; font-size: clamp(1.4em, 4vw, 2em); }
.landing-box .subtitle { color: #666; margin-bottom: 30px; font-size: clamp(0.9em, 2.5vw, 1em); }
.landing-links { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; }

/* ===== LOGIN PAGE ===== */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 20px; }
.login-box { background: white; padding: clamp(24px, 5vw, 40px); border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); width: 100%; max-width: 400px; }
.login-box h1 { text-align: center; margin-bottom: 25px; color: #333; font-size: clamp(1.2em, 3.5vw, 1.5em); }

/* ===== BUTTONS ===== */
.btn { display: inline-block; padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer; font-size: clamp(13px, 1.8vw, 14px); font-weight: 500; transition: all 0.2s; text-decoration: none; text-align: center; line-height: 1.4; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-primary { background: #4a90d9; color: white; }
.btn-primary:hover { background: #357abd; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-secondary:hover { background: #7f8c8d; }
.btn-success { background: #27ae60; color: white; }
.btn-danger { background: #e74c3c; color: white; }
.btn-danger:hover { background: #c0392b; }
.btn-warning { background: #f39c12; color: white; }
.btn-warning:hover { background: #e67e22; }
.btn-locked { background: #bdc3c7; color: #95a5a6; cursor: not-allowed; }
.btn-sm { padding: 6px 14px; font-size: clamp(11px, 1.5vw, 12px); }
.btn-lg { padding: 14px 28px; font-size: clamp(15px, 2vw, 16px); }
.btn-block { display: block; width: 100%; }

/* ===== FORM ===== */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; color: #555; font-size: clamp(13px, 1.6vw, 14px); }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 10px 14px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: clamp(13px, 1.6vw, 14px); transition: border-color 0.2s; background: white; }
.form-group textarea { resize: vertical; min-height: 60px; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: #4a90d9; }
.form-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-inline .form-group { flex: 1; min-width: 120px; margin-bottom: 0; }
.form-row { display: flex; gap: 15px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 150px; }
.form-row .half { flex: 1; min-width: 150px; }

/* ===== ALERTS ===== */
.alert { padding: clamp(10px, 2vw, 12px) clamp(14px, 2.5vw, 18px); border-radius: 8px; margin-bottom: 15px; font-weight: 500; font-size: clamp(13px, 1.6vw, 14px); }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: clamp(10px, 1.4vw, 11px); font-weight: 600; white-space: nowrap; }
.badge-success { background: #27ae60; color: white; }
.badge-danger { background: #e74c3c; color: white; }
.badge-warning { background: #f39c12; color: white; }
.badge-info { background: #3498db; color: white; }
.badge-primary { background: #9b59b6; color: white; }
.badge-secondary { background: #95a5a6; color: white; }
.badge-locked { background: #bdc3c7; color: #7f8c8d; }

/* ===== TABLE ===== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 15px; }
.table-responsive .table { min-width: 600px; }
.table { width: 100%; border-collapse: collapse; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.table th, .table td { padding: clamp(8px, 1.5vw, 12px) clamp(10px, 1.8vw, 15px); text-align: left; border-bottom: 1px solid #f0f0f0; font-size: clamp(12px, 1.5vw, 14px); }
.table th { background: #f8f9fa; font-weight: 600; color: #555; white-space: nowrap; }
.table tr:hover { background: #f8f9fa; }
.table td .btn-sm { margin: 2px; }

/* ===== PROGRESS BAR ===== */
.progress-bar { background: #ecf0f1; border-radius: 10px; height: 24px; overflow: hidden; position: relative; }
.progress-fill { background: linear-gradient(90deg, #27ae60, #2ecc71); height: 100%; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-size: clamp(11px, 1.5vw, 12px); font-weight: 600; transition: width 0.5s; min-width: 40px; }
.progress-bar.large { height: clamp(26px, 4vw, 30px); margin: 20px 0; }
.progress-bar.large .progress-fill { font-size: clamp(12px, 1.8vw, 14px); }

/* ===== ADMIN LAYOUT ===== */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #2c3e50; color: white; padding: 25px 0; flex-shrink: 0; }
.sidebar h2 { padding: 0 20px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); margin-bottom: 10px; font-size: clamp(16px, 2.2vw, 18px); }
.sidebar ul { list-style: none; }
.sidebar ul li a { display: block; padding: 12px 20px; color: rgba(255,255,255,0.7); transition: all 0.2s; border-left: 3px solid transparent; font-size: clamp(13px, 1.6vw, 14px); }
.sidebar ul li a:hover, .sidebar ul li a.active { background: rgba(255,255,255,0.08); color: white; text-decoration: none; border-left-color: #3498db; }
.main-content { flex: 1; padding: clamp(15px, 3vw, 30px); overflow-x: auto; }
.main-content h1 { margin-bottom: 20px; color: #2c3e50; font-size: clamp(1.2em, 3vw, 1.6em); }

/* ===== STATS GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: clamp(10px, 2vw, 20px); margin-bottom: 30px; }
.stat-card { background: white; padding: clamp(15px, 3vw, 25px); border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); text-align: center; }
.stat-card h3 { font-size: clamp(24px, 5vw, 32px); color: #2c3e50; margin-bottom: 5px; }
.stat-card p { color: #7f8c8d; font-size: clamp(12px, 1.6vw, 14px); }

/* ===== STUDENT LAYOUT ===== */
.student-layout { min-height: 100vh; }
.student-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: clamp(12px, 2.5vw, 20px) clamp(15px, 3vw, 30px); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.student-header h1 { font-size: clamp(18px, 3vw, 22px); word-break: break-word; }
.header-info { display: flex; align-items: center; gap: clamp(8px, 1.5vw, 15px); flex-wrap: wrap; }
.student-content { max-width: 900px; margin: 0 auto; padding: clamp(15px, 3vw, 30px) clamp(10px, 2.5vw, 20px); }
.student-content h2 { color: #2c3e50; margin-bottom: 10px; font-size: clamp(1.1em, 2.8vw, 1.4em); }

/* ===== ACTIVITY MAP ===== */
.activity-map { display: flex; flex-direction: column; gap: 8px; margin-top: 15px; }
.section-divider { text-align: center; padding: 15px 0 5px; margin-top: 10px; border-top: 2px dashed #ddd; }
.section-divider span { background: #f0f2f5; padding: 0 15px; color: #7f8c8d; font-weight: 600; font-size: clamp(12px, 1.6vw, 14px); text-transform: uppercase; letter-spacing: 1px; }

.activity-card { display: flex; align-items: center; gap: clamp(8px, 1.5vw, 15px); background: white; padding: clamp(10px, 2vw, 15px) clamp(12px, 2.5vw, 20px); border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); transition: all 0.2s; border-left: 4px solid #bdc3c7; }
.activity-card:hover { transform: translateX(3px); box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.activity-card.completed { border-left-color: #27ae60; background: #f0fff4; }
.activity-card.current { border-left-color: #3498db; background: #ebf5ff; }
.activity-card.unlocked { border-left-color: #f39c12; }
.activity-card.locked { opacity: 0.6; }
.activity-level { font-size: clamp(16px, 3vw, 20px); font-weight: 700; color: #bdc3c7; width: 36px; text-align: center; flex-shrink: 0; }
.activity-card.completed .activity-level { color: #27ae60; }
.activity-card.current .activity-level { color: #3498db; }
.activity-icon { font-size: clamp(20px, 3.5vw, 24px); flex-shrink: 0; }
.activity-info { flex: 1; min-width: 0; }
.activity-info h4 { font-size: clamp(13px, 1.8vw, 15px); color: #2c3e50; margin-bottom: 2px; word-break: break-word; }
.activity-type { font-size: clamp(11px, 1.4vw, 12px); color: #95a5a6; }
.activity-status { min-width: 90px; text-align: center; flex-shrink: 0; }
.activity-action { min-width: 60px; text-align: right; flex-shrink: 0; }

/* ===== READING TEXT ===== */
.reading-text { background: #fafafa; padding: clamp(15px, 3vw, 25px); border-radius: 10px; border: 1px solid #e0e0e0; margin: 15px 0; line-height: 1.8; font-size: clamp(14px, 2vw, 16px); }

/* ===== QUESTIONS ===== */
.question-item { margin: 20px 0; padding: clamp(10px, 2vw, 15px); background: #fafafa; border-radius: 8px; border-left: 3px solid #3498db; }
.question-item p { margin-bottom: 10px; font-size: clamp(14px, 1.8vw, 15px); }
.radio-label { display: block; padding: 8px 12px; margin: 4px 0; border-radius: 6px; cursor: pointer; transition: background 0.2s; font-size: clamp(13px, 1.6vw, 14px); }
.radio-label:hover { background: #e8f0fe; }
.radio-label input { margin-right: 8px; width: auto; }

/* ===== TIMER ===== */
.timer { font-size: clamp(32px, 8vw, 48px); font-weight: 700; color: #e74c3c; text-align: center; padding: clamp(10px, 3vw, 20px); font-family: 'Courier New', monospace; }

/* ===== GAMES ===== */
.game-area { padding: 10px 0; }
.puzzle-text { font-size: clamp(16px, 2.5vw, 18px); padding: clamp(12px, 3vw, 20px); background: #f8f9fa; border-radius: 10px; margin: 15px 0; line-height: 1.8; }

/* Letter Grid */
.letter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 280px; margin: 20px auto; }
.letter-cell { aspect-ratio: 1; background: #3498db; color: white; font-size: clamp(18px, 3.5vw, 24px); font-weight: 700; display: flex; align-items: center; justify-content: center; border-radius: 8px; text-transform: uppercase; }

/* Memory Game */
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(6px, 1.5vw, 10px); max-width: 400px; margin: 20px auto; width: 100%; }
.memory-card { aspect-ratio: 1; perspective: 600px; cursor: pointer; }
.memory-card .card-inner { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.4s; }
.memory-card.flipped .card-inner { transform: rotateY(180deg); }
.memory-card.matched .card-inner { transform: rotateY(180deg); }
.memory-card.matched .card-back { background: #27ae60; }
.card-front, .card-back { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-size: clamp(18px, 3.5vw, 24px); font-weight: 700; }
.card-front { background: #667eea; color: white; }
.card-back { background: #3498db; color: white; transform: rotateY(180deg); }

/* Maze */
.maze-grid { display: inline-grid; grid-template-columns: repeat(5, 1fr); gap: 2px; margin: 20px auto; max-width: 280px; width: 100%; }
.maze-cell { aspect-ratio: 1; border-radius: 4px; min-width: 40px; }
.maze-cell.wall { background: #2c3e50; }
.maze-cell.path { background: #ecf0f1; }
.maze-cell.start { background: #27ae60; }
.maze-cell.end { background: #e74c3c; }

/* ===== CARD ===== */
.card { background: white; padding: clamp(15px, 3vw, 25px); border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.card h3 { margin-bottom: 15px; color: #2c3e50; font-size: clamp(1em, 2.5vw, 1.2em); }

/* ===== MODAL ===== */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-content { background: white; padding: clamp(20px, 4vw, 30px); border-radius: 16px; max-width: 400px; width: 100%; position: relative; }
.modal .close { position: absolute; top: 10px; right: 15px; font-size: 24px; cursor: pointer; color: #999; }
.modal .close:hover { color: #333; }

/* ===== LEGEND ===== */
.legend { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 15px; }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.mt-1 { margin-top: 15px; }
.mt-2 { margin-top: 30px; }
.mb-1 { margin-bottom: 15px; }
.text-muted { color: #95a5a6; font-size: clamp(12px, 1.5vw, 14px); }

/* ===== TOUCH FRIENDLY ===== */
@media (hover: none) and (pointer: coarse) {
    .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .btn-sm { min-height: 36px; }
    .form-group input, .form-group textarea, .form-group select { font-size: 16px; } /* prevents iOS zoom */
    .sidebar ul li a { padding: 14px 20px; }
    .activity-card { padding: 14px 16px; }
}

/* ===== TABLET (768px and below) ===== */
@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .sidebar { width: 100%; padding: 12px 15px; }
    .sidebar h2 { padding: 0 0 12px; margin-bottom: 6px; font-size: 16px; }
    .sidebar ul { display: flex; flex-wrap: wrap; gap: 3px; }
    .sidebar ul li a { padding: 8px 12px; border-left: none; border-bottom: 2px solid transparent; font-size: 13px; }
    .sidebar ul li a:hover, .sidebar ul li a.active { border-left: none; border-bottom-color: #3498db; }
    .main-content { padding: 15px; }
    .landing-box { padding: 30px 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .activity-card { flex-wrap: wrap; gap: 8px; }
    .activity-status { min-width: auto; }
    .activity-action { min-width: auto; }
    .form-inline { flex-direction: column; }
    .form-inline .form-group { min-width: 100%; }
    .form-row { flex-direction: column; gap: 10px; }
    .form-row .half { min-width: 100%; }
    .memory-grid { max-width: 100%; }
    .student-header h1 { font-size: 18px; }
}

/* ===== SMALL PHONE (480px and below) ===== */
@media (max-width: 480px) {
    .student-header { flex-direction: column; text-align: center; gap: 8px; }
    .header-info { justify-content: center; }
    .stats-grid { grid-template-columns: 1fr; }
    .letter-grid { max-width: 220px; }
    .maze-grid { max-width: 220px; }
    .maze-cell { min-width: 36px; }
    .activity-card { flex-direction: column; align-items: stretch; text-align: center; }
    .activity-level { width: auto; }
    .activity-status { text-align: center; }
    .activity-action { text-align: center; }
    .table-responsive .table { font-size: 12px; }
    .table-responsive .table th, .table-responsive .table td { padding: 6px 8px; }
    .landing-box { padding: 24px 16px; border-radius: 14px; }
    .login-box { padding: 24px 16px; }
    .reading-text { padding: 12px; font-size: 14px; line-height: 1.7; }
    .timer { font-size: 28px; }
}

/* ===== LARGE SCREEN (1200px+) ===== */
@media (min-width: 1200px) {
    .student-content { max-width: 960px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== PRINT ===== */
@media print {
    .sidebar, .student-header, .btn, form { display: none; }
    .main-content { padding: 0; }
    .table { box-shadow: none; }
}
