/* =====================================================
   YKS Programcisi - Ortak Stil
   Acik tema varsayilan; koyu tema [data-theme="dark"]
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --ink: #1c2733;
  --muted: #5c6b7a;
  --line: #e2e8ef;
  --primary: #2f5d8a;
  --primary-soft: #e7eef6;
  --primary-ink: #ffffff;
  --success: #2e9e6b;
  --success-soft: #e3f4ec;
  --warn: #b9742c;
  --warn-soft: #fbf0e2;
  --danger: #c14848;
  --danger-soft: #f9e9e9;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(28, 39, 51, .07), 0 6px 20px rgba(28, 39, 51, .05);
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-head: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg: #11161d;
  --surface: #1a212b;
  --surface-2: #222b37;
  --ink: #e8edf3;
  --muted: #93a1b1;
  --line: #2b3543;
  --primary: #6da3d8;
  --primary-soft: #21364c;
  --primary-ink: #0e1722;
  --success: #4fc08d;
  --success-soft: #1c3a2d;
  --warn: #dba05c;
  --warn-soft: #3c2f1c;
  --danger: #e07a7a;
  --danger-soft: #422222;
  --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-head); letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ---------- Ust menu ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 8px; height: 58px;
}
.brand {
  font-family: var(--font-head); font-weight: 700; font-size: 1.05rem;
  color: var(--ink); display: flex; align-items: center; gap: 8px; margin-right: 12px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-logo { width: 28px; height: 28px; object-fit: contain; display: flex; align-items: center; }
.brand-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--primary); display: inline-block; }
.nav-links { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  padding: 7px 12px; border-radius: 8px; color: var(--muted);
  font-weight: 500; white-space: nowrap; font-size: .92rem;
}
.nav-links a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav-links a.active { background: var(--primary-soft); color: var(--primary); }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- Genel yerlesim ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.sub { color: var(--muted); font-size: .92rem; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-title h2, .card-title h3 { margin: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Form ---------- */
label { display: block; font-weight: 500; font-size: .88rem; margin-bottom: 4px; color: var(--ink); }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink);
  font: inherit; font-size: .94rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }
textarea { resize: vertical; min-height: 80px; }
.field { margin-bottom: 12px; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 140px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }

/* ---------- Butonlar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  font-size: .9rem; cursor: pointer; transition: background .12s, transform .06s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: var(--success); filter: brightness(1.07); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: 5px 10px; font-size: .82rem; border-radius: 7px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { width: 36px; height: 36px; padding: 0; font-size: 1.05rem; }

/* ---------- Rozet / etiket ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Tablo ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ---------- Sekmeler ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 9px 14px; font-weight: 600; font-size: .92rem; color: var(--muted);
  border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap; font-family: inherit;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Haftalik program tablosu (imza bilesen) ---------- */
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-label { font-family: var(--font-head); font-weight: 600; min-width: 180px; text-align: center; }
.week-grid {
  display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 10px; overflow-x: auto; padding-bottom: 6px;
}
.day-col { min-width: 150px; }
.day-head {
  font-family: var(--font-head); font-weight: 600; font-size: .86rem;
  padding: 7px 10px; border-radius: 8px; background: var(--surface-2);
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.day-head.today { background: var(--primary-soft); color: var(--primary); }
.day-head .dnum { color: var(--muted); font-weight: 500; font-size: .8rem; }
.day-head.today .dnum { color: var(--primary); }
.lesson {
  border: 1px solid var(--line); border-left: 4px solid var(--lc, var(--primary));
  border-radius: 9px; background: var(--surface); padding: 8px 10px; margin-bottom: 8px;
  cursor: pointer; transition: box-shadow .12s;
}
.lesson:hover { box-shadow: var(--shadow); }
.lesson.done { background: var(--success-soft); border-color: var(--success); border-left-color: var(--success); }
.lesson.partial { background: linear-gradient(90deg, var(--success-soft) 0%, rgba(255,200,100,0.2) 100%); border-color: #ffa500; border-left-color: #ffa500; }
.lesson.missed { background: var(--danger-soft); border-color: var(--danger); border-left-color: var(--danger); }
.lesson.missed .lesson-topic, .lesson.missed .lesson-meta { color: var(--danger); }
.lesson-subject { font-weight: 600; font-size: .86rem; }
.lesson-topic { font-size: .8rem; color: var(--muted); margin-top: 1px; }
.lesson.done .lesson-topic { color: var(--success); }
.lesson-meta { font-size: .76rem; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; align-items: center; }
.lesson.done .lesson-meta { color: var(--success); }
.day-empty { font-size: .8rem; color: var(--muted); text-align: center; padding: 12px 4px; border: 1px dashed var(--line); border-radius: 9px; }
.add-lesson-btn {
  width: 100%; border: 1px dashed var(--line); background: none; color: var(--muted);
  border-radius: 9px; padding: 6px; cursor: pointer; font: inherit; font-size: .8rem;
}
.add-lesson-btn:hover { color: var(--primary); border-color: var(--primary); }

/* Aylik gorunum */
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month-grid .mh { text-align: center; font-size: .78rem; color: var(--muted); font-weight: 600; padding: 4px 0; }
.mday {
  border: 1px solid var(--line); border-radius: 8px; min-height: 74px; padding: 5px 6px;
  font-size: .78rem; background: var(--surface); cursor: pointer;
}
.mday:hover { border-color: var(--primary); }
.mday .num { font-weight: 600; color: var(--muted); }
.mday.today .num { color: var(--primary); }
.mday.other { opacity: .4; }
.mdot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin: 2px 2px 0 0; background: var(--lc, var(--primary)); }
.mdot.done { background: var(--success); }
@media (max-width: 700px) { .mday { min-height: 56px; } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 22, 30, .45);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 14px; z-index: 100; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 460px; padding: 20px; border: 1px solid var(--line);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }

