/* ==========================================================================
   Base stylesheet — shared across the whole POS
   Loaded on every page BEFORE any module's own styles/*.css file,
   so module CSS can rely on these variables and override where needed.
   ========================================================================== */

:root {
  /* Brand / semantic colors - Inspired by SubTrack Green & Navy */
  --pos-primary: #0f172a;           /* Deep Navy */
  --pos-primary-dark: #1e293b;
  --pos-primary-light: #f1f5f9;
  
  --pos-accent: #10b981;            /* SubTrack Emerald Green */
  --pos-accent-dark: #059669;
  --pos-accent-light: #ecfdf5;

  --pos-success: #10b981;
  --pos-danger: #ef4444;
  --pos-warning: #f59e0b;
  --pos-info: #3b82f6;

  /* Sidebar/topbar theme */
  --pos-nav-bg: #0f172a;            /* Match Navy */
  --pos-nav-bg-active: #1e293b;     /* Slightly lighter navy */
  --pos-nav-text: #94a3b8;          /* Slate */
  --pos-nav-text-active: #34d399;   /* Green Active */

  /* Status colors (credit, expiry, stock) */
  --pos-credit-owed: #ef4444;       /* customer owes us */
  --pos-credit-clear: #10b981;      /* settled */
  --pos-payable: #f59e0b;           /* we owe supplier */
  --pos-expiry-soon: #f59e0b;
  --pos-expiry-expired: #ef4444;
  --pos-stock-low: #f59e0b;
  --pos-stock-out: #ef4444;

  /* Neutrals */
  --pos-bg: #f8fafc;                /* Very soft blue-grey */
  --pos-surface: #ffffff;
  --pos-border: #e2e8f0;
  --pos-text: #0f172a;
  --pos-text-muted: #64748b;

  /* Layout */
  --pos-sidebar-width: 250px;
  --pos-sidebar-collapsed-width: 76px;
  --pos-topbar-height: 64px;
  --pos-radius: 12px;
  --pos-radius-sm: 8px;
  --pos-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05), 0 0 0 1px rgba(15, 23, 42, 0.02);
  --pos-shadow-hover: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.08);
  --pos-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  background: var(--pos-bg);
  color: var(--pos-text);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

a {
  text-decoration: none;
}

/* ---------- App shell layout (Top Header Navigation Layout) ---------- */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-sidebar {
  display: none !important;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.app-topbar {
  height: 64px;
  background: var(--pos-primary);      /* Deep Navy #0f172a */
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1050 !important;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
  gap: 16px;
}

.top-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #ffffff;
  text-decoration: none;
  margin-right: 16px;
  white-space: nowrap;
  flex-shrink: 0;
}

.top-brand:hover {
  color: var(--pos-accent);
}

.top-brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
}

/* ---------- Top Horizontal Navbar ---------- */

.top-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.top-nav .nav-item {
  position: relative;
}

.top-nav .nav-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  background: transparent;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.top-nav .nav-link-btn:hover,
.top-nav .nav-link-btn.active,
.top-nav .nav-item:hover > .nav-link-btn {
  background: #1e293b;
  color: #34d399; /* Emerald Green Active */
}

.top-nav .dropdown-menu {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  padding: 6px;
  margin-top: 4px;
  min-width: 210px;
  z-index: 1080 !important;
}

.top-nav .dropdown-menu .dropdown-item {
  color: #94a3b8;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.top-nav .dropdown-menu .dropdown-item:hover,
.top-nav .dropdown-menu .dropdown-item.active {
  background: #1e293b;
  color: #34d399;
}

.app-content {
  padding: 24px;
  flex: 1;
  width: 100%;
}

/* ---------- Topbar feature search ---------- */

.topbar-search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.topbar-search-wrap input {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 8px 16px 8px 38px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.topbar-search-wrap input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.topbar-search-wrap input:focus {
  outline: none;
  background: #fff;
  color: var(--pos-text);
}

.topbar-search-wrap input:focus::placeholder {
  color: var(--pos-text-muted);
}

.topbar-search-wrap .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.75);
  pointer-events: none;
}

.topbar-search-wrap input:focus ~ .search-icon {
  color: var(--pos-text-muted);
}

.topbar-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  background: var(--pos-surface);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius-sm);
  box-shadow: var(--pos-shadow);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
}

.topbar-search-results a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: var(--pos-text);
}

.topbar-search-results a:hover {
  background: #f1f5f9;
}

@media (max-width: 768px) {
  .topbar-search-wrap {
    display: none;
  }
}

/* ---------- Cards / surfaces ---------- */

