/* ═══════════════════════════════════════════
   SplitEven Admin Panel — Global Stylesheet
   ═══════════════════════════════════════════ */

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

:root {
  --primary:       #6366F1;
  --primary-dark:  #4F46E5;
  --primary-light: #EEF2FF;
  --secondary:     #8B5CF6;
  --sidebar-bg:    #0F172A;
  --sidebar-hover: #1E293B;
  --bg:            #F8FAFC;
  --surface:       #FFFFFF;
  --border:        #E2E8F0;
  --text:          #1E293B;
  --text-muted:    #64748B;
  --success:       #10B981;
  --success-bg:    #ECFDF5;
  --warning:       #F59E0B;
  --warning-bg:    #FFFBEB;
  --danger:        #EF4444;
  --danger-bg:     #FEF2F2;
  --info:          #3B82F6;
  --info-bg:       #EFF6FF;
  --sidebar-w:     240px;
  --header-h:      64px;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md:     0 4px 12px rgba(0,0,0,.10), 0 8px 32px rgba(0,0,0,.06);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}

/* ── Login ─────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1E1B4B 0%, #312E81 50%, #4F46E5 100%);
}
.login-card {
  background: white;
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo h1 { font-size: 1.75rem; font-weight: 800; color: var(--primary); }
.login-logo p  { color: var(--text-muted); font-size: .875rem; margin-top: .2rem; }
.login-logo .shield { font-size: 2.5rem; margin-bottom: .5rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .4rem; }
.form-group input {
  width: 100%; padding: .75rem 1rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .9rem; font-family: inherit; outline: none; transition: border-color .2s;
}
.form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.btn-login {
  width: 100%; padding: .875rem;
  background: var(--primary); color: white;
  border: none; border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 600; cursor: pointer;
  transition: background .2s, transform .1s; font-family: inherit;
}
.btn-login:hover  { background: var(--primary-dark); }
.btn-login:active { transform: scale(.99); }
.login-error {
  background: var(--danger-bg); color: var(--danger);
  padding: .75rem 1rem; border-radius: var(--radius-sm);
  font-size: .875rem; margin-top: 1rem; display: none;
}

/* ── Layout ────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column; z-index: 100; overflow-y: auto;
}
.sidebar-logo {
  padding: 1.4rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo h2  { color: white; font-size: 1.2rem; font-weight: 800; }
.sidebar-logo h2 span { color: var(--primary); }
.sidebar-logo p   { color: rgba(255,255,255,.35); font-size: .72rem; margin-top: .15rem; }
.sidebar-nav      { flex: 1; padding: 1rem 0; }
.nav-section      { padding: 0 .75rem; margin-bottom: 1.5rem; }
.nav-section-title {
  color: rgba(255,255,255,.3); font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  padding: 0 .5rem; margin-bottom: .5rem;
}
.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .75rem; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6); text-decoration: none;
  font-weight: 500; font-size: .875rem; transition: all .2s; margin-bottom: 2px;
}
.nav-item:hover  { background: var(--sidebar-hover); color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-icon { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-footer {
  padding: .875rem .75rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.btn-logout {
  display: flex; align-items: center; gap: .75rem;
  width: 100%; padding: .6rem .75rem; border-radius: var(--radius-sm);
  background: none; border: none; color: rgba(255,255,255,.45);
  font-size: .875rem; font-weight: 500; cursor: pointer;
  transition: all .2s; font-family: inherit;
}
.btn-logout:hover { background: rgba(239,68,68,.15); color: #EF4444; }

/* ── Main ──────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }
.page-header {
  background: white; border-bottom: 1px solid var(--border);
  padding: 0 2rem; height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.page-header h1 { font-size: 1.15rem; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: .75rem; }
.header-badge {
  background: var(--primary-light); color: var(--primary);
  font-size: .72rem; font-weight: 700; padding: .25rem .75rem; border-radius: 100px;
}
.page-body { padding: 2rem; }

/* ── Stat Cards ────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.1rem; margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.si-indigo { background: var(--primary-light); }
.si-green  { background: var(--success-bg); }
.si-amber  { background: var(--warning-bg); }
.si-red    { background: var(--danger-bg); }
.si-blue   { background: var(--info-bg); }
.si-purple { background: #F5F3FF; }
.si-teal   { background: #F0FDFA; }
.si-pink   { background: #FDF2F8; }
.stat-value { font-size: 1.55rem; font-weight: 800; line-height: 1.15; }
.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; margin-top: .1rem; }

/* ── Cards ─────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem;
}
.card-header h2 { font-size: .95rem; font-weight: 700; }
.card-body { padding: 1.5rem; }

/* ── Charts Grid ───────────────────────────── */
.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 1.1rem; margin-bottom: 2rem; }
.chart-wrap { position: relative; height: 260px; }

