/* ============================================================
   ZabbuCare Web App — main.css
   Matches Phase 1 desktop app colours exactly
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ───────────────────────────────────────────── */
:root {
  --bg      : #0D0D14;
  --sidebar : #12121E;
  --card    : #1A1A2E;
  --accent  : #C9A84C;
  --accent2 : #E8C97A;
  --muted   : #2A2A40;
  --border  : #2A2A40;
  --text    : #F0EBE0;
  --subtext : #8A8A9A;
  --green   : #2ECC71;
  --red     : #E74C3C;
  --orange  : #F39C12;
  --blue    : #3498DB;
  --teal    : #1ABC9C;
  --purple  : #9B59B6;
  --sidebar-w : 240px;
  --topbar-h  : 60px;
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--subtext);
}

/* ── Layout ──────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.25s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}

.sidebar-logo {
  height: 90px;
  background: var(--muted);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo img {
  height: 36px;
  width: auto;
  object-fit: contain;
  object-position: left;
}

.sidebar-logo .user-info {
  font-size: 10px;
  color: var(--accent);
  margin-top: 6px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--subtext);
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 16px 20px 6px;
}

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 1px 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-item svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item:hover {
  background: var(--muted);
  color: var(--text);
}

.nav-item.active {
  background: var(--muted);
  color: var(--accent);
}

.nav-item.active svg { opacity: 1; }

/* Sidebar bottom */
.sidebar-bottom {
  margin-top: auto;
  padding: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  background: var(--sidebar);
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--muted);
  border-radius: 8px;
  margin-bottom: 6px;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
  0%,100% { box-shadow: 0 0 0 2px rgba(46,204,113,0.2); }
  50%      { box-shadow: 0 0 0 5px rgba(46,204,113,0.05); }
}

.status-dot.offline { background: var(--red); animation: none; }

.status-text {
  font-size: 9px;
  font-weight: 600;
  color: var(--subtext);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(231,76,60,0.12);
  border: 1px solid rgba(231,76,60,0.2);
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
}

.btn-logout:hover {
  background: rgba(231,76,60,0.2);
}

.btn-logout svg { width: 15px; height: 15px; }

.btn-theme {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--muted);
  border: none;
  color: var(--subtext);
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 6px;
}

.btn-theme:hover { color: var(--text); }
.btn-theme svg { width: 14px; height: 14px; }

/* ── Main content ─────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-family: Georgia, serif;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-time {
  font-size: 11px;
  color: var(--subtext);
  font-family: 'Courier New', monospace;
}

.topbar-bell {
  position: relative;
  cursor: pointer;
  color: var(--subtext);
  padding: 6px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.topbar-bell:hover {
  color: var(--accent);
  background: var(--muted);
}

.topbar-bell svg { width: 18px; height: 18px; }

.bell-badge {
  position: absolute;
  top: 2px; right: 2px;
  width: 16px; height: 16px;
  background: var(--red);
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--sidebar);
}

/* ── Page content ─────────────────────────────────────────── */
.page {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  font-family: Georgia, serif;
}

/* ── Stat cards ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  min-height: 100px;
}

.stat-accent {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 12px 0 0 12px;
}

.stat-value {
  font-family: Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
  padding-left: 12px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  padding-left: 12px;
}

.stat-hint {
  font-size: 9px;
  color: var(--subtext);
  padding-left: 12px;
  font-family: 'Courier New', monospace;
}

/* ── Finance strip ───────────────────────────────────────── */
.fin-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.fin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.fin-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--subtext);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
  font-family: 'Courier New', monospace;
}

.fin-value {
  font-size: 13px;
  font-weight: 700;
  font-family: Georgia, serif;
}

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead tr {
  background: var(--muted);
}

thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

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

tbody tr:hover { background: var(--muted); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 10px 12px;
  color: var(--text);
  white-space: nowrap;
}

/* ── Status badges ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}

.badge-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Forms ───────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--subtext);
  letter-spacing: 0.5px;
}

.form-control {
  padding: 10px 12px;
  background: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.form-control:focus { border-color: var(--accent); }

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

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238A8A9A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover { background: var(--accent2); }

.btn-danger {
  background: rgba(231,76,60,0.15);
  color: var(--red);
  border: 1px solid rgba(231,76,60,0.25);
}
.btn-danger:hover { background: rgba(231,76,60,0.25); }

.btn-secondary {
  background: var(--muted);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-success {
  background: rgba(46,204,113,0.12);
  color: var(--green);
  border: 1px solid rgba(46,204,113,0.25);
}
.btn-success:hover { background: rgba(46,204,113,0.22); }

.btn-sm {
  padding: 5px 12px;
  font-size: 11px;
}

/* ── Search bar ──────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--subtext);
  width: 14px; height: 14px;
  pointer-events: none;
}

.search-input-wrap input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  background: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.search-input-wrap input:focus {
  border-color: var(--accent);
}

.search-input-wrap input::placeholder {
  color: var(--subtext);
}

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s;
  position: relative;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  font-family: Georgia, serif;
}

.modal-close {
  width: 28px; height: 28px;
  background: var(--muted);
  border: none;
  border-radius: 6px;
  color: var(--subtext);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  font-size: 16px;
}

.modal-close:hover { color: var(--text); }

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

/* ── Toast notifications ─────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 360px;
  pointer-events: all;
  animation: toastIn 0.25s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

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

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
.toast.warning { border-left: 3px solid var(--orange); }

.toast svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Loading spinner ─────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
  display: block;
}

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

.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px;
  color: var(--subtext);
  font-size: 12px;
  gap: 12px;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--subtext);
}

.empty-state svg {
  width: 48px; height: 48px;
  opacity: 0.3;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state p { font-size: 12px; }

/* ── Branch performance cards ────────────────────────────── */
.branch-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.branch-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.branch-card-head {
  height: 3px;
  background: var(--accent);
}

.branch-card-body { padding: 14px; }

.branch-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
  font-family: Georgia, serif;
}

.branch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--muted);
  border-radius: 4px;
  padding: 5px 8px;
  margin-bottom: 3px;
}

.branch-row-label {
  font-size: 9px;
  color: var(--subtext);
  font-family: 'Courier New', monospace;
}

.branch-row-value {
  font-size: 11px;
  font-weight: 700;
}

/* ── Clock widget ────────────────────────────────────────── */
.clock-widget {
  background: var(--muted);
  border-radius: 10px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.clock-status {
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.clock-btns { display: flex; gap: 8px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .topbar {
    padding: 0 16px;
  }
  .topbar-time {
    display: none;
  }
  .topbar-bell {
    display: flex !important;
  }
  .page {
    padding: 14px 16px;
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Utilities ───────────────────────────────────────────── */
.text-accent  { color: var(--accent); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-orange  { color: var(--orange); }
.text-blue    { color: var(--blue); }
.text-subtext { color: var(--subtext); }
.text-muted   { color: var(--subtext); }
.text-sm      { font-size: 11px; }
.text-xs      { font-size: 10px; }
.font-mono    { font-family: 'Courier New', monospace; }
.font-serif   { font-family: Georgia, serif; }
.fw-700       { font-weight: 700; }
.mb-4         { margin-bottom: 4px; }
.mb-8         { margin-bottom: 8px; }
.mb-16        { margin-bottom: 16px; }
.mb-20        { margin-bottom: 20px; }
.mt-16        { margin-top: 16px; }
.gap-8        { gap: 8px; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.flex-wrap    { flex-wrap: wrap; }
.w-full       { width: 100%; }
