:root {
  --sidebar-w: 250px;
  --sidebar-bg: #1a3c5e;
  --sidebar-hover: #2a5a8f;
  --sidebar-active: #f39c12;
  --topbar-h: 56px;
  --accent: #2a5a8f;
  --accent2: #f39c12;
  --danger: #c0392b;
  --success: #27ae60;
  --warning: #e67e22;
  --card-shadow: 0 2px 12px rgba(0,0,0,.08);
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; background: #f0f2f5; color: #333; display: flex; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  left: 0; top: 0;
  display: flex; flex-direction: column;
  transition: transform .3s;
  z-index: 1000;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 18px 20px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand i { color: var(--accent2); font-size: 22px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-group-label {
  color: rgba(255,255,255,.4);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  padding: 14px 20px 4px;
  text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  transition: all .2s;
  border-left: 3px solid transparent;
  font-size: 13.5px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-hover); color: #fff; border-left-color: var(--accent2); }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.8);
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent2);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; opacity: .65; }
.sidebar-user a { color: rgba(255,255,255,.5); font-size: 16px; }
.sidebar-user a:hover { color: var(--accent2); }

/* ── MAIN ── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .3s;
}
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: #555; padding: 6px;
  border-radius: 6px;
}
.sidebar-toggle:hover { background: #f0f2f5; }
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; color: #222; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-badge {
  position: relative; color: #555;
  font-size: 18px; text-decoration: none;
}
.topbar-badge span {
  position: absolute; top: -6px; right: -8px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 10px; padding: 1px 5px;
}
.topbar-date { font-size: 12px; color: #888; }
.page-content { padding: 24px; flex: 1; }

/* ── CARDS ── */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); border: none; margin-bottom: 20px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid #f0f0f0; font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 10px; background: transparent; }
.card-body { padding: 20px; }

