/* Curki Admin — design system on top of Tailwind CDN.
   Brand color: rgb(108, 76, 220) / #6C4CDC
   Visual language inspired by Donezo: neutral page, white app shell,
   filled-brand active nav, hero-variant stat cards, pill CTAs. */

:root {
  --brand-50:  #F4F1FE;
  --brand-100: #E7E0FC;
  --brand-200: #CFBFF8;
  --brand-300: #A993F0;
  --brand-400: #8B70EA;
  --brand-500: #6C4CDC;
  --brand-600: #5B36E1;
  --brand-700: #4928B8;
  --brand-800: #371F8E;
  --brand-900: #251565;
  --brand-rgb: 108, 76, 220;

  --page-bg: #F3F3F5;
  --shell-bg: #FFFFFF;
  --shell-radius: 28px;
  --hairline: rgba(15, 23, 42, 0.06);
  --easing: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html { color-scheme: light; }
body {
  -webkit-font-smoothing: antialiased;
  background: var(--page-bg);
}
::selection { background: rgba(108, 76, 220, 0.18); color: var(--brand-900); }

/* ─────────────────────────────────────────────────────────────
   APP SHELL — the rounded white "window" the whole app sits in.
   On large screens it has a soft margin and a generous radius;
   on small screens it goes edge-to-edge.
   ───────────────────────────────────────────────────────────── */
.app-shell {
  position: relative;
  margin: 12px;
  background: var(--shell-bg);
  border-radius: var(--shell-radius);
  height: calc(100vh - 24px);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  overflow: hidden;
}
@media (max-width: 1023px) {
  .app-shell { margin: 0; border-radius: 0; height: 100vh; }
}

/* ─────────────────────────────────────────────────────────────
   SIDEBAR
   ───────────────────────────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--hairline);
}
.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: rgb(148, 163, 184);
  text-transform: uppercase;
  padding: 14px 14px 6px;
}

/* Nav link — flat by default; active = filled brand pill */
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: rgb(71, 85, 105);
  transition: background 180ms var(--easing), color 180ms var(--easing);
}
.nav-link:hover {
  background: rgba(15, 23, 42, 0.04);
  color: rgb(15, 23, 42);
}
.nav-link.active {
  background: linear-gradient(180deg, var(--brand-500) 0%, var(--brand-600) 100%);
  color: white;
  font-weight: 600;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.20),
    0 6px 14px -6px rgba(91, 54, 225, 0.50);
}
.nav-link.active svg { color: white; }
.nav-link .nav-badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 9999px;
  background: var(--brand-100);
  color: var(--brand-700);
}
.nav-link.active .nav-badge { background: rgba(255,255,255,0.22); color: white; }

/* Sidebar promo card — brand gradient with decorative wash */
.sidebar-promo {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background:
    radial-gradient(circle at 100% 100%, rgba(255,255,255,0.18) 0%, transparent 50%),
    radial-gradient(circle at 0% 0%, rgba(255,255,255,0.08) 0%, transparent 55%),
    linear-gradient(135deg, #4928B8 0%, #6C4CDC 55%, #8B70EA 100%);
  color: white;
  padding: 16px 16px 18px;
  box-shadow: 0 12px 24px -12px rgba(91, 54, 225, 0.45);
}
.sidebar-promo::after {
  content: '';
  position: absolute;
  right: -28px;
  bottom: -28px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.10), transparent 70%);
  pointer-events: none;
}
.sidebar-promo > * { position: relative; z-index: 1; }
.sidebar-promo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 9999px;
  background: white;
  color: var(--brand-700);
  font-size: 12px;
  font-weight: 600;
  transition: transform 120ms ease, box-shadow 200ms ease;
}
.sidebar-promo-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.15);
}

/* ─────────────────────────────────────────────────────────────
   PILL BUTTONS — header / page CTAs
   ───────────────────────────────────────────────────────────── */
.btn-pill-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 9999px;
  background: linear-gradient(180deg, var(--brand-500) 0%, var(--brand-600) 100%);
  color: white;
  font-weight: 600;
  font-size: 13px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.20),
    0 6px 14px -4px rgba(91, 54, 225, 0.45);
  transition: transform 120ms ease, box-shadow 200ms ease, filter 120ms ease;
  white-space: nowrap;
}
.btn-pill-primary:hover { filter: brightness(1.05); box-shadow: inset 0 1px 0 rgba(255,255,255,0.20), 0 10px 22px -6px rgba(91, 54, 225, 0.55); }
.btn-pill-primary:active { transform: translateY(1px); }

.btn-pill-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 9999px;
  background: white;
  color: var(--brand-700);
  border: 1.5px solid var(--brand-200);
  font-weight: 600;
  font-size: 13px;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
  white-space: nowrap;
}
.btn-pill-secondary:hover {
  background: var(--brand-50);
  border-color: var(--brand-400);
  color: var(--brand-800);
}

