/* ============================================================
   Polypark — Prototype Design Tokens
   BookieWise family (matches polypark.io landing + BookieWise)
   ============================================================ */

:root, [data-theme="dark"] {
  /* ============ DARK THEME (default) ============ */
  --bg:           #0A0A0B;
  --bg-elev:      #131316;
  --bg-card:      #18181B;
  --bg-card-hover:#1F1F23;
  --border:       rgba(255,255,255,0.06);
  --border-hi:    rgba(255,255,255,0.10);
  --border-brand: rgba(60, 120, 255, 0.25);

  --fg:           #FFFFFF;
  --white:        #FFFFFF;
  --text-mid:     rgba(255,255,255,0.75);
  --text-dim:     rgba(255,255,255,0.50);
  --text-faint:   rgba(255,255,255,0.30);
  --text-ghost:   rgba(255,255,255,0.15);

  --brand:        #0034D1;
  --brand-light:  #3C78FF;
  --brand-glow:   rgba(0, 52, 209, 0.10);
  --brand-line:   rgba(60, 120, 255, 0.15);

  --yes:          #16C784;
  --yes-glow:     rgba(22, 199, 132, 0.15);
  --no:           #F23645;
  --no-glow:      rgba(242, 54, 69, 0.15);
  --gold:         #D4AF37;
  --warning:      #F59E0B;

  --shadow-card:  0 1px 0 rgba(255,255,255,0.02);
  --shadow-float: 0 12px 30px rgba(0,0,0,0.5);

  /* Typography */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Motion */
  --curve: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  /* ============ LIGHT THEME ============ */
  --bg:           #FAFAFA;
  --bg-elev:      #F2F2F4;
  --bg-card:      #FFFFFF;
  --bg-card-hover:#F7F7F9;
  --border:       rgba(0,0,0,0.08);
  --border-hi:    rgba(0,0,0,0.14);
  --border-brand: rgba(0, 52, 209, 0.25);

  --fg:           #0A0A0B;
  --white:        #0A0A0B;
  --text-mid:     rgba(0,0,0,0.72);
  --text-dim:     rgba(0,0,0,0.52);
  --text-faint:   rgba(0,0,0,0.38);
  --text-ghost:   rgba(0,0,0,0.18);

  --brand:        #0034D1;
  --brand-light:  #0034D1;
  --brand-glow:   rgba(0, 52, 209, 0.06);
  --brand-line:   rgba(0, 52, 209, 0.18);

  --yes:          #0A8B5A;
  --yes-glow:     rgba(10, 139, 90, 0.08);
  --no:           #C42633;
  --no-glow:      rgba(196, 38, 51, 0.08);
  --gold:         #A8841C;
  --warning:      #B07200;

  --shadow-card:  0 1px 2px rgba(0,0,0,0.04);
  --shadow-float: 0 12px 30px rgba(0,0,0,0.1);
}

/* ============ LIGHT MODE TAILWIND OVERRIDES ============
   (prototype'ta hardcoded arbitrary values kullanıldığı için)
*/
[data-theme="light"] body { background: var(--bg); color: var(--fg); }

