/* ===== MedPlus Pharmacy POS - Theme ===== */
:root {
  --bg: #0f172a;
  --bg2: #111c33;
  --panel: #16223d;
  --panel2: #1c2b4a;
  --border: #25365c;
  --text: #e8eefb;
  --muted: #93a4c4;
  --primary: #22c1a4;
  --primary-d: #159e85;
  --accent: #3b82f6;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #22c55e;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 11px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }

/* Layout */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 230px; background: linear-gradient(180deg,#0d1730,#0b1326);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.brand { padding: 18px 18px 12px; display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg,var(--primary),var(--accent));
  display: grid; place-items: center; font-size: 20px; font-weight: 800; color: #04121b;
}
.brand h1 { font-size: 16px; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 11px; }
.nav { flex: 1; overflow-y: auto; padding: 8px; }
.nav button {
  width: 100%; text-align: left; background: transparent; color: var(--muted);
  border: none; padding: 11px 13px; border-radius: 9px; font-size: 14px;
  display: flex; align-items: center; gap: 11px; margin-bottom: 2px; transition: .12s;
}
.nav button .ic { width: 20px; text-align: center; }
.nav button:hover { background: var(--panel); color: var(--text); }
.nav button.active { background: var(--primary); color: #04121b; font-weight: 700; }
.nav .group-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #5b6b8c; padding: 14px 13px 5px; }
.sidebar-footer { padding: 10px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.online-dot { display:inline-block; width:8px;height:8px;border-radius:50%;background:var(--ok);margin-right:6px; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 60px; border-bottom: 1px solid var(--border); background: var(--bg2);
  display: flex; align-items: center; padding: 0 20px; gap: 14px; flex-shrink: 0;
}
.topbar h2 { font-size: 18px; flex: 1; }
.topbar .clock { color: var(--muted); font-size: 13px; }
.view { flex: 1; overflow-y: auto; padding: 20px; }

/* Buttons */
.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  padding: 9px 15px; border-radius: 9px; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px; transition: .12s;
}
.btn:hover { background: var(--panel); }
.btn.primary { background: var(--primary); color: #04121b; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-d); }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.warn { background: var(--warn); color: #04121b; border-color: var(--warn); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Cards & grids */
.cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.card .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.card .v { font-size: 26px; font-weight: 800; margin-top: 6px; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.card .corner { position:absolute; right:-12px; top:-12px; font-size:62px; opacity:.08; }
.card.good { border-left: 4px solid var(--ok); }
.card.warn { border-left: 4px solid var(--warn); }
.card.bad  { border-left: 4px solid var(--danger); }
.card.info { border-left: 4px solid var(--accent); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.panel-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.panel-head h3 { margin-bottom: 0; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar .search { flex: 1; min-width: 220px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; background: var(--panel); z-index: 1; }
tbody tr:hover { background: var(--panel2); }
td .actions { display: flex; gap: 6px; }
.table-wrap { max-height: 60vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }

/* Badges */
.badge { padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; display: inline-block; }
.badge.ok { background: rgba(34,197,94,.16); color: #6ee7a8; }
.badge.warn { background: rgba(245,158,11,.16); color: #fcd34d; }
.badge.bad { background: rgba(239,68,68,.16); color: #fca5a5; }
.badge.info { background: rgba(59,130,246,.16); color: #93c5fd; }
.badge.muted { background: var(--panel2); color: var(--muted); }

/* POS / Billing */
.pos { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; height: 100%; }
.pos-left, .pos-right { display: flex; flex-direction: column; min-height: 0; }
.pos-cart { flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.pos-search-results { max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: 9px; margin-top: 6px; }
.pos-search-results .item { padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: pointer; display:flex; justify-content:space-between; gap:10px; }
.pos-search-results .item:hover, .pos-search-results .item.sel { background: var(--primary); color: #04121b; }
.pos-search-results .item small { color: var(--muted); }
.pos-search-results .item:hover small, .pos-search-results .item.sel small { color: #04121b; }
.summary { background: var(--panel2); border-radius: var(--radius); padding: 14px 16px; }
.summary .line { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; }
.summary .line.total { font-size: 22px; font-weight: 800; border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 12px; color: var(--primary); }
.qty-input { width: 72px; padding: 7px; text-align: center; }
.price-input { width: 92px; padding: 7px; text-align: right; }
input:disabled { opacity: .4; cursor: not-allowed; background: var(--panel); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(4,9,20,.7); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-bg.show { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; }
.modal.lg { max-width: 860px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.x { background: transparent; border: none; color: var(--muted); font-size: 22px; line-height: 1; }

/* Toast */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow); min-width: 240px; animation: slidein .25s ease; }
.toast.bad { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.empty { text-align: center; padding: 40px; color: var(--muted); }
.empty .big { font-size: 44px; opacity: .5; margin-bottom: 10px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.tag-row { display:flex; gap:6px; flex-wrap:wrap; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.divider { height:1px; background:var(--border); margin:14px 0; }
hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* Login */
.login-bg { position: fixed; inset: 0; background: radial-gradient(circle at 30% 20%, #16305c, #0a1124); display: grid; place-items: center; z-index: 300; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 34px; width: 360px; box-shadow: var(--shadow); text-align: center; }
.login-card .logo { width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(135deg,var(--primary),var(--accent)); display: grid; place-items: center; font-size: 32px; font-weight: 800; color: #04121b; margin: 0 auto 14px; }
.pinpad { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 16px; }
.pinpad button { padding: 16px; font-size: 18px; font-weight: 700; background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; color: var(--text); }
.pinpad button:hover { background: var(--primary); color: #04121b; }
.pin-display { letter-spacing: 12px; font-size: 26px; margin: 14px 0; height: 30px; }

/* Print area hidden on screen */
#printArea { display: none; }

@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea { display: block; position: absolute; left: 0; top: 0; width: 100%; color: #000; }
}
