:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --text-2: #94a3b8;
  --accent: #3b82f6;
  --accent-2: #06b6d4;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --premium: #f59e0b;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* RTL for Arabic */
[dir="rtl"] body { direction: rtl; }
[dir="rtl"] .view-header,
[dir="rtl"] .quiz-header,
[dir="rtl"] .quick-item,
[dir="rtl"] .exam-row {
  flex-direction: row-reverse;
}
[dir="rtl"] .card-icon { margin-right: 0; margin-left: 12px; }
[dir="rtl"] .result-detail > div { text-align: right; }

#app { max-width: 430px; margin: 0 auto; min-height: 100vh; position: relative; padding-bottom: 80px; }

/* HEADER */
#app-header {
  position: sticky; top: 0;
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg) 100%);
  backdrop-filter: blur(20px);
  padding: calc(12px + var(--safe-top)) 16px 12px;
  display: flex; justify-content: space-between; align-items: center;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logo { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.5px; }
.logo span { color: var(--accent); }

.btn-premium {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white; border: none; padding: 8px 16px;
  border-radius: 20px; font-weight: 600;
  font-size: 0.85rem; box-shadow: 0 2px 10px rgba(245,158,11,0.3);
  cursor: pointer; transition: transform 0.15s;
}
.btn-premium:active { transform: scale(0.95); }

/* TAB BAR */
.tab-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  background: rgba(30,41,59,0.95); backdrop-filter: blur(20px);
  display: flex; justify-content: space-around;
  padding: 8px 0 calc(8px + var(--safe-bottom));
  z-index: 100;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.tab {
  background: none; border: none; color: var(--text-2);
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; font-size: 0.7rem; flex: 1;
  cursor: pointer; transition: all 0.2s;
  padding: 4px 0;
}

.tab svg { width: 22px; height: 22px; stroke: var(--text-2); transition: all 0.2s; }
.tab.active { color: var(--accent); }
.tab.active svg { stroke: var(--accent); }

/* VIEWS */
.view { display: none; padding: 0 16px 24px; animation: fadeIn 0.25s ease; }
.view.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }

/* DASHBOARD */
.dashboard-hero {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  margin: 16px -16px 20px; padding: 24px 16px;
  text-align: center; border-radius: 0 0 24px 24px;
}

.dashboard-hero h1 { font-size: 1.5rem; margin-bottom: 8px; font-weight: 700; }
.dashboard-hero p { color: var(--text-2); margin-bottom: 20px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; border: none; padding: 14px 28px;
  border-radius: 12px; font-size: 1rem; font-weight: 600;
  cursor: pointer; width: 100%; transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(59,130,246,0.3);
}
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }

.btn-secondary {
  background: var(--surface-2); color: var(--text); border: none;
  padding: 12px 20px; border-radius: 10px; font-size: 0.95rem;
  cursor: pointer; flex: 1; transition: all 0.2s;
}
.btn-secondary:active { background: var(--text-2); color: var(--bg); }

/* CARDS */
.cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }

.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: transform 0.2s;
  border: 1px solid rgba(255,255,255,0.05);
}
.card:active { transform: scale(0.97); }

.card-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; margin-bottom: 10px;
}
.card-icon.trafik { background: rgba(59,130,246,0.15); }
.card-icon.motor { background: rgba(6,182,212,0.15); }
.card-icon.ilkyardim { background: rgba(34,197,94,0.15); }
.card-icon.adabi { background: rgba(245,158,11,0.15); }

.card h3 { font-size: 0.95rem; margin-bottom: 4px; }
.card p { font-size: 0.8rem; color: var(--text-2); margin-bottom: 10px; }

.progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.5s; }

/* SECTION TITLE */
.section-title {
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-2); margin-bottom: 10px; font-weight: 600;
}

/* QUICK LIST */
.quick-list { display: flex; flex-direction: column; gap: 8px; }

