/* ============================================================
   GetSolar PH — Admin Portal
   Reuses the public site's design tokens (Poppins, brand colors)
   ============================================================ */
:root {
  --blue:        #1565c0;
  --blue-light:  #1e88e5;
  --blue-dark:   #0d47a1;
  --yellow:      #ffc107;
  --orange:      #ff8f00;
  --green:       #2e7d32;
  --green-light: #43a047;
  --red:         #d32f2f;
  --purple:      #7b1fa2;
  --teal:        #00897b;
  --white:       #ffffff;
  --off-white:   #f8fafc;
  --light:       #eef2f7;
  --dark:        #0f1e35;
  --dark-2:      #1a2e4a;
  --gray:        #64748b;
  --gray-light:  #cbd5e1;
  --shadow:      0 4px 24px rgba(21, 101, 192, 0.10);
  --radius:      12px;
  --radius-lg:   20px;
  --font:        'Poppins', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  color: var(--dark);
  background: var(--off-white);
  line-height: 1.6;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; font-family: var(--font); border: none; }
input, select, textarea { font-family: var(--font); }
img { max-width: 100%; }

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

.sidebar {
  width: 240px;
  background: linear-gradient(180deg, var(--dark) 0%, var(--dark-2) 100%);
  color: rgba(255,255,255,0.8);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  transition: transform .25s ease;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar .brand img { height: 34px; }
.sidebar .brand span { font-weight: 700; color: var(--white); font-size: .95rem; }
.sidebar nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .88rem;
  margin-bottom: 2px;
  transition: .2s;
}
.sidebar nav a i { width: 18px; text-align: center; font-size: .9rem; }
.sidebar nav a:hover { background: rgba(255,255,255,0.07); color: var(--white); }
.sidebar nav a.active { background: var(--blue); color: var(--white); font-weight: 600; }
.sidebar .side-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: .78rem;
}
.sidebar .side-footer a { color: var(--yellow); }

.main { flex: 1; margin-left: 240px; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--white);
  border-bottom: 1px solid var(--light);
  padding: 14px 28px;
  position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; flex: 1; }
.topbar .admin-chip {
  display: flex; align-items: center; gap: 10px;
  font-size: .85rem; color: var(--gray);
}
.topbar .admin-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
}
.topbar .icon-btn {
  background: none; color: var(--gray); font-size: 1rem;
  padding: 8px; border-radius: 8px;
}
.topbar .icon-btn:hover { background: var(--light); color: var(--dark); }
.menu-toggle { display: none; }

.content { padding: 28px; max-width: 1400px; }

/* ---------- Cards & stats ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--light);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card .s-label { font-size: .78rem; color: var(--gray); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat-card .s-label i { color: var(--blue-light); }
.stat-card .s-value { font-size: 1.5rem; font-weight: 800; margin-top: 4px; }
.stat-card .s-sub { font-size: .74rem; color: var(--gray); }

.panel {
  background: var(--white);
  border: 1px solid var(--light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--light);
}
.panel-head h2 { font-size: .98rem; font-weight: 700; flex: 1; }
.panel-body { padding: 20px; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 1100px) { .panel-grid { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
  white-space: nowrap;
}
table.data th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray);
  padding: 10px 14px;
  border-bottom: 1px solid var(--light);
  background: var(--off-white);
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--light); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .15s; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: #f0f6ff; }
.table-empty, .table-loading, .table-error {
  padding: 42px 20px; text-align: center; color: var(--gray); font-size: .9rem;
}
.table-error { color: var(--red); }

/* ---------- Controls ---------- */
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.controls input[type="search"], .controls input[type="date"], .controls select, .field input, .field select, .field textarea {
  padding: 9px 12px;
  border: 1px solid var(--gray-light);
  border-radius: 9px;
  font-size: .84rem;
  background: var(--white);
  color: var(--dark);
}
.controls input[type="search"] { min-width: 200px; }
.controls input:focus, .controls select:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue);
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 9px;
  font-size: .84rem;
  font-weight: 600;
  transition: .2s;
}
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: var(--light); color: var(--dark); }
.btn-ghost:hover { background: var(--gray-light); }
.btn-danger { background: var(--red); color: var(--white); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: .78rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.b-blue   { background: rgba(30,136,229,.12);  color: var(--blue); }
.badge.b-green  { background: rgba(67,160,71,.14);   color: var(--green); }
.badge.b-yellow { background: rgba(255,143,0,.14);   color: var(--orange); }
.badge.b-red    { background: rgba(211,47,47,.12);   color: var(--red); }
.badge.b-gray   { background: var(--light);          color: var(--gray); }
.badge.b-purple { background: rgba(123,31,162,.12);  color: var(--purple); }
.badge.b-teal   { background: rgba(0,137,123,.12);   color: var(--teal); }

/* ---------- Pagination ---------- */
.pager {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  font-size: .8rem; color: var(--gray);
}
.pager .spacer { flex: 1; }
.pager button {
  background: var(--light); color: var(--dark);
  padding: 6px 12px; border-radius: 8px; font-size: .8rem; font-weight: 600;
}
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,30,53,0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 760px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--light);
}
.modal-head h3 { font-size: 1rem; flex: 1; }
.modal-body { padding: 22px 24px; }
.modal .close-x { background: none; font-size: 1.1rem; color: var(--gray); padding: 6px; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 20px; margin-bottom: 6px; }
.kv-grid .kv b { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gray); font-weight: 600; }
.kv-grid .kv span { font-size: .88rem; }

.section-title {
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--gray); margin: 20px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--light); }

.note-item { background: var(--off-white); border: 1px solid var(--light); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; font-size: .84rem; }
.note-item .meta { font-size: .72rem; color: var(--gray); margin-top: 4px; }

.timeline-item { display: flex; gap: 12px; padding: 6px 0; font-size: .82rem; }
.timeline-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue-light); margin-top: 7px; flex-shrink: 0; }
.timeline-item .t-when { color: var(--gray); font-size: .74rem; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .78rem; font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: var(--dark); color: var(--white);
  padding: 12px 20px; border-radius: 10px; font-size: .85rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
  opacity: 0; transform: translateY(10px);
  transition: .25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--red); }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark-2) 60%, var(--blue-dark) 100%);
  padding: 20px;
}
.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-card .logo { height: 46px; margin: 0 auto 10px; display: block; }
.auth-card h1 { font-size: 1.25rem; text-align: center; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--gray); font-size: .85rem; margin-bottom: 26px; }
.auth-error {
  background: rgba(211,47,47,.08); color: var(--red);
  border: 1px solid rgba(211,47,47,.25);
  border-radius: 9px; padding: 10px 14px;
  font-size: .82rem; margin-bottom: 14px;
  display: none;
}
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-wrap .pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; color: var(--gray); padding: 8px; font-size: .9rem;
}

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 240px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 18px 14px; }
  .topbar { padding: 12px 16px; }
}
