/* Smart Medicine Finder - Futuristic Glassmorphism Design System */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg-dark: #070b14;
  --bg-surface: rgba(15, 23, 42, 0.75);
  --bg-surface-elevated: rgba(30, 41, 59, 0.85);
  --bg-glass-card: rgba(15, 23, 42, 0.65);
  
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-bright: rgba(56, 189, 248, 0.25);
  --border-laser: rgba(16, 185, 129, 0.4);

  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.35);
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.35);
  --accent-purple: #a855f7;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --font-main: 'Outfit', -apple-system, sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-glow-emerald: 0 0 24px rgba(16, 185, 129, 0.25);
  --shadow-glow-cyan: 0 0 24px rgba(6, 182, 212, 0.25);
  --shadow-elevation: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
}

/* 3D Canvas Container */
#webgl-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: auto;
}

#webgl-container canvas {
  display: block;
  width: 100vw !important;
  height: 100vh !important;
}

/* Overlay App Shell */
.app-shell {
  position: relative;
  z-index: 10;
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  pointer-events: none;
}

/* Interactive elements inside HUD */
.interactive {
  pointer-events: auto;
}

/* Glassmorphism Panel Base */
.glass-panel {
  background: var(--bg-glass-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevation);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-panel:hover {
  border-color: var(--border-glass-bright);
}

/* ----------------- Top Navigation Bar ----------------- */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: rgba(10, 14, 23, 0.7);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon-box {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.3));
  border: 1px solid var(--border-laser);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-emerald);
  box-shadow: var(--shadow-glow-emerald);
}

.brand-title-wrap h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #ffffff 30%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-title-wrap .sub-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--accent-emerald);
  font-family: var(--font-mono);
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Modern Buttons */
.btn-modern {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-modern:hover {
  transform: translateY(-1px);
  border-color: var(--border-glass-bright);
  background: rgba(51, 65, 85, 0.9);
}

.btn-primary {
  background: linear-gradient(135deg, #059669, #0d9488);
  border-color: var(--accent-emerald);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #10b981, #14b8a6);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-icon-only {
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ----------------- Main Viewport Layout ----------------- */
.main-content {
  display: grid;
  grid-template-columns: 370px 1fr 350px;
  padding: 14px 18px;
  gap: 16px;
  height: calc(100vh - 126px);
  overflow: hidden;
}

/* Left Sidebar - Search & Full-Height Medicine List */
.left-hud-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  overflow: hidden;
  padding: 14px;
}

/* Sleek Slim Scrollbars */
.left-hud-panel *::-webkit-scrollbar,
.right-hud-panel::-webkit-scrollbar,
.med-list-container::-webkit-scrollbar,
.serial-terminal-view::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.left-hud-panel *::-webkit-scrollbar-track,
.right-hud-panel::-webkit-scrollbar-track,
.med-list-container::-webkit-scrollbar-track,
.serial-terminal-view::-webkit-scrollbar-track {
  background: transparent;
}

.left-hud-panel *::-webkit-scrollbar-thumb,
.right-hud-panel::-webkit-scrollbar-thumb,
.med-list-container::-webkit-scrollbar-thumb,
.serial-terminal-view::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.25);
  border-radius: 6px;
}

.left-hud-panel *::-webkit-scrollbar-thumb:hover,
.right-hud-panel::-webkit-scrollbar-thumb:hover,
.med-list-container::-webkit-scrollbar-thumb:hover,
.serial-terminal-view::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.5);
}

/* Search Box */
.search-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-primary);
  background: rgba(10, 14, 23, 0.85);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.25);
}

/* Filter Pills */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pill {
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover, .pill.active {
  background: rgba(6, 182, 212, 0.25);
  border-color: var(--accent-cyan);
  color: #ffffff;
}

/* Medicine Results List - Fills ALL remaining vertical space */
.med-list-container {
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
}

.med-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.med-card-item:hover {
  transform: translateX(4px);
  background: rgba(30, 41, 59, 0.8);
  border-color: var(--accent-emerald);
}

.med-card-item.selected {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.15);
}

