/* SkorA+ — Malaysian Learning App */
:root {
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --primary-dark: #5A4BD1;
  --secondary: #00CEC9;
  --accent: #FDCB6E;
  --accent-dark: #E17055;
  --success: #00B894;
  --danger: #D63031;
  --bg: #F8F9FD;
  --card: #FFFFFF;
  --text: #2D3436;
  --text-light: #636E72;
  --border: #DFE6E9;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(108,92,231,.08);
  --shadow-lg: 0 8px 32px rgba(108,92,231,.12);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100dvh; }
a { color: var(--primary); text-decoration: none; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; border: none; border-radius: var(--radius-sm);
  padding: .75rem 1.5rem; cursor: pointer; transition: all .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; border-radius: var(--radius); }
.btn-sm { padding: .5rem 1rem; font-size: .875rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Cards */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.5rem; transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card-flat { box-shadow: none; border: 1px solid var(--border); }
.card-flat:hover { transform: none; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .375rem; font-size: .9rem; }
.form-input {
  width: 100%; padding: .75rem 1rem; border: 2px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 1rem; transition: border-color .2s; background: #fff;
}
.form-input:focus { outline: none; border-color: var(--primary); }
.form-input::placeholder { color: #B2BEC3; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.container-sm { max-width: 480px; margin: 0 auto; padding: 0 1rem; }
.flex { display: flex; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.p-2 { padding: 1rem; } .p-3 { padding: 1.5rem; }

/* Nav */
.nav {
  background: #fff; border-bottom: 1px solid var(--border); padding: .75rem 1rem;
  position: sticky; top: 0; z-index: 100;
}
.nav-brand { font-size: 1.25rem; font-weight: 800; color: var(--primary); }
.nav-brand span { color: var(--accent-dark); }

/* Landing page */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #A29BFE 50%, var(--secondary) 100%);
  color: #fff; padding: 4rem 1rem; text-align: center; min-height: 60vh;
  display: flex; align-items: center; justify-content: center;
}
.hero h1 { font-size: clamp(2rem, 6vw, 3.5rem); margin-bottom: .5rem; }
.hero p { font-size: 1.2rem; opacity: .9; max-width: 600px; margin: 0 auto 2rem; }
.hero .btn { font-size: 1.1rem; padding: 1rem 2.5rem; }

.features { padding: 3rem 1rem; }
.feature-card { text-align: center; padding: 2rem 1.5rem; }
.feature-card .icon { font-size: 3rem; margin-bottom: 1rem; }
.feature-card h3 { margin-bottom: .5rem; color: var(--primary); }

.pricing { padding: 3rem 1rem; background: var(--bg); }
.price-card { text-align: center; padding: 2rem; position: relative; }
.price-card.popular { border: 3px solid var(--primary); }
.price-card .badge-popular {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff; padding: .25rem 1rem; border-radius: 20px; font-size: .8rem; font-weight: 700;
}
.price-amount { font-size: 2.5rem; font-weight: 800; color: var(--primary); }
.price-amount small { font-size: .9rem; font-weight: 400; color: var(--text-light); }
.price-features { list-style: none; text-align: left; margin: 1.5rem 0; }
.price-features li { padding: .375rem 0; padding-left: 1.5rem; position: relative; }
.price-features li::before { content: '✓'; position: absolute; left: 0; color: var(--success); font-weight: 700; }

/* Dashboard */
.dash-header { padding: 1.5rem; background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; border-radius: 0 0 var(--radius) var(--radius); }
.dash-header h2 { font-size: 1.1rem; font-weight: 400; opacity: .9; }
.dash-header h1 { font-size: 1.5rem; }
.stat-row { display: flex; gap: .75rem; margin-top: 1rem; }
.stat-pill {
  background: rgba(255,255,255,.2); border-radius: 20px; padding: .375rem .75rem;
  font-size: .85rem; backdrop-filter: blur(4px);
}

.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; padding: 1rem; }
.subject-card {
  background: var(--card); border-radius: var(--radius); padding: 1.25rem; text-align: center;
  cursor: pointer; transition: all .2s; border: 2px solid transparent;
}
.subject-card:hover, .subject-card.active { border-color: var(--primary); transform: scale(1.03); }
.subject-card .icon { font-size: 2.5rem; }
.subject-card .name { font-weight: 700; margin-top: .375rem; font-size: .95rem; }

.topic-list { padding: 1rem; }
.topic-item {
  background: var(--card); border-radius: var(--radius-sm); padding: 1rem 1.25rem;
  margin-bottom: .5rem; display: flex; align-items: center; gap: 1rem;
  cursor: pointer; transition: all .2s; border: 1px solid var(--border);
}
.topic-item:hover { border-color: var(--primary); background: #F8F7FF; }
.topic-progress { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.topic-progress.done { background: var(--success); color: #fff; }
.topic-progress.partial { background: var(--accent); color: var(--text); }
.topic-progress.none { background: var(--border); color: var(--text-light); }

/* Lesson */
.lesson-content { padding: 1.5rem; max-width: 700px; margin: 0 auto; }
.lesson-content h3 { color: var(--primary); margin: 1.5rem 0 .75rem; }
.lesson-content .example-box {
  background: #F0EFFF; border-left: 4px solid var(--primary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.25rem; margin: 1rem 0; font-size: 1.2rem;
}
.lesson-content .tip-box {
  background: #FFF3CD; border-left: 4px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: .75rem 1rem; margin: 1rem 0;
}

/* Quiz */
.quiz-card { max-width: 600px; margin: 1rem auto; padding: 1.5rem; }
.quiz-question { font-size: 1.2rem; font-weight: 600; margin-bottom: 1.25rem; }
.quiz-choices { display: flex; flex-direction: column; gap: .5rem; }
.quiz-choice {
  padding: 1rem 1.25rem; border: 2px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all .2s; font-size: 1.05rem; background: #fff;
}
.quiz-choice:hover { border-color: var(--primary-light); background: #F8F7FF; }
.quiz-choice.selected { border-color: var(--primary); background: #F0EFFF; }
.quiz-choice.correct { border-color: var(--success); background: #D4EDDA; }
.quiz-choice.wrong { border-color: var(--danger); background: #F8D7DA; }
.quiz-explanation {
  margin-top: 1rem; padding: 1rem; border-radius: var(--radius-sm);
  background: #E8F8F5; border-left: 4px solid var(--success);
}

/* AI Chat */
.chat-container { max-width: 600px; margin: 0 auto; height: calc(100dvh - 120px); display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; }
.chat-bubble {
  max-width: 85%; margin-bottom: .75rem; padding: .75rem 1rem;
  border-radius: var(--radius); line-height: 1.5; word-break: break-word;
}
.chat-bubble.user { background: var(--primary); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.chat-bubble.ai { background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-input-row { display: flex; gap: .5rem; padding: .75rem 1rem; background: #fff; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; }

/* Progress bar */
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s; }

/* Badges */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: .75rem; }
.badge-item { text-align: center; padding: 1rem; opacity: .3; }
.badge-item.earned { opacity: 1; }
.badge-item .icon { font-size: 2.5rem; }
.badge-item .name { font-size: .8rem; font-weight: 600; margin-top: .25rem; }

/* Bottom nav (mobile) */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
  border-top: 1px solid var(--border); display: flex; z-index: 100; padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; text-align: center; padding: .625rem .25rem; font-size: .7rem; color: var(--text-light);
  display: flex; flex-direction: column; align-items: center; gap: .125rem; transition: color .2s;
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a .icon { font-size: 1.25rem; }
.has-bottom-nav { padding-bottom: 72px; }

/* Toast */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: .75rem 1.5rem; border-radius: var(--radius);
  font-size: .9rem; z-index: 200; opacity: 0; transition: opacity .3s;
}
.toast.show { opacity: 1; }

/* Responsive */
@media (max-width: 600px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hero { padding: 3rem 1rem; min-height: auto; }
  .hero h1 { font-size: 2rem; }
}
@media (min-width: 768px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .subject-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn .3s ease-out; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.pulse { animation: pulse .6s ease-in-out; }

/* Loading */
.loading { text-align: center; padding: 3rem; color: var(--text-light); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Year selector */
.year-tabs { display: flex; gap: .375rem; overflow-x: auto; padding: 1rem; -webkit-overflow-scrolling: touch; }
.year-tab {
  flex-shrink: 0; padding: .5rem 1rem; border-radius: 20px; font-weight: 600;
  background: var(--card); border: 2px solid var(--border); cursor: pointer; font-size: .9rem; transition: all .2s;
}
.year-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Back button */
.back-btn { background: none; border: none; color: var(--text); padding: .5rem; cursor: pointer; font-size: 1.2rem; }
