/* hidden özniteliği her zaman gizler (.btn { display:inline-flex } gibi kurallar ezmesin) */
[hidden] { display: none !important; }

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  /* okul teması (schools.theme) app.js applyTheme ile --primary'yi ezer */
  --primary: #ea580c;
  --primary-dark: #c2410c;
  --primary-soft: #fff7ed;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --blue: #2563eb;
  --blue-bg: #dbeafe;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- layout ---- */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: none;
  background: #1e1b4b;
  color: #e2e8f0;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: #fff; padding: 4px 8px 16px; }
.sidebar .brand .logo { width: 30px; height: 30px; flex: none; }
.sidebar .brand small { display: block; font-size: 12px; font-weight: 500; color: #a5b4fc; }
.sidebar .nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #818cf8; padding: 12px 12px 4px; }
.sidebar a.nav { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #c7d2fe; font-weight: 500; }
.sidebar a.nav:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.sidebar a.nav.active { background: var(--primary); color: #fff; }
.sidebar a.nav .count { margin-left: auto; background: var(--primary); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.sidebar a.nav.active .count { background: #fff; color: var(--primary); }
.sidebar .spacer { flex: 1; }
.sidebar .user-info { padding: 12px; font-size: 13px; color: #a5b4fc; border-top: 1px solid rgba(255, 255, 255, .1); }
.sidebar .user-info strong { color: #e0e7ff; display: block; }

.main { flex: 1; min-width: 0; padding: 24px 32px; max-width: 1180px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; }

/* mobil: kenar çubuğu üst şeride döner (veliler çoğunlukla telefondan girer) */
.menu-toggle { display: none; }
@media (max-width: 860px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; padding: 10px 14px; flex-direction: row; flex-wrap: wrap; align-items: center; position: sticky; top: 0; z-index: 40; }
  .sidebar .brand { padding: 4px; flex: 1; }
  .menu-toggle { display: inline-flex; background: none; border: 1px solid rgba(255, 255, 255, .25); color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 18px; cursor: pointer; }
  .sidebar .nav-wrap { display: none; width: 100%; flex-direction: column; gap: 2px; padding-top: 8px; }
  .sidebar.open .nav-wrap { display: flex; }
  .sidebar .spacer { display: none; }
  .main { padding: 18px 16px; }
}
@media (min-width: 861px) { .sidebar .nav-wrap { display: flex; flex-direction: column; gap: 4px; flex: 1; } }

/* ---- cards ---- */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); color: inherit; display: block; }
a.summary-card:hover { border-color: var(--primary); text-decoration: none; }
.summary-card .label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.summary-card .value { font-size: 24px; font-weight: 700; }
.summary-card.accent .value { color: var(--primary); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 24px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 18px; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); font-size: 14px; }

/* öğrenci kartı (veli ana sayfası) */
.child-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.child { display: flex; gap: 14px; align-items: flex-start; }
.child .avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; flex: none; }
.child dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; }
.child dt { color: var(--muted); }
.child h3 { font-size: 16px; margin-bottom: 4px; }

/* ---- table ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: top; }
table.data th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
table.data tr:hover td { background: #fafafa; }
table.data tr.inactive td { color: #94a3b8; }
td .muted, .muted { color: var(--muted); font-size: 12px; }
td.actions { white-space: nowrap; text-align: right; }

/* ---- badges ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: #475569; }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.bad { background: var(--red-bg); color: var(--red); }
.badge.info { background: var(--blue-bg); color: var(--blue); }
.badge.role-2048 { background: #ede9fe; color: #6d28d9; }
.badge.role-1024 { background: var(--blue-bg); color: var(--blue); }
.badge.role-512 { background: var(--green-bg); color: var(--green); }
.badge.role-256 { background: var(--primary-soft); color: var(--primary-dark); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: var(--red-bg); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn.block { width: 100%; justify-content: center; }

/* ---- forms ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--text); }
.field textarea { resize: vertical; min-height: 140px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* ---- alıcı seçici (chip + öneri listesi) ---- */
.picker { position: relative; border: 1px solid var(--border); border-radius: 8px; padding: 6px; display: flex; flex-wrap: wrap; gap: 6px; background: #fff; }
.picker:focus-within { outline: 2px solid var(--primary); outline-offset: -1px; }
.picker input { border: 0 !important; outline: none !important; flex: 1; min-width: 140px; padding: 4px 6px !important; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--primary-soft); color: var(--primary-dark); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 13px; font-weight: 600; }
.chip.class { background: var(--blue-bg); color: var(--blue); }
.chip button { border: 0; background: rgba(0, 0, 0, .08); color: inherit; border-radius: 50%; width: 18px; height: 18px; cursor: pointer; line-height: 1; }
.suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .14); z-index: 60; max-height: 260px; overflow: auto; }
.suggest button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.suggest button:hover, .suggest button.hl { background: var(--primary-soft); }
.suggest small { color: var(--muted); }