/* ── STAT CARDS ── */
.stat-card {
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  color: #fff;
  box-shadow: var(--card-shadow);
}
.stat-card.blue  { background: linear-gradient(135deg, #2a5a8f, #1a3c5e); }
.stat-card.green { background: linear-gradient(135deg, #27ae60, #1e8449); }
.stat-card.amber { background: linear-gradient(135deg, #f39c12, #d68910); }
.stat-card.red   { background: linear-gradient(135deg, #c0392b, #922b21); }
.stat-card.teal  { background: linear-gradient(135deg, #16a085, #0e6655); }
.stat-card .icon { font-size: 36px; opacity: .8; }
.stat-card .info { flex: 1; }
.stat-card .value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-card .label { font-size: 12px; opacity: .85; margin-top: 4px; }

/* ── TABLES ── */
.table-responsive { border-radius: var(--radius); overflow: hidden; }
.table th { font-size: 12px; font-weight: 700; letter-spacing: .5px; color: #555; background: #f8f9fa; text-transform: uppercase; }
.table td, .table th { padding: 11px 14px; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fbff; }

/* ── BADGES ── */
.badge-role-admin       { background: #1a3c5e; color:#fff; }
.badge-role-pharmacist  { background: #27ae60; color:#fff; }
.badge-role-cashier     { background: #8e44ad; color:#fff; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success { background: #d5f5e3; color: #1e8449; }
.badge-danger  { background: #fdecea; color: #c0392b; }
.badge-warning { background: #fef9e7; color: #d35400; }
.badge-info    { background: #eaf4fb; color: #1a5276; }
.badge-secondary { background: #f0f0f0; color: #666; }

/* ── BUTTONS ── */
.btn-primary   { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #1a3c5e; border-color: #1a3c5e; }
.btn-warning   { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn-sm { font-size: 12px; padding: 5px 10px; }
.btn-icon { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border-radius: 6px; }

/* ── FORMS ── */
.form-control, .form-select { border-radius: 7px; border-color: #ddd; font-size: 14px; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(42,90,143,.15); }
.form-label { font-weight: 600; font-size: 13px; color: #444; margin-bottom: 5px; }
.input-group-text { background: #f8f9fa; border-color: #ddd; }

/* ── ALERT BOXES ── */
.alert { border-radius: 8px; border: none; font-size: 13.5px; }
.alert-low-stock { background: #fef9e7; border-left: 4px solid var(--warning); color: #7d6608; padding: 12px 16px; border-radius: 6px; }
.alert-expiry    { background: #fdecea; border-left: 4px solid var(--danger); color: #7b241c; padding: 12px 16px; border-radius: 6px; }

/* ── POS ── */
.pos-wrapper { display: grid; grid-template-columns: 1fr 380px; gap: 20px; height: calc(100vh - 104px); }
.pos-left { display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.pos-right { background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); display: flex; flex-direction: column; overflow: hidden; }
.pos-search { position: relative; }
.pos-search input { border-radius: 8px; padding: 10px 16px 10px 40px; font-size: 15px; width: 100%; border: 2px solid #ddd; }
.pos-search input:focus { border-color: var(--accent); outline: none; }
.pos-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #aaa; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; overflow-y: auto; padding: 4px 2px; }
.pos-med-card {
  background: #fff; border-radius: 10px; padding: 14px 12px;
  cursor: pointer; border: 2px solid #eee;
  transition: all .15s; text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.pos-med-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(42,90,143,.15); }
.pos-med-card .med-name { font-weight: 600; font-size: 13px; color: #333; margin-bottom: 4px; }
.pos-med-card .med-price { color: var(--accent); font-weight: 700; font-size: 15px; }
.pos-med-card .med-stock { font-size: 11px; color: #888; margin-top: 3px; }
.pos-med-card.out-of-stock { opacity: .5; pointer-events: none; }
.cart-header { padding: 16px; border-bottom: 1px solid #eee; font-weight: 700; font-size: 15px; }
.cart-items { flex: 1; overflow-y: auto; padding: 10px; }
.cart-item { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid #f5f5f5; }
.cart-item-name { flex: 1; font-size: 13px; font-weight: 600; }
.cart-item-price { font-size: 12px; color: #888; }
.cart-qty { display: flex; align-items: center; gap: 6px; }
.cart-qty button { width: 24px; height: 24px; border: 1px solid #ddd; background: #f8f9fa; border-radius: 4px; cursor: pointer; font-size: 13px; }
.cart-total-section { padding: 16px; border-top: 1px solid #eee; }
.cart-total-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; color: #666; }
.cart-total-row.grand { font-size: 18px; font-weight: 700; color: #333; margin-top: 8px; padding-top: 8px; border-top: 2px solid #eee; }
.btn-checkout { width: 100%; padding: 14px; background: var(--success); color: #fff; font-size: 16px; font-weight: 700; border: none; border-radius: 8px; cursor: pointer; margin-top: 10px; transition: background .2s; }
.btn-checkout:hover { background: #1e8449; }
.btn-checkout:disabled { background: #aaa; cursor: not-allowed; }

/* ── STOCK STATUS ── */
.stock-ok      { color: var(--success); font-weight: 600; }
.stock-low     { color: var(--warning); font-weight: 600; }
.stock-out     { color: var(--danger);  font-weight: 600; }
.stock-expiring { color: var(--danger); font-weight: 600; }

/* ── PAGE HEADER ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h4 { font-weight: 700; color: #1a3c5e; margin: 0; }

/* ── LOGIN PAGE ── */
.login-page { min-height: 100vh; background: linear-gradient(135deg, #1a3c5e 0%, #2a5a8f 60%, #f39c12 100%); display: flex; align-items: center; justify-content: center; }
.login-box { background: #fff; border-radius: 14px; padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo i { font-size: 48px; color: #f39c12; }
.login-logo h2 { margin: 8px 0 2px; font-weight: 800; color: #1a3c5e; }
.login-logo p { color: #888; font-size: 13px; }
.login-box .form-control { padding: 12px 14px; font-size: 15px; }
.btn-login { width: 100%; padding: 13px; background: #1a3c5e; color: #fff; border: none; border-radius: 8px; font-size: 16px; font-weight: 700; cursor: pointer; transition: background .2s; margin-top: 6px; }
.btn-login:hover { background: #2a5a8f; }
.forgot-link { text-align: center; margin-top: 14px; font-size: 13px; color: #666; }
.forgot-link a { color: #2a5a8f; text-decoration: none; font-weight: 600; }

/* ── MODAL OVERRIDE ── */
.modal-header { background: #1a3c5e; color: #fff; border-radius: 10px 10px 0 0; }
.modal-header .btn-close { filter: invert(1); }
.modal-title { font-weight: 700; }

/* ── RECEIPT ── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 0; }
  body { background: #fff; }
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .pos-wrapper { grid-template-columns: 1fr; }
  .pos-right { height: 400px; }
}