.med-info-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.med-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.med-generic {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-body);
}

.med-badge-loc {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Batch Picking Route Queue Card */
.route-queue-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title-row h3 {
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.queue-items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.queue-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(10, 14, 23, 0.5);
  font-size: 12px;
}

/* ----------------- Center 3D Viewport Controls ----------------- */
.center-viewport-hud {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
}

.camera-floating-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-elevation);
}

.cam-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-lg);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.cam-btn:hover, .cam-btn.active {
  background: rgba(6, 182, 212, 0.25);
  color: #ffffff;
}

/* ----------------- Right Sidebar - Telemetry & Kinematics ----------------- */
.right-hud-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  overflow: hidden;
  padding: 12px;
}

/* Active Drug Telemetry Card */
.active-med-card {
  padding: 12px 14px;
  flex-shrink: 0;
  border-color: var(--border-laser);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08), rgba(15, 23, 42, 0.85));
}

.active-med-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.detail-cell {
  background: rgba(10, 14, 23, 0.6);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
}

.cell-label {
  font-size: 9.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.cell-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-emerald);
  font-family: var(--font-mono);
  margin-top: 1px;
}

/* Kinematics Math Gauge */
.kinematics-card {
  padding: 10px 12px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gauge-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.gauge-box {
  background: rgba(10, 14, 23, 0.8);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  text-align: center;
}

.gauge-name {
  font-size: 10.5px;
  color: var(--text-secondary);
  font-weight: 600;
}

.gauge-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  line-height: 1.2;
}

.gauge-unit {
  font-size: 10px;
  color: var(--text-muted);
}

/* Live Serial Stream Box - Fills all remaining vertical height */
.serial-stream-card {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
}

.serial-terminal-view {
  background: #05080f;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent-emerald);
  flex: 1;
  height: 100%;
  overflow-y: auto;
  line-height: 1.4;
}

/* ----------------- Bottom HUD Bar (Pick-to-Light Matrix) ----------------- */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-glass);
  gap: 20px;
  overflow: hidden;
}

.shelf-led-matrix-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.matrix-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.led-strip-indicators {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  overflow: hidden;
  padding: 2px 0;
}

.shelf-slot-led {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.2s ease;
  position: relative;
}

.shelf-slot-led.active {
  background: var(--accent-emerald);
  border-color: #ffffff;
  box-shadow: 0 0 12px var(--accent-emerald);
  transform: scale(1.25);
}

.shelf-slot-led.queued {
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

/* ----------------- Prescription OCR Scanner Modal ----------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.scanner-modal-card {
  width: 680px;
  max-width: 95vw;
  background: #0f172a;
  border: 1px solid var(--border-glass-bright);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-glass);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rx-preset-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.rx-preset-btn {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  background: rgba(30, 41, 59, 0.6);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rx-preset-btn:hover, .rx-preset-btn.active {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.15);
}

.rx-preset-name {
  font-size: 13px;
  font-weight: 700;
}

.rx-preset-doc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.scan-display-area {
  position: relative;
  background: #05080f;
  border: 1px dashed var(--border-glass-bright);
  border-radius: var(--radius-md);
  padding: 16px;
  min-height: 140px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #94a3b8;
  white-space: pre-wrap;
  line-height: 1.5;
  overflow: hidden;
}

/* Animated Laser Scanline */
.laser-scan-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #10b981, #38bdf8, transparent);
  box-shadow: 0 0 15px #10b981;
  display: none;
  animation: scanline-anim 1.8s infinite ease-in-out;
}

@keyframes scanline-anim {
  0% { top: 0%; opacity: 0.2; }
  50% { opacity: 1; }
  100% { top: 100%; opacity: 0.2; }
}

.scan-progress-status {
  font-size: 12px;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-glass);
  background: rgba(10, 14, 23, 0.5);
}

/* Toast Notifications */
.toast-notification {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  border-radius: var(--radius-xl);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-emerald);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-glow-emerald);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
