/* ═══════════════════════════════════════════════
   SMART BANDAGE AI — DESIGN SYSTEM (main.css)
   Inspired by: dark glassmorphism + vibrant green
   ═══════════════════════════════════════════════ */
:root {
  --bg:           #070e1c;
  --bg2:          #0d1929;
  --bg3:          #111f35;
  --surface:      rgba(255,255,255,0.04);
  --surface2:     rgba(255,255,255,0.07);
  --surface3:     rgba(255,255,255,0.10);
  --border:       rgba(255,255,255,0.07);
  --border2:      rgba(255,255,255,0.13);

  --green:        #00e5a0;
  --green-dim:    rgba(0,229,160,0.12);
  --green-glow:   rgba(0,229,160,0.35);
  --green-dark:   #00b87d;

  --teal:         #00d4c8;
  --teal-dim:     rgba(0,212,200,0.12);

  --purple:       #7c3aed;
  --purple-dim:   rgba(124,58,237,0.18);

  --ok:           #22c55e;
  --ok-dim:       rgba(34,197,94,0.14);
  --warn:         #f59e0b;
  --warn-dim:     rgba(245,158,11,0.16);
  --danger:       #ef4444;
  --danger-dim:   rgba(239,68,68,0.16);

  --text:         #f0f6ff;
  --text-muted:   #8fa3be;
  --text-dim:     #445566;

  --radius:       14px;
  --radius-sm:    10px;
  --radius-lg:    20px;
  --radius-xl:    24px;

  --shadow:       0 8px 32px rgba(0,0,0,0.5);
  --shadow-green: 0 0 24px rgba(0,229,160,0.25);

  --font-head:    'Space Grotesk', sans-serif;
  --font-body:    'Inter', sans-serif;

  --header-h:    64px;
  --mobile-nav-h:68px;
}

/* ── RESET ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  background-image: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0,229,160,0.08) 0%, transparent 60%);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select { font-family: inherit; }
svg { display: block; flex-shrink: 0; }
.hidden { display: none !important; }

/* ── SCROLLBAR ─────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

h1,h2,h3,h4 { font-family: var(--font-head); line-height: 1.2; }

/* ── BUTTONS ───────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--green), var(--teal));
  color: #060d1f; font-weight: 700; font-size: 13px;
  border: none;
  transition: opacity .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 16px rgba(0,229,160,0.3);
}
.btn-primary:hover { opacity:.9; transform:translateY(-1px); box-shadow: var(--shadow-green); }
.btn-primary:active { transform:translateY(0); }
.btn-primary:disabled { opacity:.35; pointer-events:none; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text-muted);
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--border2);
  transition: all .2s;
}
.btn-secondary:hover { color: var(--text); border-color: var(--green); background: var(--green-dim); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border);
  transition: all .2s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border2); }

.btn-sm { padding: 5px 11px !important; }

.btn-icon {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all .2s;
}
.btn-icon:hover { color: var(--text); border-color: var(--green); background: var(--green-dim); }

.btn-connect {
  padding: 7px 16px; border-radius: 99px;
  background: var(--green-dim); color: var(--green);
  font-size: 12px; font-weight: 700;
  border: 1px solid rgba(0,229,160,0.35);
  transition: all .2s;
  letter-spacing: .2px;
}
.btn-connect:hover { background: rgba(0,229,160,0.22); box-shadow: var(--shadow-green); }

.btn-release {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--purple), #9333ea);
  color: #fff; font-weight: 700; font-size: 14px;
  border: none;
  transition: opacity .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 20px rgba(124,58,237,0.4);
}
.btn-release:hover { opacity:.9; transform:translateY(-1px); box-shadow:0 8px 28px rgba(124,58,237,0.55); }
.btn-release:active { transform:translateY(0); }

/* ── BADGE ─────────────────────────────────── */
.badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 99px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}

