/* =============================================================
   MediStore POS - stylesheet
   Clinical pharmacy admin theme. Teal primary, semantic alert
   colours, IBM Plex Sans for legible tabular data.
   ============================================================= */

:root {
  --bg:        #f5f8f8;
  --surface:   #ffffff;
  --surface-2: #f0f4f5;
  --ink:       #16232b;
  --muted:     #5c6f79;
  --faint:     #8fa1aa;
  --line:      #e2e9ec;
  --line-2:    #cfdbdf;

  --brand:     #0f7d6b;
  --brand-ink: #0a5a4d;
  --brand-soft:#e3f2ef;

  --danger:    #d1495b;
  --danger-soft:#fbe8ea;
  --warn:      #d9820a;
  --warn-soft: #fcf0dd;
  --ok:        #2f9e44;
  --ok-soft:   #e5f4e8;
  --info:      #2b6cb0;
  --info-soft: #e6eff8;

  --radius:    9px;
  --radius-sm: 6px;
  --shadow:    0 1px 2px rgba(22,35,43,.06), 0 1px 1px rgba(22,35,43,.04);
  --sidebar-w: 236px;

  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }

/* tabular figures everywhere numbers matter */
.num, td.num, .stat-value, table td { font-variant-numeric: tabular-nums; }

/* ---------------- App shell ---------------- */

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #0c2a29;
  color: #cfe3df;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; flex: 0 0 auto;
}
.sidebar-brand .name { color: #fff; font-weight: 600; font-size: 15px; letter-spacing: .1px; }
.sidebar-brand .sub  { color: #7fb0a6; font-size: 11px; }

.nav { padding: 10px 10px 20px; overflow-y: auto; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-group-label {
  padding: 6px 10px; font-size: 11px; letter-spacing: .04em;
  color: #6f958d; text-transform: none; font-weight: 600;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: #bcd6d0; font-size: 13.5px; text-decoration: none;
  margin: 1px 0;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav a .ic { width: 17px; height: 17px; flex: 0 0 auto; opacity: .9; }

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

.topbar {
  height: 58px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.topbar .store { font-weight: 600; }
.topbar .store small { color: var(--muted); font-weight: 400; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.user-chip .meta { line-height: 1.2; }
.user-chip .meta .r { color: var(--muted); font-size: 12px; text-transform: capitalize; }

.content { padding: 22px; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-head .subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------- Cards & stats ---------------- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-body { padding: 16px; }

.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .stat-value { font-size: 24px; font-weight: 600; margin-top: 4px; letter-spacing: -.01em; }
.stat .foot { font-size: 12px; color: var(--faint); margin-top: 3px; }
.stat.accent { border-left: 3px solid var(--brand); }

/* ---------------- Alert strip (dashboard hero) ---------------- */

.alerts { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.alert-card {
  display: flex; align-items: center; gap: 13px;
  border-radius: var(--radius); padding: 14px 16px;
  border: 1px solid var(--line); background: var(--surface);
}
.alert-card .figure { font-size: 26px; font-weight: 700; line-height: 1; }
.alert-card .text { line-height: 1.3; }
.alert-card .text .t { font-weight: 600; }
.alert-card .text .s { color: var(--muted); font-size: 12.5px; }
.alert-card.is-danger { background: var(--danger-soft); border-color: #f2c4cb; }
.alert-card.is-danger .figure { color: var(--danger); }
.alert-card.is-warn   { background: var(--warn-soft);  border-color: #f0d6a3; }
.alert-card.is-warn   .figure { color: var(--warn); }
.alert-card.is-info   { background: var(--info-soft);  border-color: #c4d8ee; }
.alert-card.is-info   .figure { color: var(--info); }
.alert-card.is-ok     { background: var(--ok-soft);    border-color: #bfe3c8; }
.alert-card.is-ok     .figure { color: var(--ok); }
.alert-card a.more { margin-left: auto; font-size: 12.5px; }

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

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 10px 14px; color: var(--muted);
  font-weight: 600; font-size: 12.5px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surface-2);
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; }
table.data .muted { color: var(--muted); }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--ink); margin-bottom: 4px; font-weight: 600; }

/* ---------------- Badges ---------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.badge.b-ok     { background: var(--ok-soft);     color: #1e6b2c; border-color: #bfe3c8; }
.badge.b-danger { background: var(--danger-soft); color: #9e2a3a; border-color: #f2c4cb; }
.badge.b-warn   { background: var(--warn-soft);   color: #8a5300; border-color: #f0d6a3; }
.badge.b-info   { background: var(--info-soft);   color: #1f4f85; border-color: #c4d8ee; }
.badge.b-muted  { background: var(--surface-2);   color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ---------------- Forms ---------------- */

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field label .req { color: var(--danger); }
input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], input[type=search], select, textarea {
  font: inherit; font-size: 14px; color: var(--ink);
  padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand-soft); outline-offset: 0; border-color: var(--brand);
}
.hint { font-size: 12px; color: var(--faint); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.toolbar .search input { padding-left: 34px; }
.toolbar .search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); }

/* ---------------- Toasts ---------------- */

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 260px; max-width: 360px; background: var(--ink); color: #fff;
  padding: 12px 15px; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.18);
  display: flex; align-items: flex-start; gap: 10px; animation: toast-in .25s ease;
}
.toast .bar { width: 3px; align-self: stretch; border-radius: 3px; background: var(--brand); }
.toast.success .bar { background: var(--ok); }
.toast.error   .bar { background: var(--danger); }
.toast.info    .bar { background: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------- Login ---------------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 20% -10%, #123f3a 0%, #0c2a29 55%, #0a2321 100%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; }
.login-card .top { padding: 26px 28px 6px; }
.login-card .brand-row { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.login-card .brand-row .logo { width: 38px; height: 38px; border-radius: 10px; background: var(--brand);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; }
.login-card form { padding: 6px 28px 28px; display: flex; flex-direction: column; gap: 13px; }
.login-error { background: var(--danger-soft); color: #9e2a3a; border: 1px solid #f2c4cb;
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.login-hint { text-align: center; color: var(--faint); font-size: 12px; padding: 0 28px 20px; }

/* ---------------- Utilities ---------------- */

.row { display: flex; gap: 12px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.muted { color: var(--muted); }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.pill-link { font-size: 12.5px; }
.hide { display: none; }

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

.menu-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
  .menu-toggle { display: inline-flex; }
  .form-grid { grid-template-columns: 1fr; }
}
