/* ============================================================================
 * styles.css — WYF Management
 * ----------------------------------------------------------------------------
 * All visual styling lives here. Theme is driven by CSS custom properties on
 * :root (light) and :root[data-theme="dark"] (dark).
 *
 * Layout regions:
 *   .auth-shell    →  full-bleed login screen (background image + overlay)
 *   .app-shell     →  app chrome (sidebar + topbar + main)
 *   .main          →  scrollable content area
 *   .err-bar       →  fixed bottom error tray (hidden when empty)
 * ========================================================================= */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;
  --brand: #1e3a8a;          /* deep navy — matches background overlay */
  --brand-2: #2563eb;
  --accent: #f59e0b;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 4px 12px rgba(15,23,42,.08);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.12);
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2e;
  --surface-2: #0f1729;
  --surface-3: #182542;
  --border: #1f2c4a;
  --border-strong: #2a3a60;
  --text: #e6ecf7;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --brand: #3b82f6;
  --brand-2: #60a5fa;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 6px 18px rgba(0,0,0,.4);
  --shadow-lg: 0 18px 40px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

/* ----- AUTH / LOGIN -------------------------------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  background: #0b1220 url("img/bg-baguio.svg") center/cover no-repeat fixed;
}
.auth-shell::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(11,25,52,.85), rgba(15,30,66,.92));
  backdrop-filter: blur(2px);
}
.auth-card {
  position: relative; z-index: 1;
  background: var(--surface);
  width: min(420px, 92vw);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.auth-brand { text-align: center; margin-bottom: 14px; }
.auth-logo {
  width: 72px; height: 72px;
  border-radius: 14px;
  object-fit: contain;
  box-shadow: 0 4px 16px rgba(37,99,235,.18);
}
.auth-card h1 {
  margin: 0 0 4px; font-size: 22px; font-weight: 700; color: var(--text); text-align: center;
}
.auth-card .sub { margin: 0 0 20px; color: var(--text-muted); font-size: 13px; text-align: center; }
.auth-card .form-row { margin-bottom: 14px; }
.auth-card label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.auth-card .actions { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.auth-card .small-link { font-size: 12px; color: var(--text-muted); cursor: pointer; background: none; border: 0; padding: 0; }
.auth-card .small-link:hover { color: var(--brand-2); }

.captcha {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.captcha .puzzle {
  font-family: var(--mono); font-size: 18px; font-weight: 700;
  letter-spacing: 4px;
  background: var(--surface-3);
  padding: 6px 12px; border-radius: 4px;
  user-select: none;
  background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(0,0,0,.04) 6px 7px);
}
.captcha button.refresh { border: 0; background: none; cursor: pointer; color: var(--text-muted); padding: 4px 6px; font-size: 16px; }

.lockout {
  background: rgba(220,38,38,.08);
  border: 1px solid rgba(220,38,38,.4);
  color: var(--danger);
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 14px;
}

/* ----- APP SHELL ----------------------------------------------------------- */
.app-shell { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 12px;
  overflow-y: auto;
}
.brand-row { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-logo { width: 36px; height: 36px; border-radius: 8px; object-fit: contain; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 14px; line-height: 1.1; }
.brand-name small { display: block; color: var(--text-muted); font-weight: 500; font-size: 11px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer; user-select: none;
  font-size: 13px;
  margin-bottom: 2px;
  border: 0; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.sidebar-footer .me { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; color: var(--text); font-size: 12px; }

.topbar {
  height: 52px; padding: 0 22px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.topbar .title { font-weight: 600; font-size: 15px; }
.topbar .actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border);
  display: grid; place-items: center; cursor: pointer; color: var(--text-muted);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 16px; height: 16px; }

.main { padding: 22px; overflow-y: auto; background: var(--bg); }

/* ----- COMMON COMPONENTS --------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card .card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card .card-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card .card-body { padding: 16px 18px; }

.input, .select, .textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.input.error { border-color: var(--danger); }
.input::placeholder { color: var(--text-faint); }
.textarea { min-height: 70px; resize: vertical; }

.field-help { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

.btn {
  border: 0; border-radius: var(--radius-sm);
  padding: 8px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: transform .04s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-2); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; justify-content: center; }

.phone-wrap { display: flex; align-items: stretch; }
.phone-wrap .cc {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-right: 0;
  padding: 0 10px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 13px;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  color: var(--text-muted);
}
.phone-wrap .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ----- TABLES -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: 10px 12px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
table.tbl th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
table.tbl tbody tr { cursor: pointer; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr.selected { background: rgba(37,99,235,.08); }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--text);
}
.pill.success { background: rgba(22,163,74,.12); color: var(--success); }
.pill.warn { background: rgba(217,119,6,.14); color: var(--warn); }
.pill.danger { background: rgba(220,38,38,.12); color: var(--danger); }
.pill.info { background: rgba(37,99,235,.12); color: var(--brand-2); }

/* ----- METRICS / DASHBOARD ------------------------------------------------- */
.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .grid.cols-4, .grid.cols-2 { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
.metric { padding: 16px 18px; }
.metric .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.metric .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.metric .delta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.metric .delta.up { color: var(--success); }
.metric .delta.down { color: var(--danger); }

.chart-card { padding: 16px 18px; min-height: 260px; }
.chart-card h4 { margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.chart-card canvas { width: 100% !important; height: 220px !important; }

/* ----- DRAWER / DIALOG ----------------------------------------------------- */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; justify-content: flex-end; z-index: 60;
}
.drawer {
  background: var(--surface); width: min(520px, 96vw); height: 100%;
  display: flex; flex-direction: column; border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.drawer-head h3 { margin: 0; font-size: 15px; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ----- ERROR BAR (bottom-of-screen) --------------------------------------- */
.err-bar {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 90;
  background: var(--surface);
  border: 1px solid var(--danger);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  display: grid; grid-template-columns: 24px 1fr auto; align-items: start; gap: 12px;
  max-height: 50vh; overflow-y: auto;
}
.err-bar.hidden { display: none; }
.err-bar .ico { color: var(--danger); margin-top: 2px; }
.err-bar .body strong { display: block; font-size: 13px; }
.err-bar .body code { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.err-bar .body .where { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.err-bar .actions { display: flex; gap: 6px; }

/* ----- MISC --------------------------------------------------------------- */
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--mono); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 16px 0 8px; }
.empty { padding: 30px; text-align: center; color: var(--text-muted); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-size: 13px; cursor: pointer; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s; }
.tabs button.active { color: var(--text); border-bottom-color: var(--brand-2); font-weight: 600; }

/* ============================================================================
 * ANIMATIONS
 * ========================================================================= */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(32px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* Page view entrance — keyed div re-mounts on route change */
.view-enter {
  animation: fadeInUp .22s cubic-bezier(.16,1,.3,1);
}

/* Auth card floats in on load */
.auth-card {
  animation: scaleIn .3s cubic-bezier(.16,1,.3,1);
}

/* Drawer slides in from the right */
.drawer {
  animation: slideInRight .22s cubic-bezier(.16,1,.3,1);
}
/* Drawer backdrop fades in */
.drawer-mask {
  animation: fadeIn .15s ease;
}

/* Nav items — smooth color transition */
.nav-item {
  transition: background .12s ease, color .12s ease, transform .1s ease;
}
.nav-item:hover { transform: translateX(2px); }
.nav-item.active { transform: translateX(0); }

/* Buttons — lift on hover, press on click */
.btn {
  transition: transform .1s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(15,23,42,.12); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 14px rgba(37,99,235,.35); }

/* Metric cards — float on hover */
.metric {
  transition: transform .18s ease, box-shadow .18s ease;
}
.metric:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

/* Table rows — smooth background */
table.tbl tbody tr {
  transition: background .1s ease;
}

/* Cards — subtle border on hover */
.card {
  transition: box-shadow .18s ease;
}

/* Inputs — smooth focus ring */
.input, .select, .textarea {
  transition: border-color .12s ease, box-shadow .12s ease;
}

/* Pills — gentle fade */
.pill {
  animation: fadeIn .15s ease;
}

/* Icon buttons */
.icon-btn {
  transition: background .12s ease, color .12s ease, transform .1s ease;
}
.icon-btn:hover { transform: scale(1.08); }

/* Auth logo pulse on hover */
.auth-logo {
  transition: transform .2s ease, box-shadow .2s ease;
}
.auth-logo:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(37,99,235,.25);
}