.quick-item {
  background: var(--surface); border: none; border-radius: 12px;
  padding: 16px; color: var(--text); display: flex;
  justify-content: space-between; align-items: center;
  cursor: pointer; font-size: 0.95rem; transition: all 0.2s;
}
.quick-item:active { background: var(--surface-2); }
.quick-item svg { width: 18px; height: 18px; stroke: var(--text-2); stroke-width: 2; fill: none; }

/* VIEW HEADER */
.view-header {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 0; margin-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.btn-back {
  background: var(--surface); border: none; color: var(--text);
  width: 40px; height: 40px; border-radius: 12px;
  font-size: 1.2rem; cursor: pointer; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}

/* STUDY CONTENT */
.study-content { display: flex; flex-direction: column; gap: 10px; }

.lesson-card {
  background: var(--surface); border-radius: 12px; padding: 16px;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; transition: all 0.2s;
}
.lesson-card:active { background: var(--surface-2); }

.lesson-info h4 { font-size: 0.95rem; margin-bottom: 4px; }
.lesson-info span { font-size: 0.8rem; color: var(--text-2); }

.lesson-status {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); display: flex;
  align-items: center; justify-content: center; font-size: 0.85rem;
}
.lesson-status.done { background: var(--success); }

/* QUIZ */
.quiz-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; margin-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  position: sticky; top: calc(56px + var(--safe-top));
  background: var(--bg); z-index: 50;
}

.quiz-info { display: flex; align-items: center; gap: 16px; font-size: 0.9rem; font-weight: 600; }

.timer { color: var(--warning); font-variant-numeric: tabular-nums; }
.timer.danger { color: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.btn-icon {
  background: none; border: none; color: var(--text-2);
  font-size: 1.5rem; cursor: pointer; padding: 4px 8px;
}
.btn-icon.active { color: var(--warning); }

/* QUESTION */
.question-area { display: flex; flex-direction: column; gap: 16px; }

.question-image {
  width: 100%; min-height: 200px; background: var(--surface);
  border-radius: 12px; overflow: hidden; display: flex;
  align-items: center; justify-content: center; color: var(--text-2);
  font-size: 3rem;
}
.question-image img { width: 100%; height: auto; display: block; border-radius: 12px; }

.question-text {
  font-size: 1.05rem; line-height: 1.7; font-weight: 500;
  background: var(--surface); padding: 20px; border-radius: 12px;
}

.options { display: flex; flex-direction: column; gap: 10px; }

.option {
  background: var(--surface); border: 2px solid transparent;
  border-radius: 12px; padding: 16px; text-align: left;
  color: var(--text); font-size: 0.95rem; cursor: pointer;
  transition: all 0.2s; position: relative;
}
.option:active { background: var(--surface-2); }
.option.selected { border-color: var(--accent); background: rgba(59,130,246,0.1); }
.option.correct { border-color: var(--success); background: rgba(34,197,94,0.1); }
.option.wrong { border-color: var(--danger); background: rgba(239,68,68,0.1); }

.option-label {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); margin-right: 12px;
  font-size: 0.8rem; font-weight: 600; flex-shrink: 0;
}
[dir="rtl"] .option-label { margin-right: 0; margin-left: 12px; }

.option.selected .option-label { background: var(--accent); }
.option.correct .option-label { background: var(--success); }
.option.wrong .option-label { background: var(--danger); }

/* SOLUTION BOX */
.solution-box {
  background: rgba(34,197,94,0.1); border: 1px solid var(--success);
  border-radius: 12px; padding: 16px; margin-top: 12px;
  display: none;
}
.solution-box.show { display: block; }
.solution-box h4 { color: var(--success); margin-bottom: 8px; font-size: 0.9rem; }
.solution-box p { color: var(--text-2); font-size: 0.9rem; line-height: 1.6; }

