/* =====================================================
   A'HAY FRIED CHICKEN - Performance Evaluation System
   Design: Restaurant operations dashboard with balanced brand color
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  --primary: #E8470A;
  --primary-dark: #B53307;
  --primary-light: #FF6B35;
  --accent: #F8B84E;
  --accent2: #EEF7F6;
  --dark: #111827;
  --dark2: #1F2937;
  --surface: #FFFFFF;
  --surface2: #F6F8FB;
  --surface3: #EEF2F7;
  --border: #DDE3EC;
  --text: #172033;
  --text2: #475569;
  --text3: #64748B;
  --success: #22C55E;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #3B82F6;
  --sidebar-w: 270px;
  --header-h: 70px;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(15,23,42,0.08);
  --shadow-md: 0 8px 32px rgba(15,23,42,0.12);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  background: #F3F6FA;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ---- SIDEBAR ---- */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--dark);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-icon {
  width: 44px; height: 44px;
  background: var(--primary);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(232,71,10,0.4);
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: 'Sora', sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.3px;
}

.brand-text span {
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar-period {
  margin: 0 16px 0;
  padding: 10px 14px;
  background: rgba(232,71,10,0.12);
  border-radius: 10px;
  border: 1px solid rgba(232,71,10,0.2);
  text-align: center;
  margin-top: 14px;
}

.sidebar-period span {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(255,255,255,0.55);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 16px rgba(232,71,10,0.35);
}

.nav-item .nav-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  flex-shrink: 0;
}

.nav-item.active .nav-icon {
  background: rgba(255,255,255,0.2);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-footer p {
  font-size: 11px;
  color: rgba(255,255,255,0.25);
  text-align: center;
}

/* ---- MAIN LAYOUT ---- */
#main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- TOPBAR ---- */
#topbar {
  position: sticky;
  top: 0; z-index: 900;
  height: var(--header-h);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
}

.topbar-title {
  flex: 1;
}

.topbar-title h2 {
  font-family: 'Sora', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.topbar-title p {
  font-size: 12px;
  color: var(--text3);
  margin-top: 1px;
}

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

#sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  font-size: 20px;
  color: var(--text2);
}

/* ---- PAGE CONTENT ---- */
#page-content {
  flex: 1;
  padding: 28px;
}

/* ---- CARDS ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-header h3 {
  font-family: 'Sora', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 22px;
}

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
}

.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.info::before { background: var(--info); }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
  background: var(--accent2);
}

.stat-card.success .stat-icon { background: #F0FDF4; }
.stat-card.warning .stat-icon { background: #FFFBEB; }
.stat-card.danger .stat-icon { background: #FEF2F2; }
.stat-card.info .stat-icon { background: #EFF6FF; }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value {
  font-family: 'Sora', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.stat-sub {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-up { background: #DCFCE7; color: #166534; }
.badge-down { background: #FEE2E2; color: #991B1B; }
.badge-flat { background: #F3F4F6; color: #4B5563; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info { background: #DBEAFE; color: #1E40AF; }
.badge-primary { background: #FFF0E6; color: var(--primary); }
.badge-area { 
  background: var(--dark); 
  color: #fff; 
  font-size: 10px;
  padding: 2px 7px;
}

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

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

.ahay-table thead th {
  background: var(--dark);
  color: rgba(255,255,255,0.85);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.ahay-table thead th:first-child { border-radius: 8px 0 0 0; }
.ahay-table thead th:last-child { border-radius: 0 8px 0 0; }

.ahay-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.ahay-table tbody tr:hover { background: var(--surface2); }
.ahay-table tbody tr:last-child { border-bottom: none; }

.ahay-table tbody td {
  padding: 12px 14px;
  color: var(--text);
  vertical-align: middle;
}

.ahay-table tbody tr.area-separator td {
  background: var(--dark2);
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 14px;
}

.ahay-table tfoot td {
  background: var(--surface3);
  font-weight: 700;
  padding: 12px 14px;
  border-top: 2px solid var(--primary);
  color: var(--text);
}

/* ---- RANK BADGES ---- */
.rank-1 { background: linear-gradient(135deg, #FFD700, #FFA500); color: #000; border-radius: 50%; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; box-shadow: 0 2px 8px rgba(255,165,0,0.4); }
.rank-2 { background: linear-gradient(135deg, #C0C0C0, #A8A8A8); color: #000; border-radius: 50%; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.rank-3 { background: linear-gradient(135deg, #CD7F32, #A0522D); color: #fff; border-radius: 50%; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.rank-n { background: var(--surface3); color: var(--text2); border-radius: 50%; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }

/* ---- FORMS ---- */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,71,10,0.12);
}

.form-control::placeholder { color: var(--text3); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 12px rgba(232,71,10,0.3);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-dark {
  background: var(--dark);
  color: #fff;
}
.btn-dark:hover { background: var(--dark2); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--accent2); }

.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-xs { padding: 4px 9px; font-size: 11px; border-radius: 6px; }

/* ---- GRID ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ---- CHART CONTAINER ---- */
.chart-box {
  position: relative;
  height: 280px;
}

/* ---- PROGRESS BARS ---- */
.progress-bar-wrap {
  width: 100%;
  background: var(--border);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--primary);
  transition: width 0.6s ease;
}

.progress-bar-fill.success { background: var(--success); }
.progress-bar-fill.danger { background: var(--danger); }
.progress-bar-fill.warning { background: var(--warning); }

/* ---- OUTLET DETAIL ---- */
.outlet-header {
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark2) 100%);
  border-radius: var(--radius);
  padding: 28px;
  color: #fff;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}

