/* ═══════════════════════════════════════════════════════════
   KASVA WEB — Shared Stylesheet
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary:        #6C63FF;
  --primary-dark:   #5A52E0;
  --primary-light:  #EEF0FF;
  --primary-soft:   #F5F4FF;
  --success:        #22C55E;
  --success-light:  #DCFCE7;
  --danger:         #EF4444;
  --danger-light:   #FEF2F2;
  --warning:        #F59E0B;
  --warning-light:  #FEF9EC;
  --info:           #3B82F6;
  --info-light:     #EFF6FF;
  --text:           #1A1A2E;
  --text-secondary: #64647A;
  --text-muted:     #9999B0;
  --border:         #E8E8F0;
  --bg:             #F5F5FA;
  --bg-card:        #FFFFFF;
  --sidebar-w:      240px;
  --header-h:       64px;
  --radius:         12px;
  --radius-lg:      16px;
  --shadow:         0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md:      0 4px 24px rgba(108,99,255,.12);
}

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

html { font-size: 15px; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page-body {
  padding: 24px;
  flex: 1;
}

/* ── Sidebar ──────────────────────────────────────────────── */
/* ── Sidebar dark purple theme ── */
:root {
  --sidebar-bg:        #2D1B69;
  --sidebar-bg-hover:  rgba(255,255,255,.07);
  --sidebar-bg-active: rgba(255,255,255,.13);
  --sidebar-border:    rgba(255,255,255,.08);
  --sidebar-text:      rgba(255,255,255,.65);
  --sidebar-text-active: #fff;
  --sidebar-accent:    #A78BFA;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: none;
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(45,27,105,.25);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

/* Logo PNG */
.sidebar-logo-img {
  height: 32px;
  width: auto;
  max-width: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Fallback emoji */
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}

.sidebar-logo-text { font-size: 16px; font-weight: 800; color: #fff; }
.sidebar-logo-text span { color: var(--sidebar-accent); }

.sidebar-store {
  padding: 12px 20px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-store-name {
  font-size: 13px; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-store-sub {
  font-size: 11px; color: rgba(255,255,255,.4); margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(255,255,255,.3);
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  font-size: 13px; font-weight: 500;
  color: var(--sidebar-text);
  border-radius: 0;
  transition: all .15s;
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-bg-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
  font-weight: 700;
}

.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; background: var(--sidebar-accent);
  border-radius: 0 4px 4px 0;
}

.nav-item-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: currentColor;
}

.nav-item-icon svg {
  width: 18px; height: 18px;
  display: block;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-upgrade {
  background: rgba(255,255,255,.08);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  margin-bottom: 10px;
}

.sidebar-upgrade-icon { font-size: 20px; margin-bottom: 4px; }
.sidebar-upgrade-title { font-size: 12px; font-weight: 700; color: #fff; }
.sidebar-upgrade-desc { font-size: 11px; color: rgba(255,255,255,.5); margin: 4px 0 10px; }

.btn-upgrade {
  width: 100%;
  background: var(--sidebar-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
}

.btn-logout {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: none;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius);
  font-size: 13px; color: rgba(255,255,255,.55);
  transition: all .15s;
}

.btn-logout:hover {
  background: rgba(239,68,68,.2);
  color: #FCA5A5;
  border-color: rgba(239,68,68,.4);
}

.btn-logout svg { flex-shrink: 0; }



/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-title { flex: 1; }
.topbar-title h1 { font-size: 17px; font-weight: 800; color: var(--text); }
.topbar-title p  { font-size: 12px; color: var(--text-muted); }

.topbar-search {
  display: flex; align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0 14px; gap: 8px;
  width: 280px;
}

.topbar-search input {
  border: none; background: none; outline: none;
  font-size: 13px; color: var(--text);
  padding: 9px 0; width: 100%;
}

.topbar-search-icon { color: var(--text-muted); font-size: 14px; }

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

.topbar-btn {
  width: 36px; height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--text-secondary);
  position: relative; transition: all .15s;
}

.topbar-btn:hover { background: var(--primary-light); color: var(--primary); }

.notif-badge {
  position: absolute; top: -2px; right: -2px;
  width: 16px; height: 16px;
  background: var(--danger);
  border-radius: 50%;
  font-size: 9px; font-weight: 700; color: white;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
}

.topbar-profile {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  transition: all .15s;
}

.topbar-profile:hover { background: var(--primary-soft); }

.topbar-avatar {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
}

.topbar-profile-name { font-size: 13px; font-weight: 600; }
.topbar-profile-role { font-size: 10px; color: var(--text-muted); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 14px; font-weight: 700; color: var(--text);
}

.card-body { padding: 20px; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 12px;
  flex-shrink: 0;
}

.stat-card-icon svg {
  width: 20px; height: 20px;
  display: block;
}

.stat-card-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-card-value { font-size: 20px; font-weight: 800; color: var(--text); }

.stat-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 100px;
  margin-top: 6px;
}

.stat-badge.up   { background: var(--success-light); color: var(--success); }
.stat-badge.down { background: var(--danger-light);  color: var(--danger);  }

/* ── Table ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 10px 14px;
  background: var(--bg);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--primary-soft); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 100px;
  font-size: 11px; font-weight: 600;
}

.badge-success  { background: var(--success-light); color: var(--success); }
.badge-danger   { background: var(--danger-light);  color: var(--danger);  }
.badge-warning  { background: var(--warning-light); color: var(--warning); }
.badge-info     { background: var(--info-light);    color: var(--info);    }
.badge-primary  { background: var(--primary-light); color: var(--primary); }
.badge-muted    { background: var(--bg);            color: var(--text-muted); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  border: none; transition: all .15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600; color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px; color: var(--text);
  background: var(--bg-card);
  outline: none; transition: border .15s;
}

.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,99,255,.1); }

select.form-control { cursor: pointer; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(16px);
  transition: transform .2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 15px; font-weight: 700; }

.modal-close {
  width: 28px; height: 28px;
  border: none; background: var(--bg);
  border-radius: 50%; font-size: 14px;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
}

.modal-close:hover { background: var(--danger-light); color: var(--danger); }
.modal-body    { padding: 20px; }
.modal-footer  { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; align-items: center; gap: 10px;
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  z-index: 999;
  opacity: 0; transform: translateY(8px);
  transition: all .25s;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-icon    { font-size: 14px; }

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}

.page-header-title { font-size: 18px; font-weight: 800; }
.page-header-sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state-title { font-size: 15px; font-weight: 700; color: var(--text-secondary); }
.empty-state-desc  { font-size: 13px; margin-top: 4px; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 16px 0;
}

.page-btn {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px;
  background: none; color: var(--text-secondary);
  transition: all .15s;
}

.page-btn:hover, .page-btn.active {
  background: var(--primary); color: white; border-color: var(--primary);
}

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6C63FF 0%, #8B5CF6 100%);
  padding: 24px;
}

.login-card {
  background: white;
  border-radius: 24px;
  padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}

.login-logo {
  text-align: center; margin-bottom: 28px;
}

.login-logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #6C63FF, #8B5CF6);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 12px;
}

.login-logo h1 { font-size: 22px; font-weight: 800; }
.login-logo h1 span { color: var(--primary); }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar-search { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 16px; }
}