.pos-card {
  background: var(--pos-surface);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  box-shadow: var(--pos-shadow);
  transition: transform var(--pos-transition), box-shadow var(--pos-transition);
}

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

.pos-card-header h5 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--pos-text);
}

.pos-card-body {
  padding: 20px;
}

/* ---------- Stat tiles (dashboard, reports) ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--pos-surface);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  padding: 20px;
  box-shadow: var(--pos-shadow);
  transition: transform var(--pos-transition), box-shadow var(--pos-transition);
  position: relative;
  overflow: hidden;
}

.stat-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--pos-shadow-hover);
}

.stat-tile .stat-label {
  font-size: 11px;
  color: var(--pos-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  font-weight: 700;
}

.stat-tile .stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  font-family: "Space Grotesk", sans-serif;
  color: var(--pos-text);
}

.stat-tile .stat-sub {
  font-size: 12px;
  color: var(--pos-text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-tile.accent-primary { border-top: 4px solid var(--pos-primary); }
.stat-tile.accent-success { border-top: 4px solid var(--pos-success); }
.stat-tile.accent-danger  { border-top: 4px solid var(--pos-danger); }
.stat-tile.accent-warning { border-top: 4px solid var(--pos-warning); }

/* ---------- Tables ---------- */

.pos-table {
  width: 100%;
  border-collapse: collapse;
}

.pos-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pos-text-muted);
  padding: 12px 16px;
  border-bottom: 2px solid var(--pos-border);
  white-space: nowrap;
  font-weight: 700;
}

.pos-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--pos-border);
  vertical-align: middle;
  color: var(--pos-text);
}

.pos-table tbody tr {
  transition: background var(--pos-transition);
}

.pos-table tbody tr:hover {
  background: var(--pos-primary-light);
}

/* ---------- Status badges ---------- */

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-owed     { background: rgba(239, 68, 68, 0.08); color: var(--pos-credit-owed); }
.badge-clear    { background: rgba(16, 185, 129, 0.08); color: var(--pos-credit-clear); }
.badge-payable  { background: rgba(245, 158, 11, 0.08); color: var(--pos-payable); }
.badge-expiring { background: rgba(245, 158, 11, 0.08); color: var(--pos-expiry-soon); }
.badge-expired  { background: rgba(239, 68, 68, 0.08); color: var(--pos-expiry-expired); }
.badge-low      { background: rgba(245, 158, 11, 0.08); color: var(--pos-stock-low); }
.badge-out      { background: rgba(239, 68, 68, 0.08); color: var(--pos-stock-out); }

/* ---------- Forms & Inputs ---------- */

.pos-form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--pos-text);
  margin-bottom: 6px;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pos-required::after {
  content: " *";
  color: var(--pos-danger);
}

.form-control,
.form-select {
  border-radius: var(--pos-radius-sm);
  border: 1px solid var(--pos-border);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--pos-text);
  transition: all var(--pos-transition);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--pos-accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
  outline: none;
}

/* ---------- Buttons (complements Bootstrap, doesn't replace it) ---------- */

.btn-pos-primary {
  background: var(--pos-accent);
  border-color: var(--pos-accent);
  color: #fff;
  font-weight: 600;
  border-radius: var(--pos-radius-sm);
  padding: 10px 18px;
  transition: all var(--pos-transition);
}

.btn-pos-primary:hover {
  background: var(--pos-accent-dark);
  border-color: var(--pos-accent-dark);
  color: #fff;
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
}

/* Bootstrap's .btn:disabled has higher specificity (.btn + :disabled) than a
   single custom class, so without this it silently overrides background to
   transparent — the button goes invisible instead of looking muted. */
.btn-pos-primary:disabled,
.btn-pos-primary.disabled {
  background: var(--pos-border);
  border-color: var(--pos-border);
  color: var(--pos-text-muted);
  opacity: 0.7;
  box-shadow: none;
}

/* ---------- Utility ---------- */

.text-muted-sm {
  font-size: 12px;
  color: var(--pos-text-muted);
}

.scroll-x {
  overflow-x: auto;
}

/* ---------- Print (receipts / barcode labels) ----------
   Modules that print (pos/, barcode/) add their own print CSS file;
   this just hides the app shell so nothing but the printable node shows. */

@media print {
  .app-sidebar,
  .app-topbar,
  .no-print {
    display: none !important;
  }

  .app-content {
    padding: 0;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
  .app-sidebar {
    position: fixed;
    left: -100%;
    z-index: 1000;
    transition: left var(--pos-transition);
  }

  .app-sidebar.mobile-open {
    left: 0;
  }
}

/* ── Notification bell ────────────────────────────────────────────────────── */

.notif-panel {
  padding: 0;
  border-radius: var(--pos-radius);
  box-shadow: 0 8px 24px rgba(15,23,42,0.14);
}

.notif-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--pos-border);
  transition: background 0.15s;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item.notif-unread {
  background: #eff6ff;
}

