/* ============================================================
   PharmaSYS PharmaTrack — app.css
   ============================================================ */

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

:root {
  --bg:       #f8fafc;
  --surface:  #ffffff;
  --surface2: #f1f5f9;
  --border:   #e2e8f0;
  --text:     #0f172a;
  --muted:    #64748b;
  --dim:      #94a3b8;
  --teal:     #0d9488;
  --blue:     #2563eb;
  --violet:   #7c3aed;
  --amber:    #d97706;
  --red:      #dc2626;
  --green:    #16a34a;
  --mono:     'JetBrains Mono', monospace;
  --sans:     'Inter', -apple-system, sans-serif;
  --radius:   8px;
  --shadow:   0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- NAV ---- */
.app-nav {
  background: #1e293b;
  color: #94a3b8;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-right: 2rem;
  text-decoration: none;
}
.nav-logo-mark {
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--mono);
}
.nav-brand-text { color: #fff; font-weight: 700; font-size: 0.95rem; }
.nav-brand-sub   { color: #64748b; font-size: 0.75rem; }
.nav-links { display: flex; gap: 0; flex: 1; }
.nav-link {
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}
.nav-link:hover { color: #fff; text-decoration: none; }
.nav-link.active { color: #fff; border-bottom-color: var(--teal); }
.nav-right { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
.nav-user  { color: #cbd5e1; font-size: 0.82rem; }
.nav-alert-badge {
  background: var(--red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  font-family: var(--mono);
}

/* ---- LAYOUT ---- */
.page-wrap { max-width: 1400px; margin: 0 auto; padding: 2rem 1.5rem; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }
.breadcrumb { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.2rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }

/* ---- TABS ---- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  gap: 0;
}
.tab {
  padding: 0.625rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ---- CARDS ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.card-header h3 { font-size: 0.9rem; font-weight: 600; }

/* ---- STAT CARDS ---- */
.stats-grid { display: grid; gap: 1rem; margin-bottom: 1.75rem; }
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stats-grid-5 { grid-template-columns: repeat(5, 1fr); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  border-top: 3px solid var(--dim);
  box-shadow: var(--shadow);
}
.stat-card-danger { border-top-color: var(--red); }
.stat-card-warn   { border-top-color: var(--amber); }
.stat-card-ok     { border-top-color: var(--green); }
.stat-card-info   { border-top-color: var(--blue); }
.stat-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.35rem; }
.stat-value { font-size: 1.875rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.stat-card-danger .stat-value { color: var(--red); }
.stat-card-warn   .stat-value { color: var(--amber); }
.stat-card-ok     .stat-value { color: var(--green); }
.stat-card-info   .stat-value { color: var(--blue); }
.stat-sub { font-size: 0.72rem; color: var(--muted); margin-top: 0.25rem; }

/* ---- STORE GRID ---- */
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.store-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
  display: block;
}
.store-card:hover { border-color: var(--blue); box-shadow: var(--shadow-md); text-decoration: none; }
.store-card-stale { border-left: 3px solid var(--amber); }
.store-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 0.25rem; }
.store-name { font-weight: 700; font-size: 0.95rem; }
.store-sync { font-size: 0.7rem; font-family: var(--mono); font-weight: 500; }
.store-sync-ok   { color: var(--green); }
.store-sync-stale{ color: var(--amber); }
.store-location  { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.75rem; }
.store-stats { display: flex; gap: 1.25rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.store-stat { display: flex; flex-direction: column; }
.store-stat-val { font-family: var(--mono); font-size: 1rem; font-weight: 700; }
.store-stat-lbl { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.store-stat-danger { color: var(--red); }
.store-stat-warn   { color: var(--amber); }
.store-stat-alert  { color: var(--blue); }

/* ---- ALERTS ---- */
.alerts-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }
.alert-item {
  display: flex;
  gap: 0.875rem;
  padding: 0.875rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.alert-item-critical { border-left: 3px solid var(--red); background: #fef2f2; }
.alert-item-warning  { border-left: 3px solid var(--amber); background: #fffbeb; }
.alert-item-info     { border-left: 3px solid var(--blue); }
.alert-read { opacity: 0.6; }
.alert-icon  { font-size: 1rem; flex-shrink: 0; }
.alert-title { font-weight: 600; font-size: 0.85rem; }
.alert-msg   { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.alert-meta  { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; font-family: var(--mono); }

/* Flash alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.85rem;
  border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* ---- SECTION ---- */
.section-header { margin: 1.5rem 0 0.75rem; display: flex; align-items: center; justify-content: space-between; }
.section-header h2 { font-size: 1rem; font-weight: 700; }
.section-info { font-size: 0.82rem; color: var(--muted); margin-bottom: 1rem; }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.data-table thead th {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  background: var(--surface2);
}
.data-table thead th a { color: var(--muted); }
.data-table thead th a:hover { color: var(--text); text-decoration: none; }
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.data-table tbody tr:hover { background: var(--surface2); }
.data-table tbody td { padding: 0.55rem 0.75rem; vertical-align: middle; }

.drug-name { font-weight: 600; font-size: 0.83rem; }
.drug-mfr  { font-size: 0.71rem; color: var(--muted); font-family: var(--mono); }

/* ---- FORMS ---- */
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-group label { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.form-control, .form-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-control-code {
  font-family: var(--mono);
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  text-align: center;
}
.form-select-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.form-inline-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; align-items: end; }
.form-group-submit { display: flex; align-items: flex-end; }

/* ---- TABLE CONTROLS ---- */
.table-controls { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.875rem;
  font-size: 0.82rem;
  color: var(--text);
  outline: none;
}
.search-input:focus { border-color: var(--blue); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: var(--surface2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-block { width: 100%; justify-content: center; padding: 0.625rem 1rem; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.75rem; }

/* ---- BADGES & PILLS ---- */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.pill-ok     { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }
.pill-danger { background: #fef2f2; color: var(--red);   border: 1px solid #fecaca; }
.pill-warn   { background: #fffbeb; color: var(--amber); border: 1px solid #fde68a; }
.pill-muted  { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.pill-teal   { background: #f0fdfa; color: var(--teal);  border: 1px solid #99f6e4; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: var(--mono);
}
.badge-blue   { background: #dbeafe; color: var(--blue); }
.badge-purple { background: #ede9fe; color: var(--violet); }
.badge-gray   { background: var(--surface2); color: var(--muted); }

/* ---- PAGINATION ---- */
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; font-size: 0.78rem; color: var(--muted); }
.page-btns  { display: flex; gap: 0.3rem; }
.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.page-btn:hover { color: var(--text); text-decoration: none; }
.page-btn.active { color: var(--blue); border-color: var(--blue); font-weight: 600; }

/* ---- UTILS ---- */
.mono       { font-family: var(--mono); }
.fw-bold    { font-weight: 700; }
.text-muted { color: var(--muted); }
.text-ok    { color: var(--green); }
.text-danger{ color: var(--red); }
.text-warn  { color: var(--amber); }
.text-teal  { color: var(--teal); }
.text-violet{ color: var(--violet); }
.text-success{ color: var(--green); }
.text-center{ text-align: center; }
.empty-state{ padding: 2rem; text-align: center; color: var(--muted); }

/* ---- MINI BAR CHART ---- */
.mini-barchart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 80px;
  padding: 0 0.25rem;
}
.mini-bar {
  flex: 1;
  background: var(--teal);
  border-radius: 2px 2px 0 0;
  opacity: 0.7;
  min-height: 2px;
  transition: opacity 0.15s;
  cursor: default;
}
.mini-bar:hover { opacity: 1; }

/* ---- AUTH PAGES ---- */
.auth-body { background: #f1f5f9; display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-wrap { width: 100%; max-width: 400px; padding: 2rem 1rem; }
.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 2rem;
  justify-content: center;
}
.auth-logo-mark {
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  font-family: var(--mono);
  font-size: 1.1rem;
  padding: 8px 14px;
  border-radius: 8px;
}
.auth-brand   { font-weight: 800; font-size: 1rem; letter-spacing: -0.02em; }
.auth-product { font-size: 0.78rem; color: var(--muted); }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow-md);
}
.auth-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.25rem; }
.auth-sub   { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.5rem; }
.auth-links { text-align: center; margin-top: 1.25rem; font-size: 0.8rem; color: var(--muted); }
.auth-links a { color: var(--blue); }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.75rem; color: var(--muted); line-height: 1.6; }
.auth-footer a { color: var(--muted); }

.form-group + .form-group { margin-top: 1rem; }

/* ---- FOOTER ---- */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--dim);
  margin-top: 3rem;
}
