/* =========================================================
   ColdStore Admin SaaS Theme (Base Design System)
   - tokens, layout, shared components (btn/input/table/toast/modal-root)
   ========================================================= */

:root {
  --bg: #0f172a;
  --bg-soft: #111827;
  --panel: #020617;
  --card: #020617cc;
  --border: #1f2933;
  --text: #e5e7eb;
  --muted: #9ca3af;

  --primary: #3b82f6;
  --primary-soft: #1d4ed8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;

  --radius: 14px;
  --shadow: 0 20px 40px rgba(0,0,0,.4);
  --blur: blur(12px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 20% -10%, #1e293b 0%, transparent 40%),
    radial-gradient(1000px 600px at 80% 0%, #020617 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* =========================================================
   Layout
   ========================================================= */
.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100%;
}

.sidebar {
  background: linear-gradient(180deg, #020617, #020617f0);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.main {
  padding: 24px;
  overflow-y: auto;
}

/* =========================================================
   Topbar
   ========================================================= */
.topbar {
  height: 64px;
  background: rgba(2,6,23,0.7);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.brand__title {
  font-size: 16px;
  font-weight: 600;
}

.brand__subtitle {
  font-size: 12px;
  color: var(--muted);
}

/* =========================================================
   Navigation
   ========================================================= */
.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.nav__item {
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--muted);
  transition: .2s;
}

.nav__item:hover {
  background: rgba(59,130,246,.12);
  color: var(--text);
}

.nav__item.active {
  background: linear-gradient(135deg, rgba(59,130,246,.35), rgba(29,78,216,.35));
  color: white;
}

/* =========================================================
   Cards / Grid
   ========================================================= */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
}

.card__title { font-weight: 600; font-size: 15px; }
.card__subtitle { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: .15s;
}

.btn:hover { background: rgba(255,255,255,0.07); }

.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
  border: none;
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  background: rgba(239,68,68,.28);
  border-color: rgba(239,68,68,.55);
}

.btn--sm {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12px;
}

/* =========================================================
   Badges
   ========================================================= */
.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.ok { background: rgba(34,197,94,.15); color: var(--success); }
.badge.warn { background: rgba(245,158,11,.15); color: var(--warning); }
.badge.err { background: rgba(239,68,68,.15); color: var(--danger); }

/* =========================================================
   Inputs / Utilities
   ========================================================= */
.input {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  outline: none;
}

.input:focus { border-color: rgba(59,130,246,.6); }

.checkbox { width: 18px; height: 18px; }
.muted { color: var(--muted); }

/* =========================================================
   Toast
   ========================================================= */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: rgba(2,6,23,.9);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  min-width: 220px;
}

.toast.ok { border-left: 4px solid var(--success); }
.toast.warn { border-left: 4px solid var(--warning); }
.toast.err { border-left: 4px solid var(--danger); }

/* =========================================================
   Table (shared)
   ========================================================= */
.table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table th, .table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(31,41,51,.7);
  vertical-align: top;
}

.table th {
  color: rgba(229,231,235,.9);
  font-weight: 600;
  background: rgba(255,255,255,0.03);
  text-align: left;
}

.table tr:hover td { background: rgba(255,255,255,0.02); }

/* =========================================================
   CRUD helpers
   ========================================================= */
.row { display:flex; align-items:center; }
.row.between { justify-content: space-between; }
.row.end { justify-content:flex-end; }
.grow { flex:1; }
.gap-8 { gap:8px; }
.gap-12 { gap:12px; }
.mb-12 { margin-bottom: 12px; }
.mt-12 { margin-top: 12px; }

.grid { display:grid; }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* =========================================================
   MODAL (new system: modal-root / modal-overlay / modal-box)
   ========================================================= */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(0,0,0,.60);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  pointer-events: auto;
}

.modal-box {
  width: min(720px, calc(100vw - 24px));
  max-height: min(82vh, calc(100vh - 24px));
  overflow: auto;

  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}

body.modal-open { overflow: hidden; }

.modal-box.modal-box--plain{
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

/* =========================================================
   Responsive (shared)
   ========================================================= */
@media (max-width: 900px) {
  .main { padding: 16px; }
  .topbar { padding: 0 14px; }
  .brand__title { font-size: 14px; }
  .brand__subtitle { font-size: 11px; }
  .grid2 { grid-template-columns: 1fr; }
}

/* Mobil: sidebar -> drawer */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: min(86vw, 320px);
    transform: translateX(-110%);
    transition: transform .2s ease;
    z-index: 9998;
  }

  body.sidebar-open .sidebar { transform: translateX(0); }

  /* Overlay (sidebar açıkken) */
  .sidebar::after {
    content: "";
    position: fixed;
    inset: 64px 0 0 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: -1;
  }
  body.sidebar-open .sidebar::after {
    opacity: 1;
    pointer-events: auto;
  }

  .card { padding: 14px; }
  .card__header { flex-wrap: wrap; }

  /* Table: mobilde scroll */
  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* Toast: ekranı taşırmasın */
  .toast-container {
    right: 12px;
    left: 12px;
    bottom: 12px;
    align-items: stretch;
  }
  .toast { min-width: auto; }

  .modal-box {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    padding: 14px;
    border-radius: 14px;
  }
}

@media (max-width: 420px) {
  .brand__logo { width: 32px; height: 32px; border-radius: 10px; }
  .brand__title { font-size: 13px; }
  .modal-box { padding: 12px; }
}