/* ─────────────────────────────────────────────────────────────
   PANELS — content cards (charts, lists, tables)
   ───────────────────────────────────────────────────────────── */
.panel {
  background: white;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 1.25rem;
  transition: border-color 220ms var(--easing);
}
.panel:hover { border-color: rgba(15, 23, 42, 0.10); }

/* Clickable panels (e.g. org cards) — brand-tinted hover with a soft lift */
.panel.cursor-pointer {
  transition:
    background 240ms var(--easing),
    border-color 240ms var(--easing),
    transform 240ms var(--easing),
    box-shadow 240ms var(--easing);
}
.panel.cursor-pointer:hover {
  background: var(--brand-50);
  border-color: rgba(108, 76, 220, 0.32);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -10px rgba(108, 76, 220, 0.20);
}
@media (min-width: 1024px) {
  .panel { padding: 1.5rem; }
}

/* ─────────────────────────────────────────────────────────────
   STAT CARDS — Donezo-style, hero variant + default variant
   ───────────────────────────────────────────────────────────── */

/* Stat card — visibly tinted with its accent color at rest (top bar +
   corner glow + diagonal wash). On hover everything deepens slightly:
   the bar goes edge-to-edge at full opacity, the glow and wash strengthen,
   the border darkens, and the card lifts with an accent-tinted shadow.
   Text stays dark throughout — no white-on-color flip. */
.stat-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(var(--accent-rgb, 108, 76, 220), 0.28);
  border-radius: 16px;
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  min-height: 140px;
  background:
    radial-gradient(circle at 100% 0%, rgba(var(--accent-rgb, 108, 76, 220), 0.24) 0%, transparent 55%),
    linear-gradient(140deg, rgba(var(--accent-rgb, 108, 76, 220), 0.12) 0%, rgba(var(--accent-rgb, 108, 76, 220), 0.02) 60%),
    #ffffff;
  transition:
    transform 280ms var(--easing),
    box-shadow 280ms var(--easing),
    background 280ms var(--easing),
    border-color 280ms var(--easing);
}

/* Top-edge accent bar — visible by default, edge-to-edge on hover */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--accent, var(--brand-500)) 20%,
    var(--accent, var(--brand-500)) 80%,
    transparent 100%);
  opacity: 0.85;
  transition: opacity 280ms var(--easing), left 280ms var(--easing), right 280ms var(--easing);
  z-index: 1;
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(var(--accent-rgb, 108, 76, 220), 0.50);
  background:
    radial-gradient(circle at 100% 0%, rgba(var(--accent-rgb, 108, 76, 220), 0.36) 0%, transparent 60%),
    linear-gradient(140deg, rgba(var(--accent-rgb, 108, 76, 220), 0.20) 0%, rgba(var(--accent-rgb, 108, 76, 220), 0.04) 65%),
    #ffffff;
  box-shadow:
    0 16px 32px -14px rgba(var(--accent-rgb, 108, 76, 220), 0.36),
    0 4px 10px -6px rgba(15, 23, 42, 0.06);
}
.stat-card:hover::before {
  opacity: 1;
  left: 0;
  right: 0;
}

/* Card header: label (left) + drill-in arrow (right) */
.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: rgb(71, 85, 105);
  letter-spacing: -0.005em;
  transition: color 280ms var(--easing);
}

/* Drill-in arrow button — soft circle, rotates on hover */
.stat-arrow {
  width: 30px;
  height: 30px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.04);
  color: rgb(71, 85, 105);
  transition: background 200ms ease, color 200ms ease, transform 240ms var(--easing);
  flex-shrink: 0;
}
.stat-arrow:hover {
  background: var(--brand-100);
  color: var(--brand-700);
  transform: rotate(-25deg);
}

/* Value — large tabular number */
.stat-value {
  font-size: 36px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: rgb(15, 23, 42);
  font-variant-numeric: tabular-nums;
  transition: color 280ms var(--easing);
}
@media (min-width: 1024px) {
  .stat-value { font-size: 40px; }
}

/* Bottom strip — separator + trend chip / hint */
.stat-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px dashed rgba(15, 23, 42, 0.10);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: rgb(71, 85, 105);
  font-weight: 500;
  transition: color 280ms var(--easing), border-top-color 280ms var(--easing);
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  flex-shrink: 0;
  transition: background 280ms var(--easing), color 280ms var(--easing);
}
.stat-chip svg { display: block; }
.stat-chip-up   { background: rgb(220 252 231); color: rgb(21 128 61); }
.stat-chip-down { background: rgb(254 226 226); color: rgb(153 27 27); }
.stat-chip-flat { background: rgb(241 245 249); color: rgb(71 85 105); }

/* Mini stat card — smaller variant used in detail modals.
   Same accent-tint language as .stat-card so the system feels consistent. */
