/* ============================================================
   KaliArena Portal — Shared Stylesheet
   Replicated from Next.js globals.css (exact color tokens)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;900&display=swap');

/* ── CSS Custom Properties (mirrors globals.css exactly) ── */
:root {
  --background:        oklch(0.99 0.004 85);
  --foreground:        oklch(0.2 0.02 25);
  --card:              oklch(1 0.002 85);
  --card-foreground:   oklch(0.2 0.02 25);
  --primary:           oklch(0.5 0.19 25);
  --primary-foreground:oklch(0.99 0 0);
  --secondary:         oklch(0.965 0.008 85);
  --secondary-foreground:oklch(0.25 0.02 25);
  --muted:             oklch(0.955 0.01 85);
  --muted-foreground:  oklch(0.48 0.02 25);
  --accent:            oklch(0.955 0.02 75);
  --destructive:       oklch(0.577 0.245 27.325);
  --destructive-foreground:oklch(0.985 0 0);
  --border:            oklch(0.9 0.01 85);
  --input:             oklch(0.92 0.008 85);
  --ring:              oklch(0.55 0.14 25);
  --radius:            0.875rem;
  --sidebar:           oklch(0.995 0.004 85);
  --sidebar-border:    oklch(0.9 0.01 85);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ── Layout Shell ── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 17rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid oklch(0.9 0.01 85 / 0.5);
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  height: 100vh;
  overflow: hidden;
}
.sidebar-logo {
  padding: 1.25rem;
  border-bottom: 1px solid oklch(0.9 0.01 85 / 0.4);
  display: flex; align-items: center; gap: .625rem;
}
.sidebar-logo-text {
  font-size: 1.3rem; font-weight: 900;
  color: var(--primary); letter-spacing: -0.03em;
}
.sidebar-badge-area { padding: 0.75rem 1rem 0.375rem; }
.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0.75rem;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.125rem;
}
.sidebar-nav-link {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.875rem; font-weight: 500;
  color: var(--muted-foreground);
  transition: background 0.15s, color 0.15s;
  text-decoration: none; border: none; background: none; width: 100%; text-align: left;
}
.sidebar-nav-link:hover { background: oklch(0.955 0.01 85 / 0.7); color: var(--foreground); }
.sidebar-nav-link.active {
  background: var(--primary); color: var(--primary-foreground);
  box-shadow: 0 1px 3px oklch(0 0 0 / 0.1);
}
.sidebar-nav-link svg, .sidebar-nav-link i { width: 1rem; height: 1rem; flex-shrink: 0; }
.sidebar-footer { border-top: 1px solid oklch(0.9 0.01 85 / 0.4); padding: 1rem 0.75rem; }

/* ── Main Content ── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.page-content { flex: 1; overflow-y: auto; padding-bottom: 5rem; }
@media (min-width: 1024px) { .page-content { padding-bottom: 0; } }
@media (max-width: 1023px) { .sidebar { display: none; } }

/* ── Header ── */
.portal-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; height: 3.5rem; align-items: center; justify-content: space-between;
  border-bottom: 1px solid oklch(0.9 0.01 85 / 0.5);
  background: oklch(1 0.002 85 / 0.9);
  padding: 0 1rem;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
@media (min-width: 1024px) { .portal-header { height: 4rem; padding: 0 2rem; } }
.header-left { display: flex; align-items: center; gap: 0.75rem; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.header-title { font-size: 0.9375rem; font-weight: 600; color: var(--foreground); }
.header-subtitle { font-size: 0.8125rem; color: var(--muted-foreground); margin-top: 0.1rem; }
.header-avatar {
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--primary); color: var(--primary-foreground);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}
.header-user-name { font-size: 0.875rem; font-weight: 500; color: var(--foreground); }

