/* VetBills CMS - Main Stylesheet */
:root {
  --bg: #0f1117;
  --bg2: #161b27;
  --bg3: #1e2535;
  --border: rgba(255,255,255,0.08);
  --accent: #e94560;
  --accent2: #4ecca3;
  --text: #e8eaf0;
  --text-muted: #6b7280;
  --sidebar-w: 240px;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-icon { font-size: 1.6rem; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; }

.brand-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-menu { list-style: none; padding: 12px 0; flex: 1; }

.nav-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item a:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-item.active a { color: var(--accent); border-left-color: var(--accent); background: rgba(233,69,96,0.08); }
.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logout-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  transition: color 0.15s;
}
.logout-btn:hover { color: var(--accent); }
.version { font-size: 0.75rem; color: var(--text-muted); }

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

.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
  flex: 1;
}

.user-badge {
  background: var(--bg3);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.content-area { padding: 28px; flex: 1; }

/* ===== CARDS & PANELS ===== */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
}

.stat-card.green::before { background: var(--accent2); }
.stat-card.blue::before { background: #4e9fcc; }
.stat-card.yellow::before { background: #f59e0b; }

.stat-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--text); }
.stat-icon { position: absolute; top: 16px; right: 16px; font-size: 1.5rem; opacity: 0.4; }

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

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-paid    { background: rgba(78,204,163,0.15); color: #4ecca3; }
.badge-open    { background: rgba(107,114,128,0.2); color: #9ca3af; }
.badge-partial { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-overdue { background: rgba(233,69,96,0.15); color: #e94560; }

/* ===== FORMS ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }

input, select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select option { background: var(--bg3); }
textarea { resize: vertical; min-height: 80px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--accent2); color: #0f1117; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(233,69,96,0.15); color: var(--accent); border: 1px solid var(--accent); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.88rem;
}
.alert-success { background: rgba(78,204,163,0.12); border: 1px solid rgba(78,204,163,0.3); color: #4ecca3; }
.alert-error   { background: rgba(233,69,96,0.12); border: 1px solid rgba(233,69,96,0.3); color: #e94560; }
.alert-info    { background: rgba(78,158,204,0.12); border: 1px solid rgba(78,158,204,0.3); color: #4e9fcc; }

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
}

/* ===== SEARCH ===== */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-bar input { max-width: 320px; }

/* ===== INVOICE PRINT ===== */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin: 0 !important; }
  .content-area { padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .invoice-print { background: #fff !important; color: #000 !important; max-width: 100% !important; }
}

.invoice-print {
  background: #fff;
  color: #111;
  max-width: 820px;
  margin: 0 auto;
  padding: 40px;
  border-radius: var(--radius);
  font-family: var(--font-body);
}

.invoice-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 32px; }
.invoice-shop-name { font-family: var(--font-display); font-size: 1.6rem; color: #111; }
.invoice-meta { text-align: right; font-size: 0.85rem; color: #555; line-height: 1.7; }
.invoice-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 2px; color: #999; margin-bottom: 4px; }
.invoice-number { font-size: 1.3rem; font-weight: 700; color: #e94560; }
.invoice-divider { border: none; border-top: 2px solid #f0f0f0; margin: 20px 0; }
.invoice-to { font-size: 0.8rem; text-transform: uppercase; color: #999; margin-bottom: 4px; }
.invoice-client-name { font-weight: 700; font-size: 1.05rem; }
.invoice-table { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: 0.88rem; }
.invoice-table th { background: #f7f7f7; padding: 10px 12px; text-align: left; font-size: 0.75rem; text-transform: uppercase; color: #777; }
.invoice-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }
.invoice-totals { text-align: right; font-size: 0.9rem; margin-top: 12px; }
.invoice-total-due { font-size: 1.3rem; font-weight: 700; color: #e94560; }
.invoice-footer-note { margin-top: 32px; font-size: 0.8rem; color: #aaa; text-align: center; border-top: 1px solid #eee; padding-top: 16px; }
.animal-tag { display: inline-block; background: #e8f5e9; color: #2e7d32; padding: 2px 8px; border-radius: 10px; font-size: 0.78rem; font-weight: 600; }
.code-tag { display: inline-block; background: #e3f2fd; color: #1565c0; padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; font-family: monospace; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== EXTRAS ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .emoji { font-size: 3rem; margin-bottom: 12px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }
.monospace { font-family: monospace; }
.receipt-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; }
.modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.7); z-index:999; align-items:center; justify-content:center; }
.modal-overlay.show { display:flex; }
.modal-box { background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius); padding:28px; max-width:90vw; max-height:90vh; overflow:auto; position:relative; }
.modal-close { position:absolute; top:12px; right:16px; font-size:1.4rem; cursor:pointer; color:var(--text-muted); background:none; border:none; }
