/* PharmStore — Main Stylesheet */
:root {
  --primary:        #0F6E56;
  --primary-dark:   #085041;
  --primary-light:  #E1F5EE;
  --primary-text:   #04342C;

  --danger:         #DC2626;
  --danger-bg:      #FEF2F2;
  --danger-border:  #FECACA;

  --warning:        #D97706;
  --warning-bg:     #FFFBEB;
  --warning-border: #FDE68A;

  --warn3:          #B45309;
  --warn3-bg:       #FAEEDA;
  --warn3-border:   #FAC775;

  --success:        #16A34A;
  --success-bg:     #F0FDF4;
  --success-border: #BBF7D0;

  --info:           #2563EB;
  --info-bg:        #EFF6FF;

  --bg:             #F4F6F9;
  --surface:        #FFFFFF;
  --surface2:       #F8FAFC;
  --border:         #E2E8F0;
  --border-dark:    #CBD5E1;

  --text:           #1E293B;
  --text-muted:     #64748B;
  --text-light:     #94A3B8;

  --sidebar-w:      240px;
  --header-h:       58px;
  --radius:         8px;
  --radius-lg:      12px;
}

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

html { font-size: 15px; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ── Auth Layout ─────────────────────────────── */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg); padding: 20px;
}
.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 36px 40px;
  width: 100%; max-width: 420px;
}
.auth-logo {
  display: flex; align-items: center; gap: 14px; margin-bottom: 28px;
}
.auth-logo .logo-icon {
  width: 48px; height: 48px; background: var(--primary); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.auth-logo .logo-text { font-size: 18px; font-weight: 600; }
.auth-logo .logo-sub  { font-size: 12px; color: var(--text-muted); }

/* ── App Shell ───────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px; background: var(--primary); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.sidebar-logo .logo-text { font-size: 15px; font-weight: 600; line-height: 1.2; }
.sidebar-logo .logo-ver  { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section { margin-bottom: 18px; }
.nav-section-label {
  font-size: 10px; font-weight: 600; color: var(--text-light);
  letter-spacing: .06em; text-transform: uppercase;
  padding: 0 8px; margin-bottom: 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--text-muted); font-size: 13.5px;
  text-decoration: none; transition: all .15s;
  cursor: pointer;
}
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { background: var(--primary-light); color: var(--primary-text); font-weight: 500; }
.nav-link .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 600; border-radius: 10px;
  padding: 1px 6px; min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--primary-text);
  flex-shrink: 0;
}
.user-name  { font-size: 13px; font-weight: 500; }
.user-role  { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.page-content { padding: 24px; flex: 1; }

/* ── Components ──────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.card + .card, .card + .row, .row + .card { margin-top: 18px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}

.row { display: flex; gap: 18px; }
.col { flex: 1; min-width: 0; }
.col-auto { flex: 0 0 auto; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-label {
  font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.stat-value { font-size: 22px; font-weight: 600; color: var(--text); }
.stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Buttons ──────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border-dark);
  background: var(--surface); color: var(--text);
  text-decoration: none; transition: all .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger  { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover { background: #FEE2E2; }
.btn-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 7px; }

/* ── Forms ────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text-muted); margin-bottom: 5px;
}
.form-control {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit;
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Tables ───────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 9px 12px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }
.row-expired  td { background: #FFF5F5 !important; }
.row-warn3    td { background: #FFFBF0 !important; }

/* ── Badges ───────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-ok      { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-warn6   { background: #EAF3DE; color: #3B6D11; border: 1px solid #C0DD97; }
.badge-warn3   { background: var(--warn3-bg); color: var(--warn3); border: 1px solid var(--warn3-border); }
.badge-expired { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-low     { background: #FAECE7; color: #712B13; border: 1px solid #F5C4B3; }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-admin   { background: #F3E8FF; color: #7C3AED; }
.badge-pharmacist { background: var(--primary-light); color: var(--primary-text); }

/* ── Alerts ───────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 12px;
}
.alert-danger  { background: var(--danger-bg); border: 1px solid var(--danger-border); color: #991B1B; }
.alert-warning { background: var(--warn3-bg); border: 1px solid var(--warn3-border); color: var(--warn3); }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success); }
.alert-info    { background: var(--info-bg); border: 1px solid #BFDBFE; color: #1D4ED8; }

/* ── Modal ────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 200; display: flex; align-items: flex-start;
  justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px; width: 100%; max-width: 580px;
  animation: slideDown .2s ease;
}
.modal-lg { max-width: 720px; }
@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Receipt ──────────────────────────────────── */
.receipt {
  font-size: 12.5px; padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 360px; margin: 0 auto;
}
.receipt-header { text-align: center; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--border-dark); }
.receipt-header h2 { font-size: 16px; color: var(--primary); margin-bottom: 2px; }
.receipt-meta  { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--border-dark); }
.receipt-meta p { display: flex; justify-content: space-between; margin-bottom: 3px; }
.receipt-items { margin-bottom: 10px; }
.receipt-item  { display: flex; justify-content: space-between; margin-bottom: 4px; }
.receipt-total-section { border-top: 1px dashed var(--border-dark); padding-top: 8px; }
.receipt-total-section .receipt-item { margin-bottom: 4px; }
.receipt-grandtotal { font-size: 14px; font-weight: 700; color: var(--primary); margin-top: 4px; }
.receipt-footer { text-align: center; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border-dark); font-size: 11px; color: var(--text-muted); }

/* ── Misc ─────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted); font-size: 13px;
}
.empty-state .empty-icon { font-size: 32px; margin-bottom: 10px; }

.search-row { display: flex; gap: 8px; margin-bottom: 14px; }
.search-row .form-control { flex: 1; }

.expiry-bar {
  height: 4px; border-radius: 2px;
  background: var(--border); margin-top: 4px;
}
.expiry-bar-fill { height: 100%; border-radius: 2px; }

.progress-bar  { height: 6px; background: var(--border); border-radius: 3px; margin-top: 4px; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--primary); }

a { color: inherit; text-decoration: none; }

.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.fw-600       { font-weight: 600; }
.fs-12        { font-size: 12px; }
.fs-11        { font-size: 11px; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mb-0         { margin-bottom: 0; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-8        { gap: 8px; }
.ms-auto      { margin-left: auto; }

/* ── Print ────────────────────────────────────── */
@media print {
  .no-print { display: none !important; }
  .modal-overlay { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; border: none; max-width: 100%; }
  body { background: #fff; }
}

/* ── Scrollbar ────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
