/* ==========================================================================
   Sosyal Önizleme — ortak stil
   Ortak değişkenler (önizleme modülü de kullanır):
   --bg --surface --text --muted --border --accent --accent-hover --danger --ok --radius
   Kurallar: lacivert/mavimsi koyu ton yok (R ≥ B), kırmızı yalnızca vurgu,
   glow / gradyan / gökkuşağı ikon yok.
   ========================================================================== */
:root {
  --bg: #f6f4f2;
  --surface: #ffffff;
  --surface-2: #faf8f6;
  --text: #23201f;
  --muted: #6f6864;
  --border: #e4dfdb;
  --border-strong: #cfc8c3;
  --accent: #d8291c;
  --accent-hover: #b11f14;
  --accent-soft: #fbeceb;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --danger-soft: #fbecea;
  --ok: #2f7a4a;
  --ok-soft: #e9f4ed;
  --warn: #a5650a;
  --warn-soft: #fbf2e3;
  /* durum tonları: sorun = turuncu, dikkat = sarı (kırmızı yalnızca marka vurgusu) */
  --issue: #a8500c;
  --issue-soft: #fdf1e4;
  --issue-line: #e07b16;
  --caution: #806300;
  --caution-soft: #fbf6e0;
  --caution-line: #d9a514;
  --ok-line: #3d9a62;
  --stage-bg: #efebe7;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(35, 32, 31, 0.05), 0 1px 4px rgba(35, 32, 31, 0.04);
  --shadow-sm: 0 1px 2px rgba(35, 32, 31, 0.05), 0 1px 4px rgba(35, 32, 31, 0.04);
  --shadow-md: 0 2px 6px rgba(35, 32, 31, 0.06), 0 10px 28px rgba(35, 32, 31, 0.08);
  --ease: 160ms ease;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --sidebar-w: 232px;
  --topbar-h: 56px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #181514;
  --surface: #23201f;
  --surface-2: #2a2624;
  --text: #ece7e3;
  --muted: #a69e98;
  --border: #38322f;
  --border-strong: #4a4340;
  --accent: #e0574c;
  --accent-hover: #ea7067;
  --accent-soft: #3a2421;
  --on-accent: #1c1918;
  --danger: #e0675d;
  --danger-soft: #3a2421;
  --ok: #6cbf87;
  --ok-soft: #22302a;
  --warn: #d9a24d;
  --warn-soft: #362c1f;
  --issue: #f0a15a;
  --issue-soft: #3a2a1d;
  --issue-line: #e58a35;
  --caution: #e2c463;
  --caution-soft: #33301c;
  --caution-line: #d3ad2e;
  --ok-line: #57a874;
  --stage-bg: #1d1a19;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.3), 0 12px 28px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; font-weight: 600; }
h1 { font-size: 22px; letter-spacing: -.005em; }
h2 { font-size: 16.5px; }
h3 { font-size: 14px; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }

/* ---------- Form öğeleri ---------- */
label { display: block; font-weight: 500; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="password"], input[type="search"], input[type="date"], input[type="email"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  min-height: 38px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -3px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; cursor: pointer; user-select: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500;
  min-height: 38px; padding: 7px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-danger { color: var(--muted); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 30px; padding: 4px 11px; font-size: 13px; }
.btn-icon { padding: 6px; min-width: 36px; }
.btn svg, .icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Giriş sayfası ---------- */
.login-page { display: grid; place-items: center; min-height: 100%; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-md); padding: 36px 32px 26px;
}
.login-card .logo { display: block; height: 26px; margin: 0 auto 6px; }
.login-card .app-name { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 13px; letter-spacing: .02em; }
.login-card .btn-primary { width: 100%; min-height: 40px; margin-top: 6px; }
.login-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; font-size: 12px; color: var(--muted); }

