/* Cochiwawa Admin Panel — Green Theme */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --deep:    #0F2419;
  --forest:  #1A3C2E;
  --sage:    #2D6A4F;
  --mint:    #52B788;
  --lime:    #95D5B2;
  --coral:   #FF6B35;
  --white:   #FAFFF8;
  --dim:     #8BAF98;
  --gold:    #FFD700;
  --red:     #FF4444;
  --bg:      #F2FAF5;
  --surface: #FFFFFF;
  --border:  #D4EDDA;
  --text:    #0F2419;
  --muted:   #4A7A5A;
  --radius:  12px;
  --shadow:  0 2px 16px rgba(15,36,25,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; }
body { font-family: 'DM Sans', system-ui, sans-serif; background: var(--bg); color: var(--text); display: flex; min-height: 100vh; overflow-x: hidden; }

/* ===== Sidebar ===== */
.sidebar {
  width: 240px; min-height: 100vh;
  background: var(--deep);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0;
  overflow-y: auto; z-index: 50;
}
.sidebar-logo {
  padding: 24px 20px;
  font-family: 'Syne', sans-serif;
  font-size: 1.25rem; font-weight: 800; color: var(--white);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  line-height: 1.3;
}
.sidebar-logo span { color: var(--mint); }
.sidebar-section {
  padding: 8px 12px 4px;
  font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--dim);
  margin-top: 12px; font-weight: 600;
}
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; color: rgba(255,255,255,0.65);
  text-decoration: none; border-radius: 8px;
  margin: 2px 8px; font-size: 0.9rem;
  transition: all 0.15s;
}
.sidebar-link:hover { background: rgba(82,183,136,0.12); color: var(--lime); }
.sidebar-link.active { background: var(--mint); color: var(--deep); font-weight: 700; }
.sidebar-link .icon { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }

/* ===== Main ===== */
.main-content { margin-left: 240px; flex: 1; display: flex; flex-direction: column; }