/* ── ALERT BANNER ──────────────────────────── */
.alert-banner {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 200;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px;
  background: rgba(239,68,68,0.1);
  border-bottom: 1px solid rgba(239,68,68,0.35);
  backdrop-filter: blur(12px);
  animation: slideDown .3s ease;
}
.alert-banner__icon { font-size: 20px; }
.alert-banner__body { flex:1; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.alert-banner__body strong { color: var(--danger); font-weight: 600; }
.alert-banner__close { color: var(--text-muted); font-size: 16px; padding: 4px; border-radius:4px; transition: color .2s; }
.alert-banner__close:hover { color: var(--text); }

/* ── HEADER ────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: rgba(7,14,28,0.80);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  gap: 12px;
}
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(0,229,160,0.2), rgba(0,212,200,0.1));
  border: 1px solid rgba(0,229,160,0.3);
  display: flex; align-items: center; justify-content: center;
  animation: logoPulse 3s ease infinite;
}
.logo-text { display: flex; flex-direction: column; line-height: 1; }
.logo-name { font-family: var(--font-head); font-weight: 700; font-size: 15px; letter-spacing: -.3px; }
.logo-sub  { font-size: 10px; color: var(--green); font-weight: 600; letter-spacing: .6px; text-transform: uppercase; margin-top: 2px; }

.patient-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px; border-radius: 99px;
  background: var(--surface2); border: 1px solid var(--border);
  cursor: pointer; transition: border-color .2s;
}
.patient-chip:hover { border-color: var(--green); }
.patient-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--teal));
  color: #060d1f; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.patient-name { font-size: 13px; font-weight: 500; }
.patient-id   { font-size: 11px; color: var(--text-muted); }

.conn-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  animation: connPulse 2s infinite;
}
.conn-dot.disconnected { background: var(--text-dim); animation: none; box-shadow: none; }

/* ── PANEL BASE ────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  overflow: hidden;
  transition: border-color .3s;
  backdrop-filter: blur(10px);
}
.panel:hover { border-color: var(--border2); }

.panel-hdr {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-shrink: 0;
}
.panel-title {
  font-family: var(--font-head); font-size: 14px; font-weight: 600;
  color: var(--text); letter-spacing: -.2px;
}
.panel-sub { font-size: 11px; color: var(--text-muted); font-weight: 400; font-family: var(--font-body); }

.live-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.22);
  color: var(--ok); font-size: 10px; font-weight: 700; letter-spacing: 1px;
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); animation: livePulse 1.4s ease infinite;
}

/* ── FORM FIELDS ───────────────────────────── */
.field-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.field-input, .field-select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
  transition: border-color .2s;
  appearance: none;
}
.field-input:focus, .field-select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
.field-hint { font-size: 11px; color: var(--text-dim); margin-top: 5px; }

/* ── MODALS ────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
  animation: fadeIn .2s ease;
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 460px;
  box-shadow: var(--shadow);
  animation: slideUp .25s ease;
}
.modal-sm { max-width: 360px; }
.modal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.modal-hdr h3 { font-family: var(--font-head); font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }

.setting-group { display: flex; flex-direction: column; }
.api-key-row { display: flex; gap: 8px; }
.api-key-row .field-input { flex: 1; }
.scenario-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.connect-options { display: flex; flex-direction: column; gap: 10px; }
.connect-opt {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  text-align: left; color: var(--text); font-size: 13px;
  transition: all .2s; cursor: pointer;
}
.connect-opt:hover, .connect-opt.active { border-color: var(--green); background: var(--green-dim); }
.conn-opt-icon { font-size: 24px; }

.confirm-detail {
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--purple-dim); border: 1px solid rgba(124,58,237,0.3);
  font-size: 13px; line-height: 1.6;
}
.confirm-warn {
  font-size: 12px; color: var(--warn); padding: 10px 12px;
  background: var(--warn-dim); border-radius: var(--radius-sm);
  border: 1px solid rgba(245,158,11,0.3);
}
.confirm-btns { display: flex; gap: 10px; justify-content: flex-end; }

/* ── MOBILE NAV ────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--mobile-nav-h);
  background: rgba(13,25,41,0.95);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px);
  padding: 0 4px;
  align-items: center; justify-content: space-around;
}
.mnav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 10px; font-weight: 500;
  transition: color .2s; min-width: 0;
}
.mnav-btn.active { color: var(--green); }
.mnav-btn svg { stroke: currentColor; }

/* ── ANIMATIONS ────────────────────────────── */
@keyframes logoPulse {
  0%,100% { box-shadow: 0 0 0 0 var(--green-glow); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}
@keyframes connPulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.6); }
  70%  { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
@keyframes livePulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%     { opacity:.4; transform:scale(.7); }
}
@keyframes slideDown { from { transform:translateY(-100%); } to { transform:translateY(0); } }
@keyframes slideUp { from { transform:translateY(30px); opacity:0; } to { transform:translateY(0); opacity:1; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  40%     { transform: translateX(8px); }
  60%     { transform: translateX(-6px); }
  80%     { transform: translateX(6px); }
}

/* App shell — hidden by default, shown by auth */
#app-shell { display: none; }
#app-shell:not(.hidden) { display: block; }
