/* public/app/app.css
   Tema: açık/koyu (data-theme). Düzen: masaüstünde kenar çubuğu, mobilde başlık menüsü + alt menü. */

:root {
  --brand-blue: #2d8cff;
  --brand-purple: #a52ef5;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #e11d48;

  --bg: #eef4ff;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #dbeafe 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 10%, #f3e8ff 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f5f8ff;
  --line: #d7e1f5;
  --txt: #0f172a;
  --mut: #5b6679;
  --focus: #2563eb;
  --shadow: 0 10px 30px -12px rgba(37, 99, 235, 0.35);
  --radius: 18px;
  --card-front: linear-gradient(160deg, #ffffff 0%, #eaf2ff 100%);
  --card-back: linear-gradient(160deg, #faf5ff 0%, #eef2ff 100%);
  --chip: #e8efff;
  --chip-txt: #1d4ed8;
}

[data-theme="dark"] {
  --bg: #0a0f1f;
  --bg-grad: radial-gradient(1000px 500px at 0% -10%, #1e2a5a 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 0%, #3b1a63 0%, transparent 55%);
  --surface: #121a31;
  --surface-2: #18223d;
  --line: #2a3760;
  --txt: #e7edff;
  --mut: #9aa8cc;
  --focus: #7dd3fc;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
  --card-front: linear-gradient(160deg, #1a2550 0%, #121a31 100%);
  --card-back: linear-gradient(160deg, #2a1648 0%, #121a31 100%);
  --chip: #1d2b55;
  --chip-txt: #bfdbfe;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }
body {
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--txt);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--focus); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.muted { color: var(--mut); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 99; }
.skip:focus { left: 8px; top: 8px; }

/* ---------- Görünürlük yardımcıları ---------- */
.only-mobile { display: none; }
@media (max-width: 899px) {
  .only-mobile { display: flex; }
  .only-desktop { display: none !important; }
}

/* ---------- Başlık ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px clamp(12px, 3vw, 24px);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; align-items: flex-start; text-decoration: none; color: var(--txt); min-width: 0; }
.brand img { width: 118px; height: auto; }
.beta {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-top: -4px;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.seg {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px;
}
.seg button {
  border: 0; background: transparent; color: var(--mut); cursor: pointer;
  padding: 8px 14px; min-height: 40px; border-radius: 999px; font-weight: 700; font-size: 13.5px;
}
.seg button[aria-pressed="true"] {
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-purple)); color: #fff;
}

.icon-btn {
  min-width: 44px; min-height: 44px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--txt); font-size: 18px;
}

/* ---------- Kabuk: kenar çubuğu + içerik ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 150px); }
.sidebar {
  position: sticky; top: 64px; align-self: start; height: calc(100vh - 64px);
  padding: 18px 14px; border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  display: flex; flex-direction: column; gap: 16px;
}
.side-nav { display: flex; flex-direction: column; gap: 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 12px;
  border-radius: 12px; text-decoration: none; color: var(--txt); font-weight: 600;
  border: 1px solid transparent;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link[aria-current="page"] {
  background: linear-gradient(90deg, color-mix(in srgb, var(--brand-blue) 22%, transparent), color-mix(in srgb, var(--brand-purple) 22%, transparent));
  border-color: var(--line);
}
.nav-ico { width: 24px; text-align: center; font-size: 18px; }
.side-foot { margin-top: auto; }

.main { padding: clamp(14px, 2.5vw, 28px); min-width: 0; outline: none; padding-bottom: 40px; }
.scrim { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 35; }

.sidebar.drawer-open { display: flex; }
@media (max-width: 899px) {
  .shell { grid-template-columns: minmax(0, 1fr); min-height: calc(100vh - 170px); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; width: min(280px, 82vw);
    z-index: 40; transform: translateX(-105%); transition: transform .25s ease;
    padding-top: 22px; box-shadow: var(--shadow);
  }
  .sidebar.drawer-open { transform: translateX(0); }
  .main { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
}

/* ---------- Alt menü (mobil) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  justify-content: space-around; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 52px; border-radius: 12px; text-decoration: none; color: var(--mut); font-size: 12px; font-weight: 700;
}
.bottom-nav a[aria-current="page"] { color: var(--txt); background: var(--surface-2); }
.bottom-nav .b-ico { font-size: 20px; line-height: 1.1; }

/* ---------- Alt bilgi ---------- */
.footer { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 90%, transparent); }
.footer-inner { padding: 16px clamp(12px, 3vw, 24px) 20px; display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; }
.credits { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px; font-size: 14px; }
.credits a { font-weight: 600; text-decoration: none; word-break: break-all; }
.credits a:hover { text-decoration: underline; }
.dot { color: var(--mut); }
@media (max-width: 899px) { .footer { margin-bottom: 70px; } }

/* ---------- Genel bileşenler ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: clamp(20px, 3.4vw, 28px); letter-spacing: -.01em; }
.page-head p { margin: 2px 0 0; }
.page-head .grow { flex: 1; min-width: 0; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(12px, 2vw, 18px); box-shadow: var(--shadow); min-width: 0;
}

.btn {
  min-height: 44px; padding: 10px 16px; border-radius: 12px; cursor: pointer; font-weight: 700;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--txt);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn:hover:not(:disabled) { filter: brightness(1.04); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { border: 0; color: #fff; background: linear-gradient(90deg, var(--brand-blue), var(--brand-purple)); }
.btn.ok { border: 0; color: #fff; background: var(--ok); }
.btn.warn { border: 0; color: #111827; background: var(--warn); }
.btn.danger { border: 0; color: #fff; background: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  background: var(--chip); color: var(--chip-txt); font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.chip.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.chip.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: #b45309; }
[data-theme="dark"] .chip.warn { color: #fcd34d; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--mut); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--txt);
}
.textarea { min-height: 84px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 3px solid var(--focus); outline-offset: 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--brand-purple); }

.toasts { position: fixed; right: 12px; bottom: 84px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 24px)); }
@media (min-width: 900px) { .toasts { bottom: 20px; } }
.toast {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand-blue);
  border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 14px;
  animation: toast-in .2s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.loading { padding: 40px; text-align: center; color: var(--mut); }
.empty { padding: 28px; text-align: center; color: var(--mut); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Kart: çevrilebilir, sürüklenebilir ---------- */
.card-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
}
.flip-card {
  position: relative; perspective: 1200px; min-width: 0; user-select: none;
  min-height: 200px; cursor: pointer; border-radius: var(--radius);
  touch-action: manipulation;
}
.flip-inner {
  position: relative; width: 100%; height: 100%; min-height: inherit;
  transition: transform .6s cubic-bezier(.2,.8,.2,1); transform-style: preserve-3d;
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; border-radius: var(--radius); padding: 14px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.face.front { background: var(--card-front); }
.face.back { transform: rotateY(180deg); background: var(--card-back); overflow-y: auto; }
.flip-card.dragging { z-index: 10; pointer-events: none; opacity: .92; transform: scale(1.03); transition: transform .15s; }
.flip-card.drop-target { outline: 2px dashed var(--brand-purple); outline-offset: 4px; }

.card-top { display: flex; align-items: center; gap: 8px; }
.grip {
  margin-left: auto; min-width: 44px; min-height: 44px; border-radius: 12px; border: 1px dashed var(--line);
  background: var(--surface-2); color: var(--mut); cursor: grab; touch-action: none; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.grip:active { cursor: grabbing; }
.card-title { margin: 0; font-size: 17px; line-height: 1.25; font-weight: 800; overflow-wrap: anywhere; }
.card-sub { color: var(--mut); font-size: 13.5px; overflow-wrap: anywhere; }
.card-body { font-size: 13.5px; color: var(--txt); overflow-wrap: anywhere; margin: 0; }
.card-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--mut); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.flip-hint { font-size: 12px; color: var(--mut); }

.joker-face { align-items: center; justify-content: center; text-align: center; }
.joker-ico { font-size: 34px; line-height: 1; }
.joker-name { font-weight: 900; letter-spacing: .02em; font-size: 14.5px; }
.joker-card.used .face.front { filter: grayscale(1) brightness(.85); }
.joker-card.used .face.front::after {
  content: "KULLANILDI"; position: absolute; inset: auto 0 14px 0; text-align: center;
  font-weight: 900; font-size: 12px; color: var(--danger); letter-spacing: .12em;
}
.joker-card:nth-child(odd) .face.front { border-top: 4px solid var(--brand-blue); }
.joker-card:nth-child(even) .face.front { border-top: 4px solid var(--brand-purple); }

.business-card.found .face.front { border-top: 4px solid var(--ok); }
.business-card.found .face.front::after {
  content: "BULUNDU ✓"; position: absolute; top: 14px; right: 14px; font-weight: 900; font-size: 12px;
  color: #fff; background: var(--ok); padding: 4px 10px; border-radius: 999px;
}

/* ---------- Sayaç ve oyun ekranı ---------- */
.hud { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .hud { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }
.challenge-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.timer {
  font-size: clamp(56px, 12vw, 110px); font-weight: 900; line-height: 1; text-align: center;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.timer.urgent { background: none; color: var(--danger); animation: blink .6s steps(2,start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--ok), var(--brand-blue)); width: 0; transition: width .2s linear; }
.query-box {
  font-size: clamp(18px, 3vw, 24px); font-weight: 800; padding: 14px; border-radius: 14px;
  background: var(--surface-2); border: 1px dashed var(--brand-purple); overflow-wrap: anywhere;
}
.section-title { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; font-size: 16px; font-weight: 800; }
.section-title .count { margin-left: auto; }

/* ---------- Kaydırıcı (slider) ---------- */
.slider { position: relative; max-width: 440px; margin: 0 auto; }
.slider-track {
  display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 6px 2px 14px; scrollbar-width: thin; overscroll-behavior-x: contain;
}
.slider-track > .flip-card {
  flex: 0 0 100%; scroll-snap-align: center; min-height: 280px;
}
.slider-controls { display: flex; align-items: center; gap: 10px; justify-content: center; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.dots button {
  width: 12px; height: 12px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--line); padding: 0; min-width: 12px; min-height: 12px;
}
.dots button[aria-current="true"] { background: var(--brand-purple); width: 26px; }

/* ---------- Yönetim ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .input { max-width: 320px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  min-height: 44px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); cursor: pointer; font-weight: 700;
}
.tab[aria-selected="true"] { background: linear-gradient(90deg, var(--brand-blue), var(--brand-purple)); color: #fff; border-color: transparent; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.grid-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.grid-table th, .grid-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
.grid-table th { background: var(--surface-2); color: var(--mut); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.grid-table td.actions { white-space: nowrap; }
@media (max-width: 720px) {
  table.grid-table { min-width: 0; }
  .grid-table thead { display: none; }
  .grid-table, .grid-table tbody, .grid-table tr, .grid-table td { display: block; width: 100%; }
  .grid-table tr { border-bottom: 1px solid var(--line); padding: 8px 6px; }
  .grid-table td { border: 0; padding: 4px 8px; }
  .grid-table td.actions { display: flex; gap: 8px; padding-top: 8px; }
  .grid-table td.actions .btn { flex: 1; }
}

.dialog {
  width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 0;
  border-radius: var(--radius); background: var(--surface); color: var(--txt); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(2, 6, 23, .6); }
.dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dialog-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-body { padding: 16px 18px; overflow-y: auto; display: grid; gap: 18px; }
.dialog-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.form-group h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.errors { background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid var(--danger); border-radius: 12px; padding: 10px 14px; }
.errors ul { margin: 6px 0 0 18px; padding: 0; }

.login { max-width: 420px; margin: 24px auto; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; background: var(--surface-2); }
.stat-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 22px; }
.stat small { color: var(--mut); }

/* ---------- Genel mobil düzen ---------- */
@media (max-width: 480px) {
  .brand img { width: 96px; }
  .beta { font-size: 10px; }
  .seg button { padding: 8px 10px; font-size: 12.5px; }
  .topbar-actions { gap: 6px; }
  .card-grid { grid-template-columns: minmax(0, 1fr); }
  .flip-card { min-height: 190px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