/* ===== Topbar ===== */
.topbar {
  background: white; padding: 0 28px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 1px 8px rgba(15,36,25,0.06);
}
.topbar-title { font-size: 1rem; font-weight: 700; color: var(--text); font-family: 'Syne', sans-serif; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.admin-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--mint); color: var(--deep);
  font-weight: 800; font-family: 'Syne', sans-serif;
  display: flex; align-items: center; justify-content: center; font-size: 0.9rem;
}
.live-dot { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.live-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== Page ===== */
.page { padding: 28px; }
.page-header { margin-bottom: 24px; display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 1.7rem; font-weight: 800; font-family: 'Syne', sans-serif; color: var(--text); }
.page-header p { color: var(--muted); margin-top: 4px; font-size: 0.9rem; }

/* ===== Stat cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: white; border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
  border-left: 4px solid var(--mint);
}
.stat-card.gold { border-left-color: var(--gold); }
.stat-card.coral { border-left-color: var(--coral); }
.stat-card.sage { border-left-color: var(--sage); }
.stat-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; background: var(--bg); }
.stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1; font-family: 'Syne', sans-serif; }
.stat-label { font-size: 0.78rem; color: var(--muted); margin-top: 4px; font-weight: 500; }
.stat-delta { font-size: 0.72rem; font-weight: 700; margin-top: 2px; }
.delta-up { color: var(--mint); }
.delta-down { color: var(--red); }

/* ===== Cards ===== */
.card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 100%; }
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 1rem; font-weight: 700; font-family: 'Syne', sans-serif; }
.card-body { padding: 0; }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 11px 16px;
  font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--muted);
  background: var(--bg); border-bottom: 1px solid var(--border); font-weight: 700;
}
td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 0.88rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #F8FFF9; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 0.73rem; font-weight: 700; }
.badge-success { background: #D4EDDA; color: #0F5132; }
.badge-warning { background: #FFF3CD; color: #856404; }
.badge-error { background: #FFE0E0; color: #9B0000; }
.badge-info { background: #D1ECF1; color: #0C5460; }
.badge-gray { background: #E8F5E9; color: var(--muted); }
.badge-gold { background: #FFF9C4; color: #856404; }
.badge-mint { background: #D4EDDA; color: var(--sage); }

/* ===== Buttons ===== */
.btn { padding: 9px 18px; border-radius: 8px; font-weight: 600; border: none; cursor: pointer; font-size: 0.85rem; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-family: 'DM Sans', sans-serif; }
.btn-primary { background: var(--mint); color: var(--deep); }
.btn-primary:hover { background: var(--sage); color: white; }
.btn-coral { background: var(--coral); color: white; }
.btn-coral:hover { filter: brightness(0.9); }
.btn-outline { background: transparent; color: var(--mint); border: 1.5px solid var(--mint); }
.btn-outline:hover { background: var(--mint); color: var(--deep); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { filter: brightness(0.9); }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--mint); color: var(--mint); }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-xs { padding: 3px 9px; font-size: 0.74rem; border-radius: 6px; }

/* ===== Form ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 0.76rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select, .form-textarea { padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 0.9rem; outline: none; transition: border-color 0.2s; width: 100%; font-family: 'DM Sans', sans-serif; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--mint); }
.form-textarea { min-height: 80px; resize: vertical; }

/* ===== Filter bar ===== */
.filter-bar { display: flex; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.filter-bar input, .filter-bar select { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 0.86rem; outline: none; font-family: 'DM Sans', sans-serif; }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--mint); }

/* ===== Spinner ===== */
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--mint); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 28px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row td { text-align: center; padding: 40px; color: var(--muted); }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 52px 20px; color: var(--muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 0.9rem; }

/* ===== Toast ===== */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: white; border-radius: 10px; padding: 12px 18px; box-shadow: 0 4px 20px rgba(15,36,25,0.18); display: flex; align-items: center; gap: 10px; min-width: 260px; animation: slideIn 0.3s; border-left: 4px solid var(--mint); font-size: 0.88rem; }
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--mint); }
.toast.info { border-left-color: var(--sage); }
@keyframes slideIn { from { transform: translateX(110%); } to { transform: translateX(0); } }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,36,25,0.6); z-index: 100; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.15s; }
.modal { background: white; border-radius: 16px; padding: 28px; max-width: 580px; width: 94%; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(15,36,25,0.25); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 1.15rem; font-weight: 700; font-family: 'Syne', sans-serif; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); padding: 0; line-height: 1; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== Tabs ===== */
.tab-bar { display: flex; gap: 4px; border-bottom: 2px solid var(--border); padding: 0 20px; }
.tab-btn { padding: 12px 20px; border: none; background: none; cursor: pointer; font-size: 0.88rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; font-family: 'DM Sans', sans-serif; }
.tab-btn.active { color: var(--mint); border-bottom-color: var(--mint); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Date filter ===== */
.date-filter { display: flex; gap: 4px; }
.date-btn { padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--border); background: white; font-size: 0.82rem; font-weight: 600; cursor: pointer; color: var(--muted); transition: all 0.15s; font-family: 'DM Sans', sans-serif; }
.date-btn:hover { border-color: var(--mint); color: var(--mint); }
.date-btn.active { background: var(--mint); color: var(--deep); border-color: var(--mint); }

/* ===== Charts ===== */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-container { background: white; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.chart-header h3 { font-size: 0.95rem; font-weight: 700; font-family: 'Syne', sans-serif; }
.chart-canvas-wrap { position: relative; height: 240px; }

/* ===== User avatar ===== */
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--mint); color: var(--deep); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; flex-shrink: 0; font-family: 'Syne', sans-serif; }