/* ── Filters ───────────────────────────────── */
.filters-bar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .875rem 1.5rem; border-bottom: 1px solid var(--border);
  background: #FAFAFA;
}
.filter-input, .filter-select {
  padding: .45rem .75rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .875rem; font-family: inherit;
  background: white; color: var(--text); outline: none; transition: border-color .2s;
}
.filter-input:focus, .filter-select:focus { border-color: var(--primary); }
.filter-input { min-width: 200px; }
.filter-label { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.btn-clear {
  padding: .45rem .875rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .8rem; font-weight: 600;
  background: white; cursor: pointer; color: var(--text-muted);
  transition: all .2s; font-family: inherit;
}
.btn-clear:hover { border-color: var(--danger); color: var(--danger); }

/* ── Table ─────────────────────────────────── */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--bg); padding: .7rem 1rem; text-align: left;
  font-weight: 700; color: var(--text-muted); font-size: .75rem;
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s; cursor: pointer;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #F8FAFC; }
tbody td { padding: .8rem 1rem; color: var(--text); vertical-align: middle; }
.uid-cell {
  font-family: 'Courier New', monospace; font-size: .78rem; color: var(--text-muted);
  background: var(--bg); padding: .2rem .45rem; border-radius: 4px; display: inline-block;
}

/* ── Badges ────────────────────────────────── */
.badge {
  display: inline-block; padding: .22rem .6rem; border-radius: 100px;
  font-size: .72rem; font-weight: 700; white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: #065F46; }
.badge-warning { background: var(--warning-bg); color: #92400E; }
.badge-danger  { background: var(--danger-bg);  color: #991B1B; }
.badge-info    { background: var(--info-bg);    color: #1E40AF; }
.badge-purple  { background: #F5F3FF; color: #5B21B6; }
.badge-gray    { background: #F1F5F9; color: #475569; }
.scan-ai     { background: #EEF2FF; color: #3730A3; }
.scan-manual { background: #F0FDF4; color: #14532D; }

/* ── Pagination ────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: .875rem 1.5rem; border-top: 1px solid var(--border);
  font-size: .85rem; color: var(--text-muted);
}
.pagination-btns { display: flex; gap: .4rem; }
.btn-page {
  padding: .35rem .8rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: white; font-size: .8rem; cursor: pointer; transition: all .2s;
  font-family: inherit; color: var(--text);
}
.btn-page:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-page.active { background: var(--primary); border-color: var(--primary); color: white; }
.btn-page:disabled { opacity: .4; cursor: not-allowed; }

/* ── Modal ─────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  z-index: 1000; display: none; align-items: flex-start;
  justify-content: center; padding: 2rem 1rem; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: 16px; width: 100%; max-width: 720px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); margin: auto;
}
.modal-header {
  padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: white; z-index: 1; border-radius: 16px 16px 0 0;
}
.modal-header h3 { font-size: .95rem; font-weight: 700; }
.btn-close {
  background: none; border: none; font-size: 1.25rem; cursor: pointer;
  color: var(--text-muted); padding: .2rem; border-radius: 6px;
  line-height: 1; transition: color .2s;
}
.btn-close:hover { color: var(--danger); }
.modal-body { padding: 1.5rem; max-height: 80vh; overflow-y: auto; }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1.5rem;
}
.detail-field {
  background: var(--bg); border-radius: var(--radius-sm); padding: .7rem .875rem;
}
.detail-field label {
  display: block; font-size: .7rem; color: var(--text-muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: .25rem;
}
.detail-field span { font-size: .875rem; font-weight: 500; word-break: break-all; }
.detail-section-title {
  font-size: .875rem; font-weight: 700; margin: 1.25rem 0 .75rem;
  padding-bottom: .4rem; border-bottom: 1px solid var(--border);
}
.items-list { display: flex; flex-direction: column; gap: .4rem; }
.item-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .5rem .75rem; background: var(--bg); border-radius: var(--radius-sm);
  font-size: .85rem;
}
.item-row .item-name { font-weight: 500; }
.item-row .item-price { font-weight: 700; color: var(--primary); }

/* ── Rating Stars ──────────────────────────── */
.stars-filled { color: #F59E0B; }
.stars-empty  { color: #CBD5E1; }
.rating-bar-wrap { display: flex; align-items: center; gap: .75rem; }
.rating-bar-track {
  flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.rating-bar-fill { height: 100%; background: #F59E0B; border-radius: 3px; }

/* ── Loading / Empty ───────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 3rem; gap: .75rem; color: var(--text-muted); font-size: .875rem;
}
.spinner {
  width: 20px; height: 20px; border: 2.5px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state p { font-size: .875rem; }

/* ── Confidence ────────────────────────────── */
.conf-high { color: #065F46; font-weight: 700; }
.conf-med  { color: #92400E; font-weight: 700; }
.conf-low  { color: #991B1B; font-weight: 700; }

/* ── Activity Feed ─────────────────────────── */
.activity-item {
  display: flex; align-items: center; gap: .875rem;
  padding: .7rem 0; border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); flex-shrink: 0;
}
.activity-dot.success { background: var(--success); }
.activity-dot.failed  { background: var(--danger); }
.activity-meta { flex: 1; }
.activity-title { font-weight: 600; font-size: .875rem; }
.activity-sub   { font-size: .78rem; color: var(--text-muted); }
.activity-time  { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }

/* ── Misc Utility ──────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.flex-row { display: flex; align-items: center; gap: .5rem; }
.w-full { width: 100%; }
.inline-stat {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 100px; padding: .3rem .875rem;
  font-size: .8rem; font-weight: 600;
}
