/* ===========================================================================
   base.css — Ortak tasarım dili (token + reset + kontroller)
   Hem müşteri menüsü hem yönetim paneli bunu kullanır.
   Sayfaya özel renk/yerleşim menu.css ve panel.css içinde.
   ======================================================================== */

/* --- Tokenlar: açık tema (varsayılan) ------------------------------------ */
:root {
  color-scheme: light;

  --bg:            #f6f6f8;
  --bg-soft:       #eeeef2;
  --surface:       #ffffff;
  --surface-2:     #f9f9fb;
  --border:        #e5e5ea;
  --border-strong: #d2d2da;

  --text:          #17171c;
  --text-dim:      #5b5b68;
  --text-faint:    #8e8e9c;

  --accent:        #4f46e5;
  --accent-hover:  #4338ca;
  --accent-soft:   #eef2ff;
  --accent-ink:    #ffffff;

  --danger:        #dc2626;
  --danger-soft:   #fef2f2;
  --ok:            #16a34a;
  --ok-soft:       #f0fdf4;
  --warn:          #d97706;
  --warn-soft:     #fffbeb;

  --shadow-1: 0 1px 2px rgba(16, 16, 30, .05), 0 1px 3px rgba(16, 16, 30, .06);
  --shadow-2: 0 4px 12px rgba(16, 16, 30, .07), 0 12px 32px rgba(16, 16, 30, .08);
  --shadow-3: 0 8px 24px rgba(16, 16, 30, .12), 0 24px 64px rgba(16, 16, 30, .16);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-xl: 26px;

  --font: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* --- Tokenlar: koyu tema ------------------------------------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #0e0e12;
  --bg-soft:       #15151b;
  --surface:       #1a1a21;
  --surface-2:     #22222b;
  --border:        #2c2c37;
  --border-strong: #3d3d4a;

  --text:          #f2f2f5;
  --text-dim:      #a8a8b8;
  --text-faint:    #74748a;

  --accent:        #7c78f0;
  --accent-hover:  #918dff;
  --accent-soft:   #211f3d;
  --accent-ink:    #0e0e12;

  --danger:        #f87171;
  --danger-soft:   #2c1618;
  --ok:            #4ade80;
  --ok-soft:       #12261a;
  --warn:          #fbbf24;
  --warn-soft:     #2a2010;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, .45), 0 12px 32px rgba(0, 0, 0, .35);
  --shadow-3: 0 8px 24px rgba(0, 0, 0, .55), 0 24px 64px rgba(0, 0, 0, .45);
}

/* --- Reset -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .2s ease, color .2s ease;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -.015em; }
p  { margin: 0; }
img { max-width: 100%; display: block; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* --- Butonlar ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px; font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s, opacity .15s;
}
.btn:hover  { background: var(--surface-2); border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm  { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }
.btn-block { width: 100%; }

/* --- Form kontrolleri --------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.field .hint  { font-size: 12px; color: var(--text-faint); }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }

/* --- Rozet / etiket ----------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge-ok     { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.badge-off    { background: var(--surface-2);   color: var(--text-faint); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* --- Kart --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

/* --- Bildirim (toast) --------------------------------------------------- */
#toasts {
  position: fixed; z-index: 9000;
  left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto;
  width: 100%;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  box-shadow: var(--shadow-3);
  font-size: 14px;
  animation: toast-in .22s cubic-bezier(.2, .9, .3, 1);
}
.toast.ok    { border-left-color: var(--ok); }
.toast.err   { border-left-color: var(--danger); }
.toast.warn  { border-left-color: var(--warn); }
.toast .t-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast.leaving { animation: toast-out .18s ease forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px)  scale(.97); } }

/* --- Modal -------------------------------------------------------------- */
.modal-back {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(10, 10, 18, .5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  animation: fade-in .15s ease;
}
.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 36px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  animation: modal-in .2s cubic-bezier(.2, .9, .3, 1);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px; border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
@keyframes fade-in  { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }

/* --- Yükleniyor / boş durum --------------------------------------------- */
.spinner {
  width: 18px; height: 18px; flex: none;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: 44px 20px; text-align: center; color: var(--text-faint);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty .e-icon  { font-size: 30px; opacity: .7; }
.empty .e-title { font-weight: 600; color: var(--text-dim); }

.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--bg-soft) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* --- Kurulum uyarı bloğu (RLS/veri yoksa) ------------------------------- */
.setup-note {
  max-width: 620px; margin: 40px auto; padding: 22px 24px;
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  border-radius: var(--radius-lg);
  color: var(--text);
}
.setup-note h3 { margin-bottom: 10px; color: var(--warn); }
.setup-note ol { margin: 10px 0 0; padding-left: 20px; }
.setup-note li { margin-bottom: 6px; }
.setup-note code {
  background: var(--surface); padding: 1px 6px; border-radius: 5px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .9em;
}

/* --- Yardımcılar -------------------------------------------------------- */
.row     { display: flex; align-items: center; gap: 10px; }
.grow    { flex: 1; min-width: 0; }
.muted   { color: var(--text-dim); }
.faint   { color: var(--text-faint); }
.nowrap  { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden  { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