/* ── Auth Pages ── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, oklch(0.955 0.01 85) 0%, var(--background) 100%);
  padding: 1.5rem;
}
.auth-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.25rem);
  padding: 2rem; width: 100%; max-width: 28rem;
  box-shadow: 0 4px 24px oklch(0.2 0.02 25 / 0.08);
}
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo-text { font-size: 1.75rem; font-weight: 900; color: var(--primary); letter-spacing: -0.03em; }
.auth-logo-sub { font-size: 0.875rem; color: var(--muted-foreground); margin-top: 0.25rem; }
.auth-title { font-size: 1.375rem; font-weight: 700; margin-bottom: 0.25rem; }
.auth-subtitle { font-size: 0.875rem; color: var(--muted-foreground); margin-bottom: 1.5rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; }
.form-input {
  width: 100%; padding: 0.5625rem 0.75rem;
  background: var(--background); border: 1px solid var(--input);
  border-radius: var(--radius); font-size: 0.875rem; color: var(--foreground);
  transition: border-color 0.15s, box-shadow 0.15s; outline: none;
}
.form-input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px oklch(0.55 0.14 25 / 0.15); }
.form-input::placeholder { color: var(--muted-foreground); }
textarea.form-input { min-height: 90px; resize: vertical; }
.form-select {
  width: 100%; padding: 0.5625rem 2.25rem 0.5625rem 0.75rem;
  background: var(--background); border: 1px solid var(--input);
  border-radius: var(--radius); font-size: 0.875rem; color: var(--foreground);
  outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center;
}
.form-select:focus { border-color: var(--ring); box-shadow: 0 0 0 3px oklch(0.55 0.14 25 / 0.15); }
.form-error { font-size: 0.8125rem; color: var(--destructive); margin-top: 0.375rem; }
.form-hint { font-size: 0.8125rem; color: var(--muted-foreground); margin-top: 0.375rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.5625rem 1rem; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 500; transition: all 0.15s;
  cursor: pointer; border: none; text-decoration: none; white-space: nowrap; line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg, .btn i { width: 1rem; height: 1rem; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); box-shadow: 0 1px 3px oklch(0 0 0 / 0.1); }
.btn-primary:hover:not(:disabled) { background: oklch(0.44 0.19 25); }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--muted); }
.btn-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.btn-destructive:hover:not(:disabled) { background: oklch(0.52 0.245 27); }
.btn-ghost { background: transparent; color: var(--muted-foreground); }
.btn-ghost:hover:not(:disabled) { background: var(--muted); color: var(--foreground); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--foreground); }
.btn-outline:hover:not(:disabled) { background: var(--muted); }
.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.25rem; font-size: 1rem; width: 100%; justify-content: center; }
.btn-icon { width: 2.25rem; height: 2.25rem; padding: 0; }

/* ── Cards ── */
.card {
  background: var(--card); border: 1px solid oklch(0.9 0.01 85 / 0.6);
  border-radius: 1rem;
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.04), 0 4px 16px oklch(0.2 0.02 25 / 0.04);
}
.card-header { padding: 1.25rem 1.25rem 0; }
.card-title { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.card-description { font-size: 0.875rem; color: var(--muted-foreground); margin-top: 0.25rem; }
.card-content { padding: 1.25rem; }
.card-footer { padding: 0 1.25rem 1.25rem; display: flex; align-items: center; gap: 0.75rem; }

/* ── Stat Cards ── */
.stat-card {
  background: var(--card); border-radius: 1rem; padding: 1.25rem;
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.04), 0 4px 16px oklch(0.2 0.02 25 / 0.04);
}
.stat-icon { width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; display: flex; align-items: center; justify-content: center; margin-bottom: 0.875rem; }
.stat-icon svg, .stat-icon i { width: 1.25rem; height: 1.25rem; }
.stat-label { font-size: 0.8125rem; font-weight: 500; color: var(--muted-foreground); margin-bottom: 0.25rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.stat-sub { font-size: 0.8125rem; color: var(--muted-foreground); margin-top: 0.25rem; }

/* ── Icon Tile Colors ── */
.tile-primary { background: oklch(0.5 0.19 25 / 0.1); color: var(--primary); }
.tile-red     { background: #fee2e2; color: #dc2626; }
.tile-amber   { background: #fef3c7; color: #d97706; }
.tile-emerald { background: #d1fae5; color: #059669; }
.tile-blue    { background: #dbeafe; color: #2563eb; }
.tile-purple  { background: #ede9fe; color: #7c3aed; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.125rem 0.5rem; border-radius: 9999px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge svg, .badge i { width: 0.75rem; height: 0.75rem; }
.badge-primary  { background: oklch(0.5 0.19 25 / 0.1); color: var(--primary); }
.badge-red      { background: #fee2e2; color: #991b1b; }
.badge-amber    { background: #fef3c7; color: #92400e; }
.badge-emerald  { background: #d1fae5; color: #065f46; }
.badge-blue     { background: #dbeafe; color: #1e40af; }
.badge-gray     { background: var(--muted); color: var(--muted-foreground); }
.badge-outline  { background: transparent; border: 1px solid var(--border); color: var(--foreground); }

/* ── Alert / Notice ── */
.alert { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.875rem 1rem; border-radius: var(--radius); font-size: 0.875rem; }
.alert-error   { background: oklch(0.577 0.245 27 / 0.08); border: 1px solid oklch(0.577 0.245 27 / 0.25); color: var(--destructive); }
.alert-success { background: #d1fae5; border: 1px solid #6ee7b7; color: #065f46; }
.alert-warning { background: #fef3c7; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #dbeafe; border: 1px solid #93c5fd; color: #1e40af; }

/* ── Tables ── */
.table-wrap {
  overflow: hidden; border-radius: 0.875rem;
  border: 1px solid oklch(0.9 0.01 85 / 0.6); background: var(--card);
}
.table-toolbar {
  padding: 1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}
.search-input-wrap { position: relative; flex: 1; min-width: 12rem; }
.search-input-wrap i, .search-input-wrap svg {
  position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
  width: 1rem; height: 1rem; color: var(--muted-foreground); pointer-events: none;
}
.search-input { padding-left: 2.25rem !important; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--muted); }
th { padding: 0.6875rem 0.75rem; text-align: left; font-size: 0.8125rem; font-weight: 500; color: var(--muted-foreground); white-space: nowrap; }
td { padding: 0.8125rem 0.75rem; font-size: 0.9375rem; border-top: 1px solid oklch(0.9 0.01 85 / 0.4); vertical-align: middle; }
tr:hover td { background: oklch(0.955 0.01 85 / 0.35); }
.table-empty { text-align: center; padding: 3rem 1rem; color: var(--muted-foreground); font-size: 0.875rem; }

/* ── Page Layout ── */
.page-wrap { margin: 0 auto; max-width: 72rem; padding: 1.5rem; }
@media (min-width: 1024px) { .page-wrap { padding: 2rem; } }
.page-header { margin-bottom: 1.5rem; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-header-text {}
.page-title { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
@media (min-width: 640px) { .page-title { font-size: 2rem; } }
.page-subtitle { font-size: 0.875rem; color: var(--muted-foreground); margin-top: 0.375rem; max-width: 36rem; }
.section-title { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.875rem; }

/* ── Stats Grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stats-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
@media (max-width: 640px) { .stats-grid-3 { grid-template-columns: 1fr; } }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none; }
.toast {
  padding: 0.875rem 1.125rem; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 500; pointer-events: all;
  box-shadow: 0 4px 16px oklch(0 0 0 / 0.12); min-width: 16rem; max-width: 22rem;
  animation: toast-in 0.2s ease;
}
.toast-success { background: #065f46; color: white; }
.toast-error   { background: var(--destructive); color: var(--destructive-foreground); }
.toast-info    { background: var(--card); color: var(--foreground); border: 1px solid var(--border); }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: translateY(0); } }

/* ── Mobile Nav ── */
.mobile-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; background: rgba(255,255,255,0.92);
  border-top: 1px solid var(--border); backdrop-filter: blur(16px);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
@media (min-width: 1024px) { .mobile-nav { display: none; } }
.mobile-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0.625rem 0; gap: 0.2rem; font-size: 0.6875rem; font-weight: 500;
  color: var(--muted-foreground); text-decoration: none; transition: color 0.15s;
}
.mobile-nav-item.active { color: var(--primary); }
.mobile-nav-item svg, .mobile-nav-item i { width: 1.375rem; height: 1.375rem; }

/* ── Loading ── */
.loading-overlay {
  position: fixed; inset: 0; background: var(--background);
  display: flex; align-items: center; justify-content: center; z-index: 9998;
}
.spinner {
  width: 2rem; height: 2rem; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Dialog / Modal ── */
.dialog-overlay {
  position: fixed; inset: 0; background: oklch(0 0 0 / 0.5);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.dialog {
  background: var(--card); border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.25rem); padding: 1.5rem;
  width: 100%; max-width: 30rem;
  box-shadow: 0 8px 32px oklch(0 0 0 / 0.15);
  max-height: 90vh; overflow-y: auto;
}
.dialog-title { font-size: 1.0625rem; font-weight: 600; margin-bottom: 0.375rem; }
.dialog-description { font-size: 0.875rem; color: var(--muted-foreground); margin-bottom: 1.25rem; }
.dialog-footer { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.25rem; flex-wrap: wrap; }

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: 3rem 1.5rem; color: var(--muted-foreground);
  border: 1px dashed oklch(0.9 0.01 85 / 0.8); border-radius: 0.875rem;
}
.empty-state i, .empty-state svg { width: 2.5rem; height: 2.5rem; margin: 0 auto 0.75rem; opacity: 0.35; display: block; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--foreground); margin-bottom: 0.375rem; }

/* ── Avatar ── */
.avatar {
  width: 2.25rem; height: 2.25rem; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: var(--primary-foreground);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8125rem; font-weight: 700;
}
.avatar-sm { width: 1.75rem; height: 1.75rem; font-size: 0.6875rem; }
.avatar-lg { width: 3rem; height: 3rem; font-size: 1rem; }

/* ── Utilities ── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.text-sm   { font-size: 0.875rem; }
.text-xs   { font-size: 0.75rem; }
.text-lg   { font-size: 1.0625rem; }
.text-muted { color: var(--muted-foreground); }
.text-primary { color: var(--primary); }
.text-destructive { color: var(--destructive); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.spacer { flex: 1; }

/* ── Collapsible rows ── */
.collapse-row { display: none; }
.collapse-row.open { display: table-row; }
.collapse-content { background: var(--muted); padding: 1rem 0.75rem !important; }

/* ── Status dots ── */
.status-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; flex-shrink: 0; }
.status-dot.green  { background: #10b981; }
.status-dot.amber  { background: #f59e0b; }
.status-dot.red    { background: #ef4444; }
.status-dot.gray   { background: #9ca3af; }
