/* ==========================================================================
   Piksir v2 — Panel bileşenleri ("Kareli Defter" yönetim ekranları)
   Okul paneli (okul/), ileride öğretmen paneli ve veli raporu için ortak parçalar.
   Yükleme: v2 CSS'lerinden (fonts, tokens, base, components) SONRA.
   Katman: v2.components (base.css'teki katman sırasına katılır; sayfa stilleri her zaman üstündedir).
   Mobil öncelikli: 360px'den başlar; tablolar 720px altında kart listesine dönüşür.
   ========================================================================== */
@layer v2.components {

  /* ---------------------------------------------------------------- Panel kabuğu */
  .v2-panel { min-height: 100vh; display: flex; flex-direction: column; }
  .v2-panel__main { flex: 1; padding-block: var(--v2-space-5) var(--v2-space-8); }
  .v2-panel__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--v2-space-3); margin-bottom: var(--v2-space-5); }
  .v2-panel__head h2 { scroll-margin-top: 140px; }
  /* Bölüm değişince odak başlığa taşınır (ekran okuyucu için); başlık etkileşimli değil → halka yok */
  .v2-panel__head h2[tabindex="-1"]:focus, .v2-panel__head h2[tabindex="-1"]:focus-visible { outline: none; }
  .v2-panel__lede { color: var(--v2-ink-2); font-size: var(--v2-text-sm); max-width: 60ch; margin-top: 4px; }
  .v2-panel__foot { border-top: var(--v2-stroke-soft) dashed var(--v2-line); padding-block: var(--v2-space-4); color: var(--v2-ink-2); font-size: var(--v2-text-sm); text-align: center; }
  .v2-panel__foot a { color: var(--v2-ink-2); }

  /* Kimlik şeridi (üst bar sağı): rol etiketi + ad · okul */
  .v2-who { display: none; flex-direction: column; align-items: flex-end; line-height: 1.2; min-width: 0; }
  .v2-who b { font-size: var(--v2-text-sm); max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .v2-who span { font-size: var(--v2-text-xs); color: var(--v2-ink-2); max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  @media (min-width: 720px) { .v2-who { display: flex; } }

  /* ---------------------------------------------------------------- Bölüm gezinmesi (yapışkan sekme şeridi) */
  .v2-sectnav { position: sticky; top: 0; z-index: var(--v2-z-sticky); background: var(--v2-paper); border-bottom: var(--v2-stroke-soft) solid var(--v2-line); }
  .v2-sectnav__in { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-block: 8px; }
  .v2-sectnav__in::-webkit-scrollbar { display: none; }
  .v2-sectnav a {
    flex: none; display: inline-flex; align-items: center; gap: 8px;
    min-height: var(--v2-tap-min); padding: 0 14px; border-radius: 12px;
    color: var(--v2-ink); text-decoration: none; font-weight: var(--v2-weight-heavy); font-size: var(--v2-text-sm); white-space: nowrap;
    border: var(--v2-stroke-soft) solid transparent;
  }
  .v2-sectnav a:hover { background: var(--v2-sunken); text-decoration: none; }
  .v2-sectnav a[aria-current="page"] { background: var(--v2-ink); color: var(--v2-on-ink); }
  .v2-sectnav a .v2-icon { width: 22px; height: 22px; }
  .v2-sectnav a[aria-current="page"] .v2-icon { --v2-icon-fill: var(--v2-yellow); }
  .v2-count {
    display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px;
    border-radius: var(--v2-radius-pill); background: var(--v2-tomato); color: #1F1D3D;
    border: 1.5px solid var(--v2-ink); font-family: var(--v2-font-mono); font-size: var(--v2-text-xs); font-weight: 700; line-height: 1;
  }
  .v2-count--calm { background: var(--v2-sunken); }

  /* ---------------------------------------------------------------- Izgara yardımcıları */
  .v2-grid { display: grid; gap: var(--v2-space-4); }
  .v2-grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
  .v2-grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
  .v2-stack { display: grid; gap: var(--v2-space-4); }
  .v2-stack--lg { gap: var(--v2-space-6); }
  /* F4.5 (1.4.10): ızgara öğesi içeriğin min-content genişliğine kilitlenmesin (kayan sekme/çip satırı 320px'i aşmasın) */
  .v2-stack > *, .v2-grid > * { min-width: 0; }
  .v2-row { display: flex; flex-wrap: wrap; gap: var(--v2-space-2); align-items: center; }
  .v2-row--end { justify-content: flex-end; }
  .v2-row--between { justify-content: space-between; }
  .v2-card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--v2-space-3); margin-bottom: var(--v2-space-4); }
  .v2-card__head h3 { display: flex; align-items: center; gap: 10px; }
  .v2-card--pad-sm { padding: var(--v2-space-4); }

  /* ---------------------------------------------------------------- Sayı kutucukları (stat) */
  .v2-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(46%, 150px), 1fr)); gap: var(--v2-space-3); }
  .v2-stat {
    display: grid; gap: 2px; padding: 14px 16px;
    background: var(--v2-surface); border: var(--v2-stroke-soft) solid var(--v2-ink); border-radius: var(--v2-radius);
  }
  .v2-stat b { font-family: var(--v2-font-mono); font-weight: 700; font-size: 1.875rem; line-height: 1.1; letter-spacing: -0.02em; }
  .v2-stat span { font-size: var(--v2-text-sm); color: var(--v2-ink-2); font-weight: var(--v2-weight-strong); }
  .v2-stat--tone { background: var(--_t, var(--v2-yellow-tint)); }

  /* ---------------------------------------------------------------- Yatay çubuk (sınıf başarısı, konu kapsamı) */
  .v2-meter { display: grid; gap: 6px; }
  .v2-meter__top { display: flex; justify-content: space-between; gap: 12px; font-size: var(--v2-text-sm); font-weight: var(--v2-weight-strong); }
  .v2-meter__top small { color: var(--v2-ink-2); font-weight: 400; }
  .v2-meter__top span:last-child { font-family: var(--v2-font-mono); }
  .v2-meter__track { height: 14px; border: var(--v2-stroke-soft) solid var(--v2-ink); border-radius: var(--v2-radius-pill); background: var(--v2-surface); overflow: hidden; }
  .v2-meter__fill { height: 100%; width: calc(var(--value, 0) * 1%); background: var(--_c, var(--v2-green)); transition: width var(--v2-dur-slow) var(--v2-ease); }
  .v2-meter--low { --_c: var(--v2-tomato); }
  .v2-meter--mid { --_c: var(--v2-yellow); }

  /* ---------------------------------------------------------------- Tablo (720px altında kart listesi) */
  .v2-table-wrap { width: 100%; }
  .v2-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--v2-text-sm); }
  .v2-table caption { text-align: left; font-weight: var(--v2-weight-heavy); padding-bottom: 8px; }
  .v2-table th {
    text-align: left; font-size: var(--v2-text-xs); font-weight: var(--v2-weight-heavy); letter-spacing: .04em; text-transform: uppercase;
    color: var(--v2-ink-2); padding: 8px 10px; border-bottom: var(--v2-stroke-soft) solid var(--v2-ink);
  }
  .v2-table td { padding: 10px; border-bottom: 1.5px dashed var(--v2-line); vertical-align: middle; }
  .v2-table tbody tr:last-child td { border-bottom: 0; }
  .v2-table td.num, .v2-table th.num { text-align: right; font-family: var(--v2-font-mono); white-space: nowrap; }
  .v2-table .v2-actions { justify-content: flex-end; }
  .v2-table__name { font-weight: var(--v2-weight-heavy); }
  .v2-rowbtn {
    display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 4px 8px; margin: -6px -8px;
    border: 0; background: transparent; color: var(--v2-ink); font-weight: var(--v2-weight-heavy); text-align: left; border-radius: 10px;
    text-decoration: underline; text-decoration-color: var(--v2-line); text-decoration-thickness: 2px; text-underline-offset: .2em;
  }
  .v2-rowbtn:hover { background: var(--v2-sunken); text-decoration-color: var(--v2-ink); }
  @media (max-width: 719.98px) {
    .v2-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .v2-table--stack, .v2-table--stack tbody, .v2-table--stack tr, .v2-table--stack td { display: block; width: 100%; }
    .v2-table--stack tr { padding: 10px 0; border-bottom: 1.5px dashed var(--v2-line); }
    .v2-table--stack tbody tr:last-child { border-bottom: 0; }
    .v2-table--stack td { border: 0; padding: 4px 0; display: flex; gap: 12px; justify-content: space-between; align-items: center; text-align: right; }
    .v2-table--stack td::before { content: attr(data-label); font-family: var(--v2-font-body); color: var(--v2-ink-2); font-size: var(--v2-text-xs); font-weight: var(--v2-weight-heavy); text-transform: uppercase; letter-spacing: .04em; text-align: left; flex: none; }
    .v2-table--stack td[data-label=""]::before, .v2-table--stack td:not([data-label])::before { content: none; }
    .v2-table--stack td.v2-table__primary { text-align: left; justify-content: flex-start; font-size: var(--v2-text-md); }
    .v2-table--stack td.v2-table__primary::before { content: none; }
    .v2-table--stack td.num { font-family: var(--v2-font-mono); }
    .v2-table--stack .v2-actions { justify-content: flex-start; padding-top: 6px; }
  }

  /* ---------------------------------------------------------------- Eylem satırı */
  .v2-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .v2-btn--danger { --_fg: var(--v2-tomato-ink); }
  .v2-btn--danger:hover { --_bg: var(--v2-tomato-tint); }
  .v2-btn .v2-count { margin-left: 2px; }

  /* ---------------------------------------------------------------- Durum etiketi */
  .v2-status { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 10px; border-radius: var(--v2-radius-pill); border: var(--v2-stroke-soft) solid var(--v2-ink); font-size: var(--v2-text-xs); font-weight: var(--v2-weight-heavy); white-space: nowrap; background: var(--v2-surface); }
  .v2-status .v2-icon { width: 16px; height: 16px; }
  .v2-status--ok { background: var(--v2-green-tint); color: var(--v2-green-ink); }
  .v2-status--wait { background: var(--v2-sunken); color: var(--v2-ink-2); }
  .v2-status--late, .v2-status--open { background: var(--v2-tomato-tint); color: var(--v2-tomato-ink); }
  .v2-status--review { background: var(--v2-yellow-tint); color: var(--v2-yellow-ink); }
  .v2-status--info { background: var(--v2-blue-tint); color: var(--v2-blue-ink); }

  /* ---------------------------------------------------------------- Boş durum */
  .v2-empty { display: grid; justify-items: start; gap: 10px; padding: var(--v2-space-4); border: var(--v2-stroke-soft) dashed var(--v2-line); border-radius: var(--v2-radius); color: var(--v2-ink-2); }
  .v2-empty b { color: var(--v2-ink); }

  /* ---------------------------------------------------------------- Diyalog (yerel <dialog>; mobilde tam ekran sayfa) */
  .v2-dialog {
    width: min(560px, calc(100vw - 24px)); max-height: min(88vh, 900px);
    padding: 0; border: var(--v2-stroke) solid var(--v2-ink); border-radius: var(--v2-radius-lg);
    background: var(--v2-surface); color: var(--v2-ink);
    box-shadow: 0 calc(var(--v2-offset) + 2px) 0 var(--v2-shadow-color);
  }
  .v2-dialog--wide { width: min(820px, calc(100vw - 24px)); }
  .v2-dialog::backdrop { background: rgba(31, 29, 61, .55); }
  .v2-dialog[open] { display: flex; flex-direction: column; }
  .v2-dialog__head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px 22px; border-bottom: var(--v2-stroke-soft) solid var(--v2-line); }
  .v2-dialog__head h2 { font-size: var(--v2-text-xl); flex: 1; min-width: 0; }
  .v2-dialog__body { padding: 18px 22px; overflow: auto; display: grid; gap: var(--v2-space-4); align-content: start; }
  .v2-dialog__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; border-top: var(--v2-stroke-soft) solid var(--v2-line); background: var(--v2-paper); }
  @media (max-width: 599.98px) {
    .v2-dialog, .v2-dialog--wide { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border-width: 0; box-shadow: none; }
    .v2-dialog__foot { position: sticky; bottom: 0; }
    .v2-dialog__foot .v2-btn { flex: 1 1 auto; }
  }

  /* ---------------------------------------------------------------- Form ekleri */
  .v2-select { appearance: none; -webkit-appearance: none; padding-right: 44px;
    background-image: linear-gradient(45deg, transparent 50%, var(--v2-ink) 50%), linear-gradient(135deg, var(--v2-ink) 50%, transparent 50%);
    background-position: calc(100% - 22px) 50%, calc(100% - 15px) 50%; background-size: 7px 7px; background-repeat: no-repeat; }
  .v2-textarea { min-height: 140px; padding: 12px 16px; line-height: 1.5; resize: vertical; }
  .v2-check { display: flex; align-items: flex-start; gap: 12px; min-height: var(--v2-tap-min); padding: 8px 0; font-weight: var(--v2-weight-strong); cursor: pointer; }
  .v2-check input { width: 26px; height: 26px; margin: 0; flex: none; accent-color: var(--v2-ink); }
  .v2-form { display: grid; gap: var(--v2-space-4); }
  .v2-field__error:empty { display: none; }
  .v2-fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: var(--v2-space-3); }
  .v2-fieldset legend { font-weight: var(--v2-weight-heavy); font-size: var(--v2-text-sm); margin-bottom: 4px; padding: 0; }

  /* ---------------------------------------------------------------- Bildirim (toast) */
  .v2-toast {
    position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: var(--v2-z-overlay);
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 14px;
    background: var(--v2-ink); color: var(--v2-on-ink); font-weight: var(--v2-weight-strong); font-size: var(--v2-text-sm);
    border: var(--v2-stroke-soft) solid var(--v2-ink);
    transition: opacity var(--v2-dur) var(--v2-ease), transform var(--v2-dur) var(--v2-ease);
  }
  .v2-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
  .v2-toast.is-err { background: var(--v2-tomato-tint); color: var(--v2-tomato-ink); border-color: var(--v2-tomato-ink); }

  /* ---------------------------------------------------------------- Zaman çizelgesi (not / durum geçmişi) */
  .v2-timeline { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
  .v2-timeline li { display: grid; gap: 2px; padding: 8px 12px; border-left: 3px solid var(--v2-line); background: var(--v2-paper); border-radius: 0 10px 10px 0; font-size: var(--v2-text-sm); }
  .v2-timeline li small { color: var(--v2-ink-2); font-family: var(--v2-font-mono); font-size: var(--v2-text-xs); }
  .v2-timeline li.is-state { border-left-color: var(--v2-ink-3); color: var(--v2-ink-2); }

  /* ---------------------------------------------------------------- Yükleniyor */
  .v2-loading { display: flex; align-items: center; gap: 10px; color: var(--v2-ink-2); padding: var(--v2-space-5) 0; }
  .v2-loading::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--v2-line); border-top-color: var(--v2-ink); animation: v2-spin .8s linear infinite; }
  @keyframes v2-spin { to { transform: rotate(360deg); } }
}