.mini-stat-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(var(--accent-rgb, 108, 76, 220), 0.22);
  border-radius: 10px;
  padding: 10px 12px;
  background:
    radial-gradient(circle at 100% 0%, rgba(var(--accent-rgb, 108, 76, 220), 0.20) 0%, transparent 60%),
    linear-gradient(140deg, rgba(var(--accent-rgb, 108, 76, 220), 0.09) 0%, rgba(var(--accent-rgb, 108, 76, 220), 0.01) 60%),
    #ffffff;
  transition:
    transform 240ms var(--easing),
    box-shadow 240ms var(--easing),
    background 240ms var(--easing),
    border-color 240ms var(--easing);
}
.mini-stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--accent-rgb, 108, 76, 220), 0.45);
  background:
    radial-gradient(circle at 100% 0%, rgba(var(--accent-rgb, 108, 76, 220), 0.32) 0%, transparent 65%),
    linear-gradient(140deg, rgba(var(--accent-rgb, 108, 76, 220), 0.18) 0%, rgba(var(--accent-rgb, 108, 76, 220), 0.02) 65%),
    #ffffff;
  box-shadow:
    0 10px 22px -12px rgba(var(--accent-rgb, 108, 76, 220), 0.28);
}

/* ─────────────────────────────────────────────────────────────
   HEADER
   ───────────────────────────────────────────────────────────── */

/* Section icon chip — gradient brand badge sitting next to the page title.
   Has an inner highlight, a soft inset shadow at the bottom, and a colored
   drop shadow so it visually pops off the header bar. */
.page-icon-chip {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  align-items: center;
  justify-content: center;
  color: white;
  background:
    radial-gradient(circle at 100% 100%, rgba(255,255,255,0.20) 0%, transparent 50%),
    linear-gradient(135deg, var(--brand-500) 0%, var(--brand-600) 55%, var(--brand-700) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08),
    0 6px 14px -4px rgba(91, 54, 225, 0.45);
  flex-shrink: 0;
  transition: transform 240ms var(--easing), box-shadow 240ms var(--easing);
}
.page-icon-chip:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(0, 0, 0, 0.10),
    0 10px 20px -6px rgba(91, 54, 225, 0.55);
}
.page-icon-chip svg { display: block; }

.range-preset.active {
  background: white;
  color: var(--brand-700);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────
   BAR ROW (lists)
   ───────────────────────────────────────────────────────────── */
.bar-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  overflow: hidden;
  transition: background 180ms var(--easing);
}
.bar-row:hover { background: var(--brand-50); }
.bar-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--w, 0%);
  background: linear-gradient(90deg, rgba(108, 76, 220, 0.14), rgba(108, 76, 220, 0.03));
  border-radius: 0.5rem;
  z-index: 0;
  transition: width 300ms ease;
}
.bar-row > * { position: relative; z-index: 1; }

/* ─────────────────────────────────────────────────────────────
   PILLS / STATUSES
   ───────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.pill-up { background: rgb(220 252 231); color: rgb(22 101 52); }
.pill-down { background: rgb(254 226 226); color: rgb(153 27 27); }
.pill-admin { background: var(--brand-100); color: var(--brand-700); }
.pill-owner { background: rgb(254 243 199); color: rgb(146 64 14); }
.pill-staff { background: rgb(241 245 249); color: rgb(51 65 85); }
.pill-open { background: rgb(254 226 226); color: rgb(153 27 27); }
.pill-resolved { background: rgb(220 252 231); color: rgb(22 101 52); }
.pill-in_progress { background: rgb(255 237 213); color: rgb(154 52 18); }

/* ─────────────────────────────────────────────────────────────
   MISC
   ───────────────────────────────────────────────────────────── */
.spinner {
  border: 2px solid rgba(108, 76, 220, 0.22);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  width: 1rem;
  height: 1rem;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, rgb(241 245 249) 0%, rgba(207, 191, 248, 0.35) 50%, rgb(241 245 249) 100%);
  background-size: 1000px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: 0.375rem;
}
@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

.section { animation: fadeIn 0.22s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Fancy brand-themed scrollbars — floating pill with vertical gradient.
   The 3px transparent border + background-clip:padding-box creates a
   "floating" thumb with breathing room around it (Apple/Linear style). */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--brand-300) 0%, var(--brand-500) 100%);
  border-radius: 9999px;
  border: 3px solid transparent;
  background-clip: padding-box;
  transition: background 200ms ease;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--brand-500) 0%, var(--brand-700) 100%);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, var(--brand-600) 0%, var(--brand-800) 100%);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: transparent; }

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--brand-400) transparent;
}

tbody tr {
  border-bottom: 1px solid rgb(241 245 249);
  transition: background 150ms ease;
}
tbody tr:hover {
  background: var(--brand-50);
  cursor: pointer;
}
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 0.75rem; }

.dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--c, var(--brand-500));
  flex-shrink: 0;
}

/* Focus rings */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(108, 76, 220, 0.30);
  border-color: var(--brand-500);
}

input[type="date"] { color-scheme: light; }
