/* ==========================================================================
   Clickza — Design System
   Apple iOS-inspired glassmorphism, premium blue accent
   ========================================================================== */

:root{
  --bg:            #F4F6F9;
  --bg-alt:        #FFFFFF;
  --surface:       rgba(255,255,255,0.72);
  --surface-solid: #FFFFFF;
  --border:        rgba(15,23,42,0.06);
  --text:          #14151A;
  --text-dim:      #6B7280;
  --text-faint:    #9CA3AF;

  --accent:        #0A84FF;
  --accent-dim:    #3AA0FF;
  --accent-soft:   rgba(10,132,255,0.10);
  --accent-grad:   linear-gradient(135deg,#0A84FF 0%,#5AC8FA 100%);

  --success:       #22C55E;
  --success-soft:  rgba(34,197,94,0.12);
  --warning:       #FF9F0A;
  --warning-soft:  rgba(255,159,10,0.14);
  --danger:        #FF3B30;
  --danger-soft:   rgba(255,59,48,0.12);

  --radius-sm: 12px;
  --radius:    18px;
  --radius-lg: 26px;
  --radius-xl: 32px;

  --shadow-sm: 0 2px 10px rgba(20,21,26,0.04);
  --shadow:    0 8px 30px rgba(20,21,26,0.07);
  --shadow-lg: 0 20px 60px rgba(20,21,26,0.12);

  --blur: 24px;
  --font-display: -apple-system, "SF Pro Display", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-body: -apple-system, "SF Pro Text", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Roboto Mono", monospace;

  --sidebar-w: 244px;
  --header-h: 72px;
  --transition: 200ms cubic-bezier(.4,0,.2,1);
}

html.dark{
  --bg:            #0A0A0D;
  --bg-alt:        #101014;
  --surface:       rgba(28,28,32,0.62);
  --surface-solid: #16161B;
  --border:        rgba(255,255,255,0.08);
  --text:          #F5F5F7;
  --text-dim:      #A1A1A8;
  --text-faint:    #6E6E76;
  --accent-soft:   rgba(10,132,255,0.18);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.25);
  --shadow:    0 8px 30px rgba(0,0,0,0.35);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.5);
}

*{ box-sizing:border-box; margin:0; padding:0; }
html{ -webkit-text-size-adjust:100%; }
body{
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}
a{ color:inherit; text-decoration:none; }
button{ font-family:inherit; cursor:pointer; }
input, select, textarea{ font-family:inherit; }
::selection{ background: var(--accent-soft); }

/* Scrollbars */
::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-thumb{ background: rgba(120,120,130,0.35); border-radius:8px; }
::-webkit-scrollbar-track{ background:transparent; }

/* ---------------- Glass surface ---------------- */
.glass{
  background: var(--surface);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  border: 1px solid var(--border);
}

.card{
  background: var(--surface);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover{ box-shadow: var(--shadow); }

/* ---------------- Layout shell ---------------- */
.app-shell{ display:flex; min-height:100vh; }

.sidebar{
  width: var(--sidebar-w);
  flex-shrink:0;
  position: fixed;
  top:0; left:0; bottom:0;
  padding: 28px 16px;
  display:flex; flex-direction:column; gap:6px;
  z-index: 40;
  border-right: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  transform: translateX(0);
  transition: transform var(--transition);
}
.sidebar-brand{
  display:flex; align-items:center; gap:10px;
  padding: 6px 12px 22px 12px;
}
.sidebar-brand .logo-dot{
  width:34px; height:34px; border-radius:10px;
  background: var(--accent-grad);
  display:flex; align-items:center; justify-content:center;
  color:#fff; font-family:var(--font-display); font-weight:700; font-size:16px;
  box-shadow: 0 4px 14px rgba(10,132,255,0.35);
}
.sidebar-brand span{ font-family:var(--font-display); font-weight:700; font-size:19px; letter-spacing:-0.02em; }

.nav-group-label{
  font-size:11px; font-weight:700; letter-spacing:0.08em; text-transform:uppercase;
  color: var(--text-faint); padding: 16px 12px 6px;
}
.nav-link{
  display:flex; align-items:center; gap:12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 14.5px; font-weight:560;
  transition: background var(--transition), color var(--transition);
}
.nav-link svg{ width:19px; height:19px; flex-shrink:0; }
.nav-link:hover{ background: rgba(120,120,130,0.08); color: var(--text); }
.nav-link.active{
  background: var(--accent-soft);
  color: var(--accent);
  font-weight:650;
}
.sidebar-footer{ margin-top:auto; padding-top:14px; border-top:1px solid var(--border); }

.main{
  margin-left: var(--sidebar-w);
  flex:1; min-width:0;
  padding: 26px 32px 100px;
}

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  gap:16px; margin-bottom:26px; flex-wrap:wrap;
}
.page-title{ font-family: var(--font-display); font-size:26px; font-weight:700; letter-spacing:-0.02em; }
.page-sub{ color:var(--text-dim); font-size:13.5px; margin-top:2px; }