.alert { border-radius: var(--radius-sm); padding: 9px 12px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-info { background: var(--surface-2); color: var(--text); border-color: var(--border); }

/* ---------- Kabuk ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; min-height: 100%; }
.sidebar {
  grid-row: 1 / span 2;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.sidebar .brand img { height: 18px; }
.sidebar .brand span { font-size: 12px; color: var(--muted); border-left: 1px solid var(--border); padding-left: 10px; }
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav .nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 500;
  position: relative;
  transition: background-color var(--ease), color var(--ease);
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a .icon { color: var(--muted); }
.nav a.active .icon { color: var(--accent); }
.sidebar .side-foot { padding: 12px 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

.topbar {
  grid-column: 2; position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .page-title { font-weight: 600; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .menu-toggle { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.user-chip .who { line-height: 1.2; }
.user-chip .who b { display: block; font-weight: 600; font-size: 13px; }
.user-chip .who small { color: var(--muted); font-size: 12px; }

.main { grid-column: 2; padding: 28px 32px 40px; min-width: 0; }
.main > .page { max-width: 1440px; margin: 0 auto; }
.main.flush > .page { max-width: none; }
.main.flush { padding: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-head h1 { margin: 0; flex: 1; }
.page-head .desc { flex-basis: 100%; color: var(--muted); margin: -4px 0 0; font-size: 14px; }

.backdrop { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(280px, 84vw);
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: none;
  }
  .shell.drawer-open .sidebar { transform: none; }
  .shell.drawer-open .backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(24, 21, 20, .45); }
  .topbar, .main { grid-column: 1; }
  .topbar { padding: 0 12px; }
  .topbar .menu-toggle { display: inline-flex; }
  .user-chip .who { display: none; }
  .main { padding: 18px 14px 32px; }
  .main.flush { padding: 0; }
  h1 { font-size: 20px; }
}

/* ---------- Kartlar, tablolar ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; flex: 1; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar input[type="search"] { max-width: 360px; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 14px; align-items: end; margin-bottom: 16px; }
.filters .field { margin: 0; }
.filters label { font-size: 12px; color: var(--muted); font-weight: 500; }
.filters .actions { display: flex; gap: 8px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-weight: 600; font-size: 12px; letter-spacing: .02em; color: var(--muted); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table td.detail { max-width: 380px; font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-word; }
.table .linkish { color: var(--text); font-weight: 500; cursor: pointer; background: none; border: 0; padding: 0; font: inherit; text-align: left; }
.table .linkish:hover { color: var(--accent); text-decoration: underline; }
.table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table td a:not(.btn) { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
.table td a:not(.btn):hover { color: var(--accent); text-decoration-color: currentColor; }
.table select { min-height: 30px; padding: 3px 8px; width: auto; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 13px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
/* Günlük: işlem türü rozetleri */
.badge.act::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; flex: none; }
.act-auth { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.act-auth::before { background: var(--muted) !important; }
.act-fail { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.act-upload { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.act-view { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.act-preview { background: #f3ebe2; color: #7a5231; border-color: transparent; }
:root[data-theme="dark"] .act-preview { background: #33291f; color: #d7b48f; }
.act-warn { background: var(--issue-soft); color: var(--issue); border-color: transparent; }
.act-delete { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.act-user { background: #efede3; color: #5f5a2e; border-color: transparent; }
:root[data-theme="dark"] .act-user { background: #2f2d22; color: #cfc893; }
.act-legend { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 0 0 14px; font-size: 12.5px; color: var(--muted); }
.act-legend .badge { font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; transition: box-shadow var(--ease); }
.act-legend .badge:hover { box-shadow: 0 0 0 1px var(--border-strong); }

/* ---------- Medya kitaplığı ---------- */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface); padding: 28px 22px; text-align: center; color: var(--muted);
  margin-bottom: 18px; transition: border-color var(--ease), background-color var(--ease);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dropzone b { color: var(--text); }
.dropzone .btn { margin-top: 10px; }
.uploads { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.upload-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow-sm); }
.upload-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .status { color: var(--muted); font-size: 12px; }
.upload-item.error .status { color: var(--danger); }
.upload-item.done .status { color: var(--ok); }
.progress { grid-column: 1 / -1; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.upload-item.done .progress > i { background: var(--ok); }
.upload-item.error .progress > i { background: var(--danger); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.media-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.media-card:hover, .media-card:focus-visible { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.media-card .thumb { position: relative; aspect-ratio: 1 / 1; background: var(--surface-2); overflow: hidden; }
.media-card .thumb img, .media-card .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-card .thumb .tag {
  position: absolute; left: 8px; bottom: 8px; background: rgba(28, 25, 24, .78); color: #f4efeb;
  font-size: 11.5px; padding: 1px 7px; border-radius: 4px; display: inline-flex; gap: 4px; align-items: center;
}
.media-card .thumb .tag .icon { width: 12px; height: 12px; }
.media-card .meta { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.media-card .meta .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-card .meta .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-card .actions { display: flex; justify-content: space-between; align-items: center; padding: 0 8px 8px 12px; font-size: 12px; color: var(--muted); }
.load-more { display: flex; justify-content: center; margin-top: 18px; }

/* ---------- Profil ---------- */
.grid-2 { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13.5px; margin-bottom: 4px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 140px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity li:last-child { border-bottom: 0; }
.activity time { color: var(--muted); }

/* ---------- Diyalog, bildirim ---------- */
dialog.modal {
  border: 1px solid var(--border); border-radius: 16px; padding: 0;
  background: var(--surface); color: var(--text);
  width: min(460px, calc(100vw - 24px)); box-shadow: 0 10px 40px rgba(0,0,0,.18);
}
dialog.modal::backdrop { background: rgba(24, 21, 20, .45); }
.modal-head { padding: 16px 20px 0; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 14px 20px; }
.modal-foot { padding: 12px 20px 16px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }
.secret {
  display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; font-family: var(--mono); font-size: 15px; word-break: break-all;
}
.secret span { flex: 1; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--text); color: var(--bg); border-radius: var(--radius); padding: 11px 15px;
  font-size: 13.5px; box-shadow: var(--shadow-md); border-left: 4px solid var(--ok);
}
.toast.error { border-left-color: var(--accent); }

.loading { padding: 48px 16px; text-align: center; color: var(--muted); }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -4px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } * { transition: none !important; } }

.preview-host { min-height: calc(100vh - var(--topbar-h)); }
.notice { max-width: 560px; margin: 48px auto; text-align: center; }
.notice h2 { margin-bottom: 8px; }

/* Yardımcı: koyu temada form alanı zemini biraz ayrışsın */
:root[data-theme="dark"] input[type="text"], :root[data-theme="dark"] input[type="password"], :root[data-theme="dark"] input[type="search"],
:root[data-theme="dark"] input[type="date"], :root[data-theme="dark"] input[type="email"], :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background: #1f1c1b; }
.preview-host { min-height: calc(100vh - var(--topbar-h)); }