/* ===== Verification card ===== */
.verification-card {
  background: white; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border: 2px solid var(--border);
  transition: border-color 0.2s;
}
.verification-card:hover { border-color: var(--mint); }
.verification-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .verification-grid { grid-template-columns: 1fr; } }
.doc-photo { width: 100%; border-radius: 8px; max-height: 200px; object-fit: cover; background: var(--bg); border: 1px solid var(--border); display: block; }
.doc-placeholder { background: var(--bg); border: 2px dashed var(--border); border-radius: 8px; height: 120px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 0.82rem; }

/* ===== Revenue highlight ===== */
.revenue-value { font-size: 2rem; font-weight: 800; color: var(--sage); font-family: 'Syne', sans-serif; }
.revenue-gold { color: #B8860B; }

/* ===== Alert banner ===== */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 0.88rem; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.alert-warning { background: #FFF3CD; border: 1px solid #FFE69C; color: #664D03; }
.alert-danger { background: #FFE0E0; border: 1px solid #FFBABA; color: #7A0000; }
.alert-success { background: #D4EDDA; border: 1px solid #C3E6CB; color: #155724; }
.alert-info { background: #D1ECF1; border: 1px solid #BEE5EB; color: #0C5460; }

/* ===== Section divider ===== */
.section-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ===== Two-column responsive grid ===== */
.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ===== Mobile hamburger button ===== */
#mob-menu-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 1.5rem; color: var(--text); padding: 4px 8px;
  line-height: 1; flex-shrink: 0;
}

/* ===== Sidebar overlay ===== */
#sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 49;
}
#sidebar-overlay.active { display: block; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  /* Clip at browser level — no horizontal scroll ever */
  html, body { overflow-x: clip !important; }

  #mob-menu-btn { display: block; }

  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; z-index: 50; }
  .sidebar.open { transform: translateX(0); }

  /* main-content must NOT have overflow-x:hidden — it would block inner card-body scroll */
  .main-content { margin-left: 0; width: 100%; max-width: 100%; }

  .page { padding: 12px; max-width: 100%; }

  .topbar { padding: 0 10px; gap: 6px; }
  .topbar-title { font-size: 0.88rem; white-space: nowrap; min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; }
  .topbar-user span { display: none; }

  /* Page header: always stack title above buttons */
  .page-header { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }
  .page-header h1 { font-size: 1.3rem; }
  .page-header > div > div[style], .page-header > div[style] { flex-wrap: wrap !important; gap: 8px !important; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stat-value { font-size: 1.4rem; }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; font-size: 1.1rem; }

  /* Two-col grid stacks */
  .two-col-grid { grid-template-columns: 1fr !important; }

  /* Tables scroll horizontally inside card-body only */
  .card { max-width: 100%; }
  .card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  table { min-width: 420px; }

  /* Filter bar */
  .filter-bar { flex-wrap: wrap; gap: 8px; }
  .filter-bar input, .filter-bar select { min-width: 0 !important; flex: 1 1 140px; }

  /* Revenue rows wrap */
  .revenue-row { flex-wrap: wrap; gap: 4px; }

  /* Info rows wrap */
  .info-row { flex-wrap: wrap; }

  /* Inline flex in page body wraps */
  .page [style*="display:flex"] { flex-wrap: wrap; }

  /* Tab bars */
  .tab-bar { flex-wrap: wrap; }

  /* Charts */
  .chart-grid { grid-template-columns: 1fr; }
  .chart-canvas-wrap { height: 200px; }

  /* Grids */
  .verification-grid { grid-template-columns: 1fr; }
  .doc-grid { grid-template-columns: 1fr 1fr !important; }

  /* Toast */
  #toast-container { right: 10px; left: 10px; bottom: 12px; }
  .toast { min-width: unset; width: 100%; box-sizing: border-box; }

  /* Modal */
  .modal { width: 96%; padding: 16px; max-height: 85vh; }
  .modal-footer { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page { padding: 10px; }
  table { min-width: 340px; }
  .doc-grid { grid-template-columns: 1fr !important; }
}

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn 0.3s; }