/* QUIZ FOOTER */
.quiz-footer {
  position: fixed; bottom: calc(64px + var(--safe-bottom)); left: 50%;
  transform: translateX(-50%); width: 100%; max-width: 430px;
  display: flex; gap: 10px; padding: 12px 16px;
  background: var(--bg); z-index: 90;
  border-top: 1px solid rgba(255,255,255,0.05);
}

/* RESULTS */
.result-card {
  background: var(--surface); border-radius: 24px; padding: 32px;
  text-align: center; margin-top: 24px;
}

.result-score {
  font-size: 4rem; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.result-label { font-size: 1.3rem; font-weight: 600; margin: 8px 0 24px; }
.result-label.pass { color: var(--success); }
.result-label.fail { color: var(--danger); }

.result-detail { display: flex; justify-content: space-around; margin-bottom: 24px; }
.result-detail > div { font-size: 1rem; }
.result-detail b { display: block; color: var(--text-2); font-size: 0.8rem; margin-bottom: 4px; }

.result-actions { display: flex; flex-direction: column; gap: 10px; }

/* EXAM LIST */
.exam-list { display: flex; flex-direction: column; gap: 10px; }

.exam-row {
  background: var(--surface); border-radius: 12px; padding: 16px;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; transition: all 0.2s;
}
.exam-row:active { background: var(--surface-2); }

.exam-row h4 { font-size: 0.95rem; margin-bottom: 4px; }
.exam-row span { font-size: 0.8rem; color: var(--text-2); }

/* REVIEW */
.review-item {
  background: var(--surface); border-radius: 16px; padding: 20px;
  margin-bottom: 16px; border-left: 4px solid var(--accent);
}
.review-item.correct { border-left-color: var(--success); }
.review-item.wrong { border-left-color: var(--danger); }
[dir="rtl"] .review-item { border-left: none; border-right: 4px solid var(--accent); }
[dir="rtl"] .review-item.correct { border-right-color: var(--success); }
[dir="rtl"] .review-item.wrong { border-right-color: var(--danger); }

/* PREMIUM */
.btn-premium-large {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white; border: none; padding: 18px;
  border-radius: 14px; font-size: 1.1rem; font-weight: 700;
  width: 100%; cursor: pointer; margin-top: 20px;
  box-shadow: 0 6px 20px rgba(245,158,11,0.3);
}
.btn-premium-large:active { transform: scale(0.98); }

/* TOAST */
.toast {
  position: fixed; top: calc(60px + var(--safe-top)); left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--surface); color: var(--text);
  padding: 12px 24px; border-radius: 12px; font-size: 0.95rem;
  z-index: 200; opacity: 0; transition: all 0.3s;
  box-shadow: var(--shadow); white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.05);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* LEARNING CARDS */
.card-flip {
  background: var(--surface); border-radius: 16px;
  padding: 20px; margin-bottom: 12px; cursor: pointer;
  transition: transform 0.3s; min-height: 160px;
  display: flex; flex-direction: column; justify-content: center;
  text-align: center; border: 1px solid rgba(255,255,255,0.05);
}
.card-flip:active { transform: scale(0.98); }

.card-flip .front { font-size: 1.1rem; font-weight: 600; }
.card-flip .back { display: none; color: var(--text-2); margin-top: 12px; font-size: 0.95rem; }
.card-flip.flipped .back { display: block; }

/* TRACKING */
.streak-bar {
  background: var(--surface); border-radius: 12px; padding: 16px;
  margin-bottom: 16px; display: flex; justify-content: space-around;
}
.streak-bar > div { text-align: center; }
.streak-bar .val { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.streak-bar .lbl { font-size: 0.75rem; color: var(--text-2); text-transform: uppercase; }

/* RESPONSIVE */
@media (max-width: 380px) {
  .cards-grid { grid-template-columns: 1fr; }
  .dashboard-hero h1 { font-size: 1.3rem; }
}

/* HIDE scrollbar but allow scroll */
::-webkit-scrollbar { width: 0; height: 0; }
