/* =============================================
   BackFeed Admin - Design System
   Brand: Navy #0f2557 | Orange #f97316 | White #ffffff
   ============================================= */

:root {
  --navy:        #0f2557;
  --navy-deep:   #091840;
  --navy-mid:    #1a3a7a;
  --navy-light:  #2a5298;
  --navy-faint:  #e8eef8;
  --orange:      #f97316;
  --orange-deep: #ea6c0b;
  --orange-faint:#fff4ec;
  --white:       #ffffff;
  --gray-50:     #f8faff;
  --gray-100:    #f1f5fd;
  --gray-200:    #e2e8f6;
  --gray-400:    #94a3b8;
  --gray-600:    #64748b;
  --gray-800:    #1e293b;
  --success:     #10b981;
  --error:       #ef4444;
  --warning:     #f59e0b;
  --sidebar-w:   260px;
  --topbar-h:    64px;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow-sm:   0 1px 3px rgba(15,37,87,.08);
  --shadow:      0 4px 16px rgba(15,37,87,.10);
  --shadow-lg:   0 8px 32px rgba(15,37,87,.14);
  --transition:  0.2s ease;
  --font-display:'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--gray-100);
  color: var(--gray-800);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============ SIDEBAR ============ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-logo {
  width: 38px; height: 38px;
  background: var(--orange);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.brand-icon {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: var(--white);
  letter-spacing: -0.5px;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.2px;
}
.brand-name em { color: var(--orange); font-style: normal; }

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

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,.35);
  padding: 16px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: var(--white);
}

.nav-item.active {
  background: var(--orange);
  color: var(--white);
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(249,115,22,.3);
}

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

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
}

.user-avatar {
  width: 34px; height: 34px;
  background: var(--orange);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: white;
  flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: rgba(255,255,255,.45); }

.logout-btn {
  color: rgba(255,255,255,.4);
  transition: color var(--transition);
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--orange); }
.logout-btn svg { width: 16px; height: 16px; display: block; }

/* ============ MAIN CONTENT ============ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
  display: none;
  background: none; border: none;
  cursor: pointer; color: var(--navy);
  padding: 6px; border-radius: 6px;
}
.sidebar-toggle svg { width: 20px; height: 20px; }

.topbar-title { flex: 1; }
.topbar-title h1 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.2;
  letter-spacing: -0.2px;
}
.topbar-subtitle {
  font-size: 12px;
  color: var(--gray-600);
  display: block;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

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

/* ============ FLASH ============ */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 28px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  animation: slideDown 0.3s ease;
}
.flash svg { width: 18px; height: 18px; flex-shrink: 0; }
.flash button { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; }
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:none; } }

/* ============ CARDS ============ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}
.card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.1px;
}
.card-body { padding: 24px; }
.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

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

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

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

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.stat-icon.orange { background: var(--orange-faint); color: var(--orange); }
.stat-icon.navy   { background: var(--navy-faint); color: var(--navy); }
.stat-icon.green  { background: #ecfdf5; color: var(--success); }
.stat-icon.yellow { background: #fffbeb; color: var(--warning); }
.stat-icon svg { width: 20px; height: 20px; }

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}
.stat-label {
  font-size: 12px;
  color: var(--gray-600);
  font-weight: 500;
}
.stat-change {
  position: absolute;
  top: 20px; right: 20px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}
.stat-change.up   { background: #ecfdf5; color: var(--success); }
.stat-change.down { background: #fef2f2; color: var(--error); }

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

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-600);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-800);
  font-size: 14px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--orange);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(249,115,22,.25);
}
.btn-primary:hover { background: var(--orange-deep); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(249,115,22,.35); }

.btn-navy {
  background: var(--navy);
  color: var(--white);
}
.btn-navy:hover { background: var(--navy-mid); }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--gray-200);
}
.btn-outline:hover { border-color: var(--navy); background: var(--navy-faint); }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--navy); }

.btn-danger {
  background: #fef2f2;
  color: var(--error);
  border: 1.5px solid #fecaca;
}
.btn-danger:hover { background: var(--error); color: var(--white); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}
.form-hint { font-size: 12px; color: var(--gray-600); margin-top: 4px; }
.form-required { color: var(--orange); margin-left: 2px; }

.form-control, .form-select, .form-textarea {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--gray-800);
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}
.form-control::placeholder { color: var(--gray-400); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-select { 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='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; }

.form-check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.form-check input[type="checkbox"], .form-check input[type="radio"] { width: 18px; height: 18px; accent-color: var(--orange); cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

.form-error { font-size: 12px; color: var(--error); margin-top: 4px; }
.form-control.is-error { border-color: var(--error); }

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 12px; }
.toggle {
  position: relative;
  width: 46px; height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--gray-200);
  border-radius: 24px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.toggle input:checked + .toggle-slider { background: var(--orange); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }
.toggle-label { font-size: 14px; font-weight: 500; color: var(--navy); }

/* ============ BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-orange  { background: var(--orange-faint); color: var(--orange); }
.badge-navy    { background: var(--navy-faint); color: var(--navy); }
.badge-green   { background: #ecfdf5; color: #065f46; }
.badge-yellow  { background: #fffbeb; color: #92400e; }
.badge-red     { background: #fef2f2; color: #991b1b; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

/* ============ PAGINATION ============ */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  padding-top: 20px;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--gray-200);
  color: var(--gray-800);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.page-link:hover { border-color: var(--orange); color: var(--orange); }