.notif-title {
  font-size: 13px;
  line-height: 1.3;
}

.notif-body {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

/* ── Drug classification badges (POS cart + product list) ──────────────────── */

.drug-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 4px;
}

.drug-badge.narcotic   { background: rgba(220,38,38,0.12);  color: #dc2626; }
.drug-badge.controlled { background: rgba(217,119,6,0.12);  color: #d97706; }
.drug-badge.short      { background: rgba(234,179,8,0.15);  color: #b45309; }
.drug-badge.rx         { background: rgba(37,99,235,0.10);  color: #2563eb; }
.drug-badge.otc        { background: rgba(22,163,74,0.10);  color: #16a34a; }

/* ── Keyboard hint bar (POS checkout page) ─────────────────────────────────── */

.kb-hint-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  background: #f1f5f9;
  color: #475569;
  padding: 12px 24px;
  font-size: 13.5px;
  font-weight: 500;
  margin: -24px -24px 20px;
  border-bottom: 1px solid #cbd5e1;
  box-shadow: inset 0 -1px 3px rgba(0, 0, 0, 0.03);
}

.kb-hint-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 13.5px;
}

.kb-hint-bar kbd {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-bottom: 2px solid #94a3b8;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  letter-spacing: 0.02em;
}

.cart-row.active-row {
  background-color: #ecfdf5 !important;
}

/* ── Report link cards ─────────────────────────────────────────────────────── */
/* (Defined in modules/reports/styles/index.css — kept minimal here for pages
    that use report-link-card without that module CSS, e.g. pharmacy/reports.php) */
.report-link-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--pos-surface);
  border: 1px solid var(--pos-border);
  border-top: 3px solid var(--pos-primary);
  border-radius: var(--pos-radius);
  padding: 16px;
  color: var(--pos-text);
  box-shadow: var(--pos-shadow);
  transition: box-shadow 0.15s, transform 0.15s;
}

.report-link-card:hover {
  box-shadow: 0 4px 12px rgba(15,23,42,0.12);
  transform: translateY(-2px);
  color: var(--pos-primary);
}

.report-link-card i {
  font-size: 22px;
  color: var(--pos-primary);
}

.report-link-card .desc {
  font-size: 12px;
  color: var(--pos-text-muted);
  line-height: 1.4;
}

/* ── Alert list (dashboard) ────────────────────────────────────────────────── */
/* Defined in modules/dashboard/styles/index.css — this is a fallback only */

/* ── Print utilities ──────────────────────────────────────────── */
@media print {
  .no-print,
  .app-topbar,
  .app-sidebar,
  .kb-hint-bar,
  .top-brand,
  .top-nav,
  .topbar-search-wrap,
  #notif-dropdown,
  .dropdown {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .app-main, .app-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Cloud Sync — Topbar Badge
   ════════════════════════════════════════════════════════════════════════ */
.sync-topbar-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s, transform .15s;
    white-space: nowrap;
    user-select: none;
    border: 1px solid transparent;
}
.sync-topbar-badge:hover { opacity: .85; transform: translateY(-1px); }

/* States */
.sync-topbar-synced      { background: rgba(16,185,129,.12); color: #10b981; border-color: rgba(16,185,129,.25); }
.sync-topbar-syncing     { background: rgba(99,102,241,.12); color: #818cf8; border-color: rgba(99,102,241,.25); }
.sync-topbar-error       { background: rgba(239,68,68,.12);  color: #ef4444; border-color: rgba(239,68,68,.25);  }
.sync-topbar-unconfigured{ background: rgba(245,158,11,.10); color: #f59e0b; border-color: rgba(245,158,11,.25); }
.sync-topbar-unknown     { background: rgba(148,163,184,.1); color: #94a3b8; border-color: rgba(148,163,184,.2); }

/* Dots */
.sync-topbar-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.dot-green { background: #10b981; box-shadow: 0 0 0 0 rgba(16,185,129,.5); animation: sync-dot-pulse 1.8s infinite; }
.dot-blue  { background: #818cf8; animation: sync-dot-blink .6s ease-in-out infinite alternate; }
.dot-red   { background: #ef4444; }
.dot-grey  { background: #64748b; }

@keyframes sync-dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.5); }
  70%  { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
@keyframes sync-dot-blink {
  from { opacity: .4; } to { opacity: 1; }
}