.topbar-actions{ display:flex; align-items:center; gap:10px; }

.icon-btn{
  width:40px; height:40px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  background: var(--surface); border:1px solid var(--border);
  color: var(--text-dim);
  transition: all var(--transition);
}
.icon-btn:hover{ color:var(--accent); border-color: var(--accent-soft); }
.icon-btn svg{ width:18px; height:18px; }

.avatar{
  width:38px; height:38px; border-radius:50%;
  background: var(--accent-grad); color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:14px; font-family:var(--font-display);
}

/* ---------------- Buttons ---------------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding: 11px 20px;
  border-radius: 14px;
  font-size: 14px; font-weight: 620;
  border: 1px solid transparent;
  transition: transform 120ms ease, box-shadow var(--transition), background var(--transition), opacity var(--transition);
  white-space:nowrap;
}
.btn:active{ transform: scale(0.97); }
.btn svg{ width:16px; height:16px; }
.btn-primary{
  background: var(--accent-grad); color:#fff;
  box-shadow: 0 8px 20px rgba(10,132,255,0.30);
}
.btn-primary:hover{ box-shadow: 0 10px 26px rgba(10,132,255,0.4); }
.btn-secondary{
  background: var(--surface); color:var(--text); border-color:var(--border);
}
.btn-secondary:hover{ border-color: var(--accent-dim); color:var(--accent); }
.btn-danger{ background: var(--danger-soft); color: var(--danger); }
.btn-ghost{ background:transparent; color:var(--text-dim); }
.btn-ghost:hover{ color:var(--text); background: rgba(120,120,130,0.08); }
.btn-sm{ padding:7px 13px; font-size:12.5px; border-radius:10px; }
.btn-block{ width:100%; }
.btn:disabled{ opacity:.5; cursor:not-allowed; }

/* ---------------- Forms ---------------- */
.field{ margin-bottom:18px; }
.field label{
  display:block; font-size:12.5px; font-weight:650; color:var(--text-dim);
  margin-bottom:7px; letter-spacing:0.01em;
}
.input, select.input, textarea.input{
  width:100%; padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
html.dark .input{ background: rgba(255,255,255,0.04); }
.input:focus{
  outline:none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
select.input{ appearance:none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position: right 14px center; padding-right:38px; }
textarea.input{ resize:vertical; min-height:80px; }
.field-row{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.field-hint{ font-size:12px; color:var(--text-faint); margin-top:6px; }
.checkbox-row{ display:flex; align-items:center; gap:8px; font-size:13.5px; color:var(--text-dim); }
.checkbox-row input{ width:16px; height:16px; accent-color: var(--accent); }

/* ---------------- Stat cards / grid ---------------- */
.stat-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(220px,1fr));
  gap:16px;
  margin-bottom: 28px;
}
.stat-card{
  padding: 20px 20px 18px;
  position:relative; overflow:hidden;
}
.stat-card .stat-icon{
  width:38px; height:38px; border-radius:11px;
  display:flex; align-items:center; justify-content:center;
  margin-bottom: 14px;
}
.stat-card .stat-icon svg{ width:19px; height:19px; }
.stat-label{ font-size:12.5px; color:var(--text-dim); font-weight:600; margin-bottom:6px; }
.stat-value{ font-family: var(--font-display); font-size:25px; font-weight:750; letter-spacing:-0.02em; font-variant-numeric: tabular-nums; }
.stat-delta{ font-size:11.5px; font-weight:650; margin-top:8px; display:inline-flex; align-items:center; gap:4px; }
.stat-delta.up{ color: var(--success); }
.stat-delta.down{ color: var(--danger); }

.tone-blue .stat-icon{ background: var(--accent-soft); color: var(--accent); }
.tone-green .stat-icon{ background: var(--success-soft); color: var(--success); }
.tone-orange .stat-icon{ background: var(--warning-soft); color: var(--warning); }
.tone-red .stat-icon{ background: var(--danger-soft); color: var(--danger); }
.tone-purple .stat-icon{ background: rgba(175,82,222,0.12); color:#AF52DE; }

/* ---------------- Table ---------------- */
.table-wrap{ overflow-x:auto; border-radius: var(--radius-lg); }
table.data-table{ width:100%; border-collapse:collapse; min-width:920px; }
table.data-table th{
  text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:0.06em;
  color: var(--text-faint); font-weight:700; padding: 14px 16px; border-bottom:1px solid var(--border);
  white-space:nowrap;
}
table.data-table td{
  padding: 14px 16px; font-size:13.8px; border-bottom:1px solid var(--border); white-space:nowrap;
}
table.data-table tbody tr{ transition: background var(--transition); }
table.data-table tbody tr:hover{ background: rgba(120,120,130,0.05); }
table.data-table tbody tr:last-child td{ border-bottom:none; }

.badge{
  display:inline-flex; align-items:center; gap:5px;
  padding: 4px 11px; border-radius:99px; font-size:11.5px; font-weight:700;
}
.badge::before{ content:''; width:6px; height:6px; border-radius:50%; background:currentColor; }
.badge-green{ background: var(--success-soft); color: var(--success); }
.badge-orange{ background: var(--warning-soft); color: var(--warning); }
.badge-red{ background: var(--danger-soft); color: var(--danger); }

.row-actions{ display:flex; gap:6px; }
.row-actions .icon-btn{ width:32px; height:32px; border-radius:9px; }
.row-actions .icon-btn svg{ width:15px; height:15px; }

/* ---------------- Auth pages ---------------- */
.auth-shell{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  padding:24px;
  background:
    radial-gradient(circle at 15% 15%, rgba(10,132,255,0.16), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(90,200,250,0.16), transparent 45%),
    var(--bg);
}
.auth-card{ width:100%; max-width:420px; padding: 40px 36px; border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); }
.auth-logo{ display:flex; align-items:center; gap:12px; margin-bottom:28px; justify-content:center; }
.auth-logo .logo-dot{ width:46px; height:46px; border-radius:14px; }
.auth-title{ font-family:var(--font-display); font-size:24px; font-weight:750; text-align:center; letter-spacing:-0.02em; }
.auth-sub{ text-align:center; color:var(--text-dim); font-size:13.5px; margin-top:6px; margin-bottom:26px; }
.auth-foot{ text-align:center; font-size:13.5px; color:var(--text-dim); margin-top:20px; }
.auth-error{ background: var(--danger-soft); color: var(--danger); padding:11px 14px; border-radius:12px; font-size:13px; margin-bottom:18px; }
.auth-success{ background: var(--success-soft); color: var(--success); padding:11px 14px; border-radius:12px; font-size:13px; margin-bottom:18px; }

/* ---------------- Misc ---------------- */
.section-title{ font-family:var(--font-display); font-weight:700; font-size:17px; letter-spacing:-0.01em; margin-bottom:16px; }
.flex-between{ display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.muted{ color: var(--text-dim); }
.faint{ color: var(--text-faint); }
.mt-8{ margin-top:8px;} .mt-16{ margin-top:16px;} .mt-24{ margin-top:24px;} .mb-16{ margin-bottom:16px;} .mb-24{ margin-bottom:24px;}
.grid-2{ display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.grid-3{ display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }
.empty-state{ text-align:center; padding: 60px 20px; color: var(--text-dim); }
.empty-state svg{ width:44px; height:44px; margin-bottom:14px; color:var(--text-faint); }

.toolbar{ display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-bottom:18px; }
.toolbar .input{ width:auto; }
.search-box{ position:relative; flex:1; min-width:200px; }
.search-box svg{ position:absolute; left:13px; top:50%; transform:translateY(-50%); width:16px; height:16px; color:var(--text-faint); }
.search-box input{ padding-left:38px; }

.modal-backdrop{
  position:fixed; inset:0; background:rgba(10,10,14,0.45);
  display:none; align-items:center; justify-content:center; z-index:100; padding:20px;
  backdrop-filter: blur(4px);
}
.modal-backdrop.open{ display:flex; }
.modal{
  width:100%; max-width:480px; max-height:88vh; overflow-y:auto;
  background: var(--surface-solid); border-radius: var(--radius-xl); border:1px solid var(--border);
  box-shadow: var(--shadow-lg); padding:28px;
}

.toast-stack{ position:fixed; top:20px; right:20px; z-index:200; display:flex; flex-direction:column; gap:10px; }
.toast{
  padding:13px 18px; border-radius:14px; font-size:13.5px; font-weight:600;
  background: var(--surface-solid); border:1px solid var(--border); box-shadow: var(--shadow);
  animation: slideIn 260ms ease;
  display:flex; align-items:center; gap:8px;
}
.toast.success{ color: var(--success); }
.toast.error{ color: var(--danger); }
@keyframes slideIn{ from{ opacity:0; transform: translateX(24px);} to{opacity:1; transform:translateX(0);} }

/* Mobile nav */
.mobile-topbar, .mobile-tabbar{ display:none; }

@media (max-width: 980px){
  .sidebar{ transform: translateX(-110%); }
  .sidebar.open{ transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main{ margin-left:0; padding: 90px 16px 96px; }
  .mobile-topbar{
    display:flex; align-items:center; justify-content:space-between;
    position:fixed; top:0; left:0; right:0; height:64px; padding:0 16px; z-index:50;
    background: var(--surface); backdrop-filter: blur(var(--blur));
    border-bottom:1px solid var(--border);
  }
  .mobile-tabbar{
    display:flex; justify-content:space-around; align-items:center;
    position:fixed; bottom:0; left:0; right:0; height:64px; z-index:50;
    background: var(--surface); backdrop-filter: blur(var(--blur));
    border-top:1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tabbar a{ display:flex; flex-direction:column; align-items:center; gap:3px; font-size:10px; color:var(--text-faint); font-weight:600; }
  .mobile-tabbar a svg{ width:21px; height:21px; }
  .mobile-tabbar a.active{ color: var(--accent); }
  .field-row{ grid-template-columns:1fr; }
  .grid-2{ grid-template-columns:1fr; }
  .grid-3{ grid-template-columns:1fr; }
  .sidebar-scrim{ position:fixed; inset:0; background:rgba(0,0,0,0.35); z-index:39; display:none; }
  .sidebar-scrim.open{ display:block; }
}

@media print{
  .sidebar, .mobile-topbar, .mobile-tabbar, .topbar-actions, .toolbar, .sidebar-scrim{ display:none !important; }
  .main{ margin-left:0 !important; padding:0 !important; }
  .card{ box-shadow:none !important; border:1px solid #ccc !important; }
  body{ background:#fff !important; }
}

/* Counter animation */
@keyframes countPop{ from{ opacity:0; transform: translateY(4px);} to{opacity:1; transform:translateY(0);} }
.stat-value.animate{ animation: countPop 400ms ease; }

/* Fade in cards */
.fade-in{ animation: fadeIn 420ms ease both; }
@keyframes fadeIn{ from{opacity:0; transform: translateY(8px);} to{opacity:1; transform:translateY(0);} }