/* ---------- Konu secici ---------- */
.topic-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.topic-item { padding: 8px 12px; cursor: pointer; font-size: .9rem; border-bottom: 1px solid var(--line); }
.topic-item:last-child { border-bottom: none; }
.topic-item:hover { background: var(--primary-soft); color: var(--primary); }

/* ---------- Sayac ---------- */
.timer-display {
  font-family: var(--font-mono); font-size: clamp(3.2rem, 14vw, 7rem);
  font-weight: 600; text-align: center; letter-spacing: .02em;
  font-variant-numeric: tabular-nums; margin: 18px 0; line-height: 1;
}
.timer-display.warning { color: var(--danger); }
.timer-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.preset-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }

/* ---------- Liste kartlari ---------- */
.student-card {
  display: flex; align-items: center; gap: 12px; padding: 13px 15px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 10px; cursor: pointer; transition: box-shadow .12s;
}
.student-card:hover { box-shadow: var(--shadow); text-decoration: none; }
.avatar {
  width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft);
  color: var(--primary); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; flex-shrink: 0;
}
.student-card .info { flex: 1; min-width: 0; }
.student-card .name { font-weight: 600; color: var(--ink); }
.student-card .meta { font-size: .82rem; color: var(--muted); }

/* ---------- Bildirim (toast) ---------- */
#toast-zone { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(420px, 92vw); }
.toast {
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 10px;
  font-size: .9rem; box-shadow: var(--shadow); animation: toast-in .2s ease;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--success); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Giris sayfasi ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo h1 { font-size: 1.7rem; margin-bottom: 4px; }

/* ---------- Bos durum ---------- */
.empty { text-align: center; color: var(--muted); padding: 34px 14px; }
.empty .big { font-size: 2rem; margin-bottom: 8px; }