[data-theme="light"] .bg-\[\#0A0A0B\] { background-color: var(--bg) !important; }
[data-theme="light"] .bg-\[\#0A0A0B\]\/60 { background-color: rgba(250,250,250,0.65) !important; }
[data-theme="light"] .bg-\[\#0A0A0B\]\/80 { background-color: rgba(250,250,250,0.85) !important; }
[data-theme="light"] .bg-\[\#0A0A0B\]\/90 { background-color: rgba(250,250,250,0.92) !important; }
[data-theme="light"] .bg-\[\#18181B\] { background-color: var(--bg-card) !important; }
[data-theme="light"] .bg-\[\#131316\] { background-color: var(--bg-elev) !important; }
[data-theme="light"] .bg-\[\#1F1F23\] { background-color: #EEEEF0 !important; }

/* Text white family → forced to dark text (boosted for light bg readability) */
[data-theme="light"] .text-white { color: var(--fg) !important; }

/* EXCEPTION: text-white inside colored fills (gradient bg, bg-brand, bg-yes, bg-no, bg-warning, bg-gold) stays white */
[data-theme="light"] .bg-gradient-to-br .text-white,
[data-theme="light"] .bg-gradient-to-tr .text-white,
[data-theme="light"] .bg-gradient-to-r .text-white,
[data-theme="light"] .bg-gradient-to-l .text-white,
[data-theme="light"] .bg-gradient-to-t .text-white,
[data-theme="light"] .bg-gradient-to-b .text-white,
[data-theme="light"] .bg-gradient-to-br.text-white,
[data-theme="light"] .bg-gradient-to-tr.text-white,
[data-theme="light"] .bg-gradient-to-r.text-white,
[data-theme="light"] .bg-brand .text-white,
[data-theme="light"] .bg-brand.text-white,
[data-theme="light"] .bg-brand-light .text-white,
[data-theme="light"] .bg-brand-light.text-white { color: #FFFFFF !important; }
[data-theme="light"] .text-white\/90 { color: rgba(0,0,0,0.88) !important; }
[data-theme="light"] .text-white\/80 { color: rgba(0,0,0,0.82) !important; }
[data-theme="light"] .text-white\/70 { color: rgba(0,0,0,0.75) !important; }
[data-theme="light"] .text-white\/60 { color: rgba(0,0,0,0.68) !important; }
[data-theme="light"] .text-white\/50 { color: rgba(0,0,0,0.58) !important; }
[data-theme="light"] .text-white\/40 { color: rgba(0,0,0,0.50) !important; }
[data-theme="light"] .text-white\/30 { color: rgba(0,0,0,0.40) !important; }
[data-theme="light"] .text-white\/20 { color: rgba(0,0,0,0.28) !important; }
[data-theme="light"] .text-white\/10 { color: rgba(0,0,0,0.15) !important; }

/* Border white family */
[data-theme="light"] .border-white\/5 { border-color: rgba(0,0,0,0.06) !important; }
[data-theme="light"] .border-white\/10 { border-color: rgba(0,0,0,0.10) !important; }
[data-theme="light"] .border-white\/20 { border-color: rgba(0,0,0,0.16) !important; }

/* BG white-alpha family (overlay/highlight) */
[data-theme="light"] .bg-white\/3 { background-color: rgba(0,0,0,0.03) !important; }
[data-theme="light"] .bg-white\/5 { background-color: rgba(0,0,0,0.04) !important; }
[data-theme="light"] .bg-white\/10 { background-color: rgba(0,0,0,0.08) !important; }

/* Semantic colors adjusted for light mode contrast */
[data-theme="light"] .text-yes,
[data-theme="light"] .text-\[\#16C784\] { color: #0A8B5A !important; }
[data-theme="light"] .text-no,
[data-theme="light"] .text-\[\#F23645\] { color: #C42633 !important; }
[data-theme="light"] .text-gold,
[data-theme="light"] .text-\[\#D4AF37\] { color: #A8841C !important; }
[data-theme="light"] .text-warning { color: #B07200 !important; }

/* Brand-light (used as link color in dark) should map back to brand in light */
[data-theme="light"] .text-brand-light { color: var(--brand) !important; }

/* Pulse glow — soften in light mode */
[data-theme="light"] @keyframes pulse-yes {
  0%, 100% { box-shadow: 0 0 0 0 rgba(10,139,90,0.4); }
  50% { box-shadow: 0 0 0 5px rgba(10,139,90,0); }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.618;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* Utility classes (Tailwind genişletmesi) */
.font-mono { font-family: var(--font-mono); }
.text-balance { text-wrap: balance; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Card hover effects */
.card-hover {
  transition: border-color 200ms var(--curve), transform 200ms var(--curve);
}
.card-hover:hover {
  border-color: var(--border-hi);
  transform: translateY(-1px);
}

/* Button styles */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 21px;
  border-radius: 8px;
  background: var(--brand);
  color: #FFFFFF; /* always white on branded blue */
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 200ms var(--curve);
}
.btn-primary:hover {
  background: var(--brand-light);
  box-shadow: 0 0 20px rgba(0,52,209,0.3);
}
[data-theme="light"] .btn-primary:hover {
  background: #002FB8; /* darker hover in light */
  box-shadow: 0 4px 14px rgba(0,52,209,0.25);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 21px;
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-hi);
  transition: all 200ms var(--curve);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.2);
}

.btn-yes {
  background: var(--yes);
  color: #0A0A0B;
}
.btn-yes:hover {
  background: #10A56E;
  box-shadow: 0 0 20px var(--yes-glow);
}

.btn-no {
  background: var(--no);
  color: #0A0A0B;
}
.btn-no:hover {
  background: #D22E3D;
  box-shadow: 0 0 20px var(--no-glow);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge-brand { background: var(--brand-glow); color: var(--brand-light); border: 1px solid var(--brand-line); }
.badge-yes { background: var(--yes-glow); color: var(--yes); }
.badge-no { background: var(--no-glow); color: var(--no); }
.badge-gold { background: rgba(212,175,55,0.1); color: var(--gold); }
.badge-warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.badge-neutral { background: rgba(255,255,255,0.06); color: var(--text-dim); }

/* Pulse animation */
@keyframes pulse-yes {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,199,132,0.6); }
  50% { box-shadow: 0 0 0 5px rgba(22,199,132,0); }
}
.pulse-yes { animation: pulse-yes 2s ease-in-out infinite; }

@keyframes pulse-brand {
  0%, 100% { box-shadow: 0 0 0 0 rgba(60,120,255,0.6); }
  50% { box-shadow: 0 0 0 5px rgba(60,120,255,0); }
}
.pulse-brand { animation: pulse-brand 2s ease-in-out infinite; }

/* Sidebar */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 13px;
  border-radius: 8px;
  color: var(--text-mid);
  font-size: 13px;
  transition: all 150ms;
  cursor: pointer;
  text-decoration: none;
}
.sidebar-link:hover {
  background: rgba(255,255,255,0.04);
  color: var(--white);
}
.sidebar-link.active {
  background: var(--brand-glow);
  color: var(--brand-light);
  border: 1px solid var(--brand-line);
}
.sidebar-link .icon { width: 16px; height: 16px; flex-shrink: 0; }

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  padding: 13px 21px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
}
.data-table td {
  padding: 13px 21px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* Input */
.input {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--white);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 150ms;
}
.input:focus {
  outline: none;
  border-color: var(--brand-light);
}

/* Stat tile */
.stat-tile {
  padding: 21px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 13px;
}
.stat-label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-delta {
  font-size: 12px;
  font-family: var(--font-mono);
  margin-top: 4px;
}
.stat-delta.up { color: var(--yes); }
.stat-delta.down { color: var(--no); }

/* Chart placeholder */
.chart-placeholder {
  width: 100%;
  height: 200px;
  background: linear-gradient(180deg, var(--brand-glow) 0%, transparent 100%);
  border: 1px solid var(--border);
  border-radius: 13px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 13px;
  position: relative;
  overflow: hidden;
}

/* Sparkline */
.sparkline {
  height: 40px;
  width: 100px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 21px;
  right: 21px;
  padding: 13px 21px;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  color: var(--fg);
  font-size: 13px;
  box-shadow: var(--shadow-float);
  z-index: 9999;
  animation: slide-up 300ms var(--curve);
}
@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ============ FLOATING THEME TOGGLE ============ */
.fw-theme-toggle {
  position: fixed;
  bottom: 76px;
  right: 21px;
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.fw-theme-toggle button {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms var(--curve);
}
.fw-theme-toggle button:hover {
  color: var(--fg);
}
.fw-theme-toggle button.active {
  background: var(--brand);
  color: #fff;
}

/* ============ GRADIENT TEXT (theme aware) ============ */
.fw-gradient-text {
  background: linear-gradient(to right, var(--fg), var(--brand-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* In light theme, use brand-light (darker blue) gradient */
[data-theme="light"] .fw-gradient-text {
  background: linear-gradient(to right, var(--fg), #0034D1);
  -webkit-background-clip: text;
  background-clip: text;
}

/* Tailwind's from-white / to-brand-light in gradients */
[data-theme="light"] .from-white { --tw-gradient-from: var(--fg) !important; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, transparent) !important; }
[data-theme="light"] .from-brand { --tw-gradient-from: #0034D1 !important; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, transparent) !important; }

/* ============ FOCUS RING (a11y) ============ */
*:focus-visible {
  outline: 2px solid var(--brand-light);
  outline-offset: 2px;
  border-radius: 4px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
}

/* ============ PRICE FLASH (live tick) ============ */
@keyframes flash-up-glow {
  0% { background: rgba(22,199,132,0); color: var(--yes); }
  20% { background: rgba(22,199,132,0.25); color: var(--yes); transform: scale(1.06); }
  100% { background: rgba(22,199,132,0); color: var(--yes); transform: scale(1); }
}
@keyframes flash-down-glow {
  0% { background: rgba(242,54,69,0); color: var(--no); }
  20% { background: rgba(242,54,69,0.25); color: var(--no); transform: scale(1.06); }
  100% { background: rgba(242,54,69,0); color: var(--no); transform: scale(1); }
}
.fw-price {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  transition: color 200ms;
}
.fw-price.flash-up { animation: flash-up-glow 600ms var(--curve); }
.fw-price.flash-down { animation: flash-down-glow 600ms var(--curve); }

/* ============ LIVE DOT ============ */
.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--yes);
  box-shadow: 0 0 0 0 rgba(22,199,132,0.6);
  animation: live-pulse 1.8s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,199,132,0.6); }
  50% { box-shadow: 0 0 0 6px rgba(22,199,132,0); }
}

/* ============ ACTIVITY FEED ENTRY (live insert) ============ */
.feed-entry {
  opacity: 1;
  transform: translateX(0);
  transition: all 300ms var(--curve);
}
@keyframes feed-slide-in {
  0% { opacity: 0; transform: translateX(-20px); background: rgba(60,120,255,0.08); }
  100% { opacity: 1; transform: translateX(0); background: transparent; }
}
.feed-entry.new { animation: feed-slide-in 500ms var(--curve); }

/* ============ SKELETON LOADER ============ */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-elev) 0%, var(--bg-card-hover) 50%, var(--bg-elev) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============ MICRO-INTERACTIONS ============ */
button, a {
  transition: transform 180ms var(--curve), background 180ms, border-color 180ms, color 180ms, box-shadow 180ms;
}
button:active, a:active { transform: translateY(1px); }

.card-hover:hover { transform: translateY(-2px); }

/* Countdown styling */
.fw-countdown {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.fw-countdown.urgent { color: var(--warning); }

/* ============ MOBILE RESPONSIVE ============ */

/* Admin shell: sidebar becomes drawer on mobile */
@media (max-width: 768px) {
  #fw-shell-root > div.flex {
    display: block !important;
  }
  #fw-shell-root aside {
    position: fixed !important;
    top: 0;
    left: 0;
    height: 100vh !important;
    transform: translateX(-100%);
    transition: transform 280ms var(--curve);
    z-index: 9997;
    box-shadow: 8px 0 24px rgba(0,0,0,0.5);
  }
  #fw-shell-root aside.open {
    transform: translateX(0);
  }
  #fw-shell-root main {
    width: 100% !important;
    min-width: 0 !important;
  }
  .fw-mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9996;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms;
  }
  .fw-mobile-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
  .fw-hamburger {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    color: var(--fg);
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 10px;
  }

  /* Generic mobile paddings on data-shell-content */
  [data-shell-content] {
    padding: 16px !important;
  }
  [data-shell-content] .p-\[34px\] { padding: 16px !important; }
  [data-shell-content] .p-\[21px\] { padding: 13px !important; }

  /* Stat tiles grid → 2 cols always on mobile */
  .stat-tile { padding: 13px; }

  /* Tables horizontal scroll */
  .data-table { min-width: 600px; }
  .rounded-\[13px\]:has(> .data-table),
  [class*="rounded-"]:has(> table.data-table) {
    overflow-x: auto;
  }

  /* Hide persona switcher + theme toggle on small mobile to save space */
  .fw-theme-toggle { bottom: 13px; right: 13px; }
}

.fw-hamburger { display: none; }

/* Tenant (player) pages mobile */
@media (max-width: 640px) {
  .max-w-\[1280px\] { max-width: 100% !important; }
  header .hidden { display: none !important; }
  header nav.hidden { display: none !important; }
  header .h-\[64px\] { height: 56px !important; }

  /* Hero sections tighten */
  h1.text-5xl { font-size: 2rem !important; }
  h1.text-3xl { font-size: 1.5rem !important; }

  /* Market cards stack */
  .grid.grid-cols-1 { gap: 10px !important; }
}

/* Auth split screen stacks on mobile */
@media (max-width: 1024px) {
  body.min-h-screen.flex aside { display: none !important; }
  body.min-h-screen.flex main { flex: 1 !important; }
}

/* ============ REDUCE MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .fw-price.flash-up, .fw-price.flash-down { animation: none !important; }
  .live-dot { animation: none !important; }
}