/* ---- mesajlar ---- */
.mail { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: start; }
.folders { display: flex; flex-direction: column; gap: 4px; }
.folders button { display: flex; align-items: center; gap: 8px; text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 8px;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }
.folders button:hover { background: #eef2ff; }
.folders button.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.folders .count { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--primary); }
.msg-list .row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.msg-list .row:hover { background: #fafafa; }
.msg-list .row.unread .who, .msg-list .row.unread .subj { font-weight: 700; }
.msg-list .row.unread { box-shadow: inset 3px 0 0 var(--primary); }
.msg-list .who { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-list .date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.msg-list .subj { font-size: 14px; grid-column: 1 / -1; }
.msg-list .prev { font-size: 13px; color: var(--muted); grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-view .meta { font-size: 13px; color: var(--muted); margin-bottom: 14px; display: grid; gap: 2px; }
.msg-view .body { white-space: pre-wrap; word-wrap: break-word; font-size: 15px; line-height: 1.6; }
.msg-view .atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.msg-view .att { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--text); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .mail { grid-template-columns: 1fr; }
  .folders { flex-direction: row; overflow-x: auto; }
  .folders button { white-space: nowrap; }
}

/* ---- modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); display: none; align-items: flex-start; justify-content: center;
  padding: 48px 16px; z-index: 50; overflow: auto; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px; box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2); }
.modal.modal-wide { max-width: 760px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 17px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.agreement-text { white-space: pre-wrap; max-height: 50vh; overflow: auto; font-size: 14px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.close-x { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.close-x:hover { color: var(--text); }

/* ---- toast ---- */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; z-index: 90; box-shadow: 0 10px 28px rgba(15, 23, 42, .3); opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }
#toast.error { background: var(--red); }

/* ---- auth pages ---- */
.auth-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 24px 16px; }
.auth-top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; padding: 12px 20px; background: rgba(255, 255, 255, .9);
  border-bottom: 1px solid var(--border); z-index: 10; }
.auth-top .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.auth-top .brand .logo { width: 26px; height: 26px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 400px; padding: 32px; }
.auth-logo { text-align: center; margin-bottom: 8px; }
.auth-logo .logo { width: 56px; height: 56px; }
.auth-title { text-align: center; font-size: 22px; font-weight: 700; margin: 10px 0 4px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.alert.error { background: var(--red-bg); color: var(--red); }
.alert.success { background: var(--green-bg); color: var(--green); }
.alert.warn { background: var(--amber-bg); color: var(--amber); }

/* ================= Dil seçici (i18n.js langSwitcher) ================= */
.lang-switch { position: relative; display: inline-flex; align-items: center; }
.lang-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 9px; padding: 6px 9px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: border-color .15s; }
.lang-btn:hover { border-color: var(--primary); }
.lang-switch:focus-within .lang-btn { outline: 2px solid var(--primary); outline-offset: 1px; }
.lang-caret { font-size: 10px; color: var(--muted); }
.lang-flag { width: 22px; height: 15px; border-radius: 3px; overflow: hidden; display: inline-flex; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .1); }
.lang-flag svg { width: 100%; height: 100%; display: block; }
.lang-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 160px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 28px rgba(15, 23, 42, .14); padding: 5px; z-index: 80; }
.lang-opt { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 9px; border: 0; background: none; font: inherit;
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; border-radius: 7px; text-align: left; }
.lang-opt:hover, .lang-opt.active { background: var(--primary-soft); color: var(--primary-dark); }
.auth-lang { margin-left: auto; }
/* uygulama kenar çubuğu (koyu zemin): menü yukarı açılır */
.shell-lang { margin-bottom: 8px; }
.shell-lang .lang-btn { width: 100%; background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .15); color: #e2e8f0; justify-content: flex-start; }
.shell-lang .lang-caret { margin-left: auto; color: #94a3b8; }
.shell-lang .lang-switch { display: flex; }
.shell-lang .lang-menu { top: auto; bottom: calc(100% + 6px); left: 0; right: auto; }
