/* ==========================================================================
   refresh.css — Modern UI Polish Layer  (loaded LAST, override-only)
   --------------------------------------------------------------------------
   - Self-hosted Inter (CSP-safe: font-src 'self') for crisp typography.
   - Elevated, cohesive visual design on top of the existing token system.
   - Purely additive / visual overrides — NO structural layout changes.
   - Works in both light & dark themes (consumes theme.css variables).
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Inter — self-hosted variable font (Turkish latin-ext included)
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  letter-spacing: -0.006em;
}

/* --------------------------------------------------------------------------
   1. Refined design tokens — richer depth, gradients, softer surfaces
   -------------------------------------------------------------------------- */
:root {
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #4f46e5 55%, #4338ca 100%);
  --brand-grad-soft: linear-gradient(135deg, rgba(99,102,241,0.14), rgba(79,70,229,0.06));
  --ring-indigo: 0 0 0 4px rgba(99, 102, 241, 0.16);

  /* Softer, more diffuse, slightly cool-tinted elevation */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 2px 4px rgba(15, 23, 42, 0.04), 0 8px 20px -6px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 4px 8px rgba(15, 23, 42, 0.05), 0 18px 36px -10px rgba(15, 23, 42, 0.16);
  --shadow-xl: 0 8px 16px rgba(15, 23, 42, 0.06), 0 32px 56px -14px rgba(15, 23, 42, 0.22);
  --shadow-indigo: 0 8px 22px -6px rgba(79, 70, 229, 0.45);
}

[data-theme="light"] {
  --color-bg: #f5f6fb;
  --color-bg-alt: #eef1f8;
  --card-border: #e8ebf3;
  --color-border: #e8ebf3;
  --table-header-bg: #f7f8fc;
  --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.03);
}

[data-theme="dark"] {
  --color-bg: #0b1120;
  --color-bg-alt: #111a2e;
  --brand-grad-soft: linear-gradient(135deg, rgba(99,102,241,0.22), rgba(79,70,229,0.08));
}