.outlet-header::before {
  content: '🍗';
  position: absolute;
  right: 28px; top: 50%;
  transform: translateY(-50%);
  font-size: 80px;
  opacity: 0.08;
}

.outlet-header h2 {
  font-family: 'Sora', sans-serif;
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}

.kpi-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.kpi-item {
  flex: 1;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.kpi-val-feb { font-size: 15px; font-weight: 700; color: var(--info); }
.kpi-val-mar { font-size: 15px; font-weight: 700; color: var(--primary); }
.kpi-compare { font-size: 12px; margin-top: 4px; }

/* ---- MODAL ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border-radius: 18px;
  width: min(680px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 {
  font-family: 'Sora', sans-serif;
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--surface3);
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  transition: background 0.2s;
}

.modal-close:hover { background: #FEE2E2; color: var(--danger); }

.modal-body { padding: 26px; }
.modal-footer { padding: 16px 26px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- TABS ---- */
.tab-nav {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  padding: 9px 18px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 8px 8px 0 0;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text); background: var(--surface2); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---- SEARCH / FILTER ---- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.filter-bar input, .filter-bar select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
  outline: none;
  transition: border-color 0.2s;
}

.filter-bar input:focus, .filter-bar select:focus {
  border-color: var(--primary);
}

/* ---- ALERT ---- */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.alert-danger { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }

/* ---- SPV EVAL ---- */
.score-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: var(--border);
  outline: none;
}

.score-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(232,71,10,0.4);
}

/* ---- PRINT ---- */
@media print {
  #sidebar, #topbar, .btn, .filter-bar, .topbar-actions { display: none !important; }
  #main { margin-left: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  body { background: #fff; }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  :root { --sidebar-w: 260px; }
  
  #sidebar {
    transform: translateX(-100%);
  }
  
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,0.3);
  }
  
  #main { margin-left: 0; }
  
  #sidebar-toggle { display: flex; }
  
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  
  #page-content { padding: 16px; }
  
  .kpi-row { flex-direction: column; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ---- LOADING ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---- EMPTY STATE ---- */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text3);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h4 { font-size: 16px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ---- TOOLTIP ---- */
[data-tip] { position: relative; cursor: help; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 110%; left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: #fff;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
}
[data-tip]:hover::after { opacity: 1; }

/* ---- NOTIFICATIONS ---- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}