.page-link.active { background: var(--orange); border-color: var(--orange); color: white; }
.page-link.disabled { opacity: 0.4; pointer-events: none; }

/* ============ EMPTY STATE ============ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}
.empty-icon {
  width: 64px; height: 64px;
  background: var(--gray-100);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
  color: var(--gray-400);
}
.empty-icon svg { width: 32px; height: 32px; }
.empty-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 8px;
}
.empty-desc { color: var(--gray-600); font-size: 14px; margin-bottom: 24px; }

/* ============ MODALS ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(9,24,64,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(.96) translateY(8px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: none; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}
.modal-close {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: var(--gray-100);
  border-radius: 6px; cursor: pointer; color: var(--gray-600);
  font-size: 18px; line-height: 1;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--gray-200); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }

/* ============ TABS ============ */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 24px; gap: 0; }
.tab-item {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-decoration: none;
  transition: all var(--transition);
}
.tab-item:hover { color: var(--navy); }
.tab-item.active { color: var(--orange); border-bottom-color: var(--orange); font-weight: 600; }

/* ============ RATING STARS ============ */
.star { color: var(--orange); }
.star.empty { color: var(--gray-200); }

/* ============ SECTION HEADER ============ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}

/* ============ CODE BLOCK ============ */
.code-block {
  background: var(--navy-deep);
  color: #a5f3fc;
  border-radius: var(--radius);
  padding: 20px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  position: relative;
}
.code-copy {
  position: absolute;
  top: 12px; right: 12px;
}

/* ============ CHART BAR ============ */
.mini-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.mini-bar-label { font-size: 12px; color: var(--gray-600); width: 80px; flex-shrink: 0; }
.mini-bar-track { flex: 1; height: 8px; background: var(--gray-200); border-radius: 8px; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 8px; background: var(--orange); transition: width 0.8s ease; }
.mini-bar-fill.navy { background: var(--navy); }
.mini-bar-value { font-size: 12px; font-weight: 600; color: var(--navy); width: 30px; text-align: right; }

/* ============ BREADCRUMB ============ */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 20px; font-size: 13px;
}
.breadcrumb a { color: var(--gray-600); text-decoration: none; }
.breadcrumb a:hover { color: var(--orange); }
.breadcrumb-sep { color: var(--gray-400); }
.breadcrumb-current { color: var(--navy); font-weight: 500; }

/* ============ PILL / CHIP ============ */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
  background: var(--gray-100); color: var(--gray-600);
}

/* ============ LOADING ============ */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ LOGIN PAGE ============ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  background-image: radial-gradient(ellipse at 20% 50%, rgba(249,115,22,.12) 0%, transparent 50%),
                    radial-gradient(ellipse at 80% 20%, rgba(42,82,152,.4) 0%, transparent 50%);
  padding: 20px;
}
.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-brand {
  text-align: center;
  margin-bottom: 36px;
}
.login-brand .brand-logo {
  margin: 0 auto 12px;
  width: 52px; height: 52px;
}
.login-brand .brand-icon { font-size: 18px; }
.login-brand h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.3px;
}
.login-brand h1 em { color: var(--orange); font-style: normal; }
.login-brand p { color: var(--gray-600); font-size: 14px; margin-top: 6px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-toggle { display: flex; }
  .main-content { margin-left: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 500px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ============ BADGE ALIASES ============ */
.badge-success { background: #ecfdf5; color: #065f46; }
.badge-danger  { background: #fef2f2; color: #991b1b; }
.badge-warning { background: #fffbeb; color: #92400e; }
.badge-info    { background: #eff6ff; color: #1e40af; }

/* ============ TABS NAV ============ */
.tabs-nav {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 0;
}
.tab-link {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
  border-radius: 6px 6px 0 0;
}
.tab-link:hover { color: var(--navy); }
.tab-link.active { color: var(--navy); border-bottom-color: var(--orange); font-weight: 600; }

/* ============ ALERT ============ */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; }
.alert-info    { background: rgba(14,165,233,.08); border: 1px solid rgba(14,165,233,.2); }
.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* ============ BTN SUCCESS ============ */
.btn-success { background: #059669; color: #fff; border-color: #059669; }
.btn-success:hover { background: #047857; }