/* Ambient page backdrop — subtle, premium, theme-aware */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1100px 520px at 100% -10%, rgba(99, 102, 241, 0.10), transparent 60%),
    radial-gradient(900px 480px at -10% 0%, rgba(16, 185, 129, 0.06), transparent 55%);
}
[data-theme="dark"] body::before {
  background:
    radial-gradient(1100px 520px at 100% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(900px 480px at -10% 0%, rgba(16, 185, 129, 0.08), transparent 55%);
}

/* --------------------------------------------------------------------------
   2. ICON SIZING FIX  (root cause of the giant pencil/edit icons)
   `.icon` was never defined; unsized <svg><use/></svg> rendered huge.
   -------------------------------------------------------------------------- */
.icon,
svg.icon {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
  vertical-align: -0.18em;
}
/* Safety net: any sprite-<use> svg without explicit width keeps a sane size */
svg:not([width]):not([class*="chart"]):not([data-chart]) > use {
  /* scope handled on parent below */
}
svg:not([width]):not([class*="chart"]):not([data-chart]) {
  width: 1.25em;
  height: 1.25em;
}
/* Buttons / links / table cells: align icons to text size */
.btn .icon, .btn svg:not([width]) { width: 1.1em; height: 1.1em; }
td .icon, td svg:not([width]), .table__link svg { width: 1.05em; height: 1.05em; }

/* --------------------------------------------------------------------------
   3. PAGE SHELL & HEADER
   -------------------------------------------------------------------------- */
.page-shell { padding-top: var(--space-6); }

.page-shell__header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.page-shell__title {
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.15;
  background: linear-gradient(180deg, var(--color-text), color-mix(in srgb, var(--color-text) 78%, var(--color-primary)));
  -webkit-background-clip: text;
  background-clip: text;
}

/* Breadcrumb — quieter, pill home */
.breadcrumb, [class*="breadcrumb"] { font-size: var(--text-sm); }

/* --------------------------------------------------------------------------
   4. CARDS
   -------------------------------------------------------------------------- */
.card {
  border-radius: 16px;
  border-color: var(--card-border);
  box-shadow: var(--shadow-sm);
}
.card:hover { box-shadow: var(--shadow-md); }

.card__title { font-weight: 700; letter-spacing: -0.01em; }

/* --------------------------------------------------------------------------
   5. STAT CARDS — premium summary tiles with accent + colored icon chip
   -------------------------------------------------------------------------- */
.stat-card {
  position: relative;
  border-radius: 16px;
  padding: var(--space-5) var(--space-6);
  background:
    var(--brand-grad-soft),
    var(--card-bg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.stat-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--brand-grad);
  opacity: 0.9;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.stat-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: var(--shadow-indigo);
}
.stat-card__icon svg { width: 22px; height: 22px; }
.stat-card__value {
  font-size: 2rem;
  font-weight: 780;
  letter-spacing: -0.03em;
}
.stat-card__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
}
.stat-card__link, .stat-link {
  font-weight: 600;
  color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   5b. GRID UTILITY FIX
   Dozens of dashboards/forms used `.grid-cols-N` WITHOUT the base `.grid`
   class, so `display:grid` was never set and the children collapsed into a
   full-width vertical stack — the "page scrolls forever / looks oversized"
   bug. Make the column utilities self-sufficient + add responsive collapse.
   -------------------------------------------------------------------------- */
.grid-cols-1, .grid-cols-2, .grid-cols-3, .grid-cols-4 { display: grid; }

@media (max-width: 1100px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 960px) {
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
}

/* Stat tiles that pair an icon chip with a body: lay them out as a centered
   row instead of stacking the icon above the text, and keep the value sized
   for a narrow gridded column. */
.stat-card:has(.stat-card__body) {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.stat-card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-card:has(.stat-card__body) .stat-card__icon {
  margin-bottom: 0;
  flex-shrink: 0;
}
.stat-card__body .stat-card__value { font-size: 1.6rem; }

/* --------------------------------------------------------------------------
   6. TABLES
   -------------------------------------------------------------------------- */
.table-wrapper {
  border-radius: 16px;
  border-color: var(--card-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table th {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.table td {
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid color-mix(in srgb, var(--color-border) 65%, transparent);
}
.table tbody tr { position: relative; }
.table tbody tr:hover {
  background: linear-gradient(90deg, color-mix(in srgb, var(--color-primary) 7%, transparent), transparent 60%);
  box-shadow: inset 3px 0 0 var(--color-primary);
}
.table__link { font-weight: 600; }
.table__link:hover { color: var(--color-primary-hover); text-decoration: none; }

/* Edit/Düzenle action link in tables: turn into a tidy pill */
td a:not(.btn):not(.table__link)[href*="edit"],
td a:not(.btn):not(.table__link)[href*="Edit"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-light);
  transition: background var(--transition-fast), color var(--transition-fast);
}
td a:not(.btn):not(.table__link)[href*="edit"]:hover,
td a:not(.btn):not(.table__link)[href*="Edit"]:hover {
  background: var(--color-primary);
  color: #fff;
}

/* --------------------------------------------------------------------------
   7. BUTTONS — full coverage of BOTH naming conventions
   IMPORTANT: most of the app uses BEM double-dash variants (.btn--primary,
   .btn--secondary, .btn--sm) which components.css never styled — they rendered
   as bare, label-only links. These rules give them real, modern styling so
   every button across the app looks consistent.
   -------------------------------------------------------------------------- */
.btn { border-radius: 10px; font-weight: 600; letter-spacing: -0.01em; }

/* Primary — gradient fill, white label */
.btn-primary,
.btn--primary,
.btn-submit,
.login-card__submit {
  background: var(--brand-grad);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-indigo);
}
.btn-primary:hover:not(:disabled),
.btn--primary:hover:not(:disabled),
.btn-submit:hover:not(:disabled) {
  filter: brightness(1.06);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 10px 26px -6px rgba(79, 70, 229, 0.55);
}

/* Secondary — surface fill, outline */
.btn-secondary,
.btn--secondary {
  background: var(--card-bg);
  color: var(--color-text);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled),
.btn--secondary:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* Danger */
.btn--danger,
.btn-danger,
.btn-remove {
  background: linear-gradient(135deg, #f87171, #ef4444 60%, #dc2626);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 22px -6px rgba(239, 68, 68, 0.45);
}
.btn--danger:hover:not(:disabled),
.btn-danger:hover:not(:disabled),
.btn-remove:hover:not(:disabled) { filter: brightness(1.05); color: #fff; }

/* Success */
.btn-success {
  background: linear-gradient(135deg, #34d399, #10b981 60%, #059669);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 22px -6px rgba(16, 185, 129, 0.45);
}
.btn-success:hover:not(:disabled) { filter: brightness(1.05); color: #fff; }

/* Ghost / text / link */
.btn--ghost, .btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn--ghost:hover:not(:disabled), .btn-ghost:hover:not(:disabled) {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.btn--text, .btn-link {
  background: transparent;
  border-color: transparent;
  color: var(--color-primary);
  box-shadow: none;
  min-height: 0;
  padding: var(--space-1) var(--space-2);
}
.btn--text:hover, .btn-link:hover { text-decoration: underline; }

/* Sizes */
.btn--sm {
  min-height: 34px;
  min-width: 0;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  border-radius: 8px;
}
.btn--md { min-height: 40px; padding: var(--space-2) var(--space-4); }
.btn--lg { min-height: 48px; padding: var(--space-3) var(--space-6); font-size: var(--text-lg); }
.btn--block { display: flex; width: 100%; }

/* Page header "+ add" actions */
.page-shell__actions .btn { box-shadow: var(--shadow-sm); }

/* --------------------------------------------------------------------------
   8. FORMS / INPUTS — calmer borders, glowing focus
   -------------------------------------------------------------------------- */
.form-control, .form-input, .form-select, select.form-control, textarea.form-control {
  border-radius: 10px;
  border-color: var(--input-border);
  background-color: var(--input-bg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus, .form-input:focus, .form-select:focus, textarea.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: var(--ring-indigo);
}
.form-label { font-weight: 600; color: var(--color-text); }

/* --------------------------------------------------------------------------
   9. TOPBAR — frosted glass, refined nav, gradient brand
   -------------------------------------------------------------------------- */
.topbar {
  background: color-mix(in srgb, var(--topbar-bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}
.topbar__brand { font-weight: 750; letter-spacing: -0.02em; }
.topbar__brand-logo,
.topbar__logo,
.topbar__brand img,
.topbar__brand > span:first-child {
  border-radius: 11px;
}
/* The brand square badge ("YE") → brand gradient */
.topbar__brand [class*="logo"],
.topbar__brand-mark,
.topbar__brand-badge {
  background: var(--brand-grad) !important;
  color: #fff !important;
  box-shadow: var(--shadow-indigo);
}

/* Nav items → pill hover/active */
.topbar__nav-item, .topbar__nav-link {
  border-radius: 10px;
  font-weight: 550;
}
.topbar__nav-item:hover, .topbar__nav-link:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.topbar__nav-item.is-active, .topbar__nav-link.is-active,
.topbar__nav-item[aria-current], .topbar__nav-link[aria-current] {
  background: var(--brand-grad-soft);
  color: var(--color-primary);
}

/* Topbar icon buttons */
.topbar__icon-btn, .topbar__action {
  border-radius: 10px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.topbar__icon-btn:hover, .topbar__action:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   10. BADGES — softer, rounded
   -------------------------------------------------------------------------- */
.badge { padding: 3px 10px; font-weight: 600; }

/* --------------------------------------------------------------------------
   11. CHART / DASHBOARD CARDS — center & cap chart canvas size
   -------------------------------------------------------------------------- */
.chart-card, .dashboard-chart, .card canvas {
  max-width: 100%;
}
.card canvas { display: block; margin-inline: auto; }

/* --------------------------------------------------------------------------
   12. LOGIN / AUTH — richer brand panel
   -------------------------------------------------------------------------- */
.login-page {
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(99,102,241,0.18), transparent 60%),
    radial-gradient(700px 500px at 0% 110%, rgba(16,185,129,0.10), transparent 55%),
    var(--login-bg);
}
.login-card {
  border-radius: 22px;
  box-shadow: var(--shadow-xl);
  border-color: var(--card-border);
}
.login-card__brand { border-radius: 16px; box-shadow: var(--shadow-indigo); }
.login-card__title { letter-spacing: -0.03em; }

/* --------------------------------------------------------------------------
   13. EMPTY STATES & MODALS — soften
   -------------------------------------------------------------------------- */
.empty-state__icon { background: var(--brand-grad-soft); color: var(--color-primary); }
.modal { border-radius: 20px; }

/* --------------------------------------------------------------------------
   15. NEXT-GEN MOTION LAYER — staggered page-load reveals, live micro-
   interactions, atmospheric depth. All entrance motion is gated behind
   prefers-reduced-motion: no-preference so it never hides content for users
   who opt out (and degrades to a plain, fully-visible layout).
   -------------------------------------------------------------------------- */

/* Stable digit width so animated count-ups don't reflow their neighbours. */
.stat-card__value { font-variant-numeric: tabular-nums; }

/* Atmospheric glow anchored to the top of the scroll content — subtle, brand
   tinted, behind everything, never intercepts clicks. */
.page-shell__content { position: relative; }
.page-shell__content::before {
  content: "";
  position: absolute;
  inset: -40px -40px auto -40px;
  height: 320px;
  background:
    radial-gradient(680px 300px at 82% -40%, rgba(99,102,241,0.10), transparent 70%),
    radial-gradient(560px 280px at 8% -60%, rgba(16,185,129,0.07), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.page-shell__content > * { position: relative; z-index: 1; }

@media (prefers-reduced-motion: no-preference) {
  /* Page-load reveal: cards, stat tiles, tables and charts rise + fade in. */
  .stat-card,
  .card,
  .table-wrapper {
    animation: rf-rise 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  /* Stagger siblings inside a grid / stack so the reveal cascades. */
  .grid > .stat-card:nth-child(1),  .grid > .card:nth-child(1)  { animation-delay: 40ms; }
  .grid > .stat-card:nth-child(2),  .grid > .card:nth-child(2)  { animation-delay: 100ms; }
  .grid > .stat-card:nth-child(3),  .grid > .card:nth-child(3)  { animation-delay: 160ms; }
  .grid > .stat-card:nth-child(4),  .grid > .card:nth-child(4)  { animation-delay: 220ms; }
  [class*="grid-cols"] > .stat-card:nth-child(1) { animation-delay: 40ms; }
  [class*="grid-cols"] > .stat-card:nth-child(2) { animation-delay: 100ms; }
  [class*="grid-cols"] > .stat-card:nth-child(3) { animation-delay: 160ms; }
  [class*="grid-cols"] > .stat-card:nth-child(4) { animation-delay: 220ms; }
  .card { animation-delay: 120ms; }
  .card + .card { animation-delay: 200ms; }
  .card + .card + .card { animation-delay: 280ms; }

  /* Sheen sweep across stat tiles on hover. */
  .stat-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
    transform: translateX(-120%);
    transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
  }
  .stat-card:hover::after { transform: translateX(120%); }
}

@keyframes rf-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* Richer, springier hover affordances (kept outside reduced-motion so the
   color/shadow shift still gives feedback; transform is reset below). */
.card { transition: box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.22,1,0.36,1), border-color 0.25s ease; }
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--color-primary) 22%, var(--card-border)); }
.stat-card { transition: box-shadow 0.3s ease, transform 0.3s cubic-bezier(0.22,1,0.36,1); }
.stat-card__icon { transition: transform 0.3s cubic-bezier(0.34,1.4,0.64,1); }
.stat-card:hover .stat-card__icon { transform: scale(1.08) rotate(-4deg); }

/* Table rows: smooth tint on hover instead of a hard background flip. */
.table tbody tr { transition: background-color 0.18s ease; }

/* Section / card titles: an animated brand underline accent. */
.card__title { position: relative; }

/* --------------------------------------------------------------------------
   14/15. Reduced motion — disable transforms & reveals, keep all content
   fully visible.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .stat-card:hover, .btn-primary:hover:not(:disabled),
  .card:hover, .stat-card:hover .stat-card__icon { transform: none; }
  .stat-card, .card, .table-wrapper { animation: none !important; opacity: 1 !important; }
}