/* ---------- Istatistik kutulari ---------- */
.stat { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.stat .v { font-family: var(--font-head); font-weight: 700; font-size: 1.4rem; }
.stat .l { font-size: .8rem; color: var(--muted); }

/* ---------- Mobil ---------- */
@media (max-width: 700px) {
  .container { padding: 16px 12px 80px; }
  .card { padding: 14px; }
  .week-grid { grid-template-columns: 1fr; }
  .day-col { min-width: 0; }
  .week-label { min-width: 0; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Kucuk renk noktasi (ders rengi gostergesi) */
.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: baseline;
}

html, body { overflow-x: hidden; max-width: 100%; }

.free-pool { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.free-chip {
  border: 1px dashed var(--lc, var(--primary)); border-radius: 9px;
  padding: 6px 10px; font-size: .82rem; cursor: grab; background: var(--surface);
  display: flex; align-items: center; gap: 6px; user-select: none;
}
.free-chip.dragging { opacity: .4; }
.free-chip.picked { outline: 2px solid var(--primary); }
[data-drop].drop-over, [data-drop].drop-target { background: var(--primary-soft); }

.topic-list { display: none; }
.topic-list.open { display: block; }

@media (max-width: 700px) {
  .week-grid { grid-template-columns: 1fr; overflow-x: visible; }
  .day-col { min-width: 0; width: 100%; }
  table { font-size: .85rem; }
  th, td { padding: 8px 6px; word-break: break-word; }
  .field-row { flex-direction: column; }
  .field-row > .field { min-width: 0; }
}

@media (max-width: 480px) {
  .modal { max-width: 100%; padding: 14px; }
  .modal-backdrop { padding: 0; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .timer-display { font-size: clamp(4rem, 18vh, 9rem); margin: 6px 0; }
  .timer-controls, .preset-row { gap: 6px; }
}

/* ---------- Konu listesi: tıklayınca aç/kapa ---------- */
.topic-list { display: none; }
.topic-list.open { display: block; }

/* ---------- Navbar mobil ---------- */
@media (max-width: 700px) {
  .topbar-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 10px;
    gap: 6px;
  }
  .brand {
    font-size: 0;
    margin-right: 0;
    flex-shrink: 0;
  }
  .brand-dot { width: 14px; height: 14px; }
  .nav-links {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    justify-content: flex-start;
  }
  .nav-links a { padding: 6px 8px; font-size: .82rem; }
  .topbar-actions { margin-left: auto; }
}

/* ---------- Genel taşma engeli ---------- */
html, body { overflow-x: hidden; max-width: 100%; }
*, *::before, *::after { max-width: 100%; }

/* Tablet ve mobilde yatay kaydırma çubuğu çıkmasın */
@media (max-width: 1024px) {
  body { overflow-x: hidden; }
  .week-grid { grid-template-columns: 1fr; overflow-x: visible; }
  .day-col { min-width: 0; width: 100%; }
}

/* ---------- Sayaç mobil ---------- */
@media (max-width: 700px) {
  .timer-display { font-size: clamp(2.4rem, 16vw, 5rem); margin: 10px 0; }
  .timer-controls { gap: 6px; }
  .timer-controls .btn { flex: 1 1 auto; min-width: 0; padding: 9px 6px; font-size: .82rem; }
  .preset-row .btn { font-size: .78rem; padding: 6px 8px; }
  .tabs { font-size: .85rem; }
  .tab { padding: 8px 10px; }
}

/* ---------- Form grid (profil/sayaç sayfalarında kullanılıyor) ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Free pool (serbest görev sürükleme) ---------- */
.free-pool { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.free-chip {
  border: 1px dashed var(--lc, var(--primary)); border-radius: 9px;
  padding: 6px 10px; font-size: .82rem; cursor: grab; background: var(--surface);
  display: flex; align-items: center; gap: 6px; user-select: none;
}
.free-chip.not-done { background: var(--danger-soft); border-color: var(--danger); }
.free-chip.dragging { opacity: .4; }
.free-chip.picked { outline: 2px solid var(--primary); }
[data-drop].drop-over, [data-drop].drop-target { background: var(--primary-soft); }

/* ---------- Mobil modal ---------- */
@media (max-width: 480px) {
  .modal { max-width: 100%; padding: 14px; }
  .modal-backdrop { padding: 0; }
}

/* ---------- Sayaç yatay mod ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  .timer-display { font-size: clamp(4rem, 18vh, 9rem); margin: 6px 0; }
  .timer-controls, .preset-row { gap: 6px; }
}