/**
 * Saathi Rx — Hospital Pharmacy & Chemist Master Theme
 * Modern Emerald Glassmorphism & Fast-Checkout POS Styling
 */

:root {
  --rx-primary: #059669;
  --rx-primary-hover: #10b981;
  --rx-primary-dark: #047857;
  --rx-primary-light: #34d399;
  --rx-primary-glow: rgba(16, 185, 129, 0.25);
  
  --rx-secondary: #0284c7;
  --rx-accent: #f59e0b;
  --rx-danger: #ef4444;
  --rx-danger-glow: rgba(239, 68, 68, 0.2);
  --rx-purple: #8b5cf6;
  
  --rx-bg-base: #060b17;
  --rx-bg-surface: #0b1528;
  --rx-bg-sidebar: #09101f;
  --rx-bg-card: rgba(15, 23, 42, 0.75);
  --rx-bg-card-hover: rgba(30, 41, 59, 0.85);
  
  --rx-border: rgba(255, 255, 255, 0.08);
  --rx-border-strong: rgba(255, 255, 255, 0.14);
  --rx-border-focus: rgba(16, 185, 129, 0.45);
  
  --rx-text-main: #f8fafc;
  --rx-text-muted: #94a3b8;
  --rx-text-dim: #64748b;
  
  --rx-header-height: 64px;
  --rx-sidebar-width: 260px;
  --rx-radius: 10px;
  --rx-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--rx-font);
  background-color: var(--rx-bg-base);
  color: var(--rx-text-main);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* App Layout */
.rx-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top App Header */
.rx-header {
  height: var(--rx-header-height);
  background: var(--rx-bg-surface);
  border-bottom: 1px solid var(--rx-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.rx-header-left, .rx-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.rx-logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.rx-logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--rx-primary), var(--rx-primary-dark));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  box-shadow: 0 2px 10px var(--rx-primary-glow);
}

.rx-logo-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #fff;
}

.rx-logo-badge {
  font-size: 9.5px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: var(--rx-primary-light);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rx-counter-badge {
  background: rgba(2, 132, 199, 0.15);
  border: 1px solid rgba(2, 132, 199, 0.3);
  color: #38bdf8;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rx-header-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--rx-border);
  color: var(--rx-text-main);
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s ease;
}

.rx-header-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--rx-border-strong);
}

.rx-user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--rx-border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.rx-user-pill:hover {
  background: rgba(255, 255, 255, 0.08);
}

.rx-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--rx-primary);
}

/* App Body & Sidebar */
.rx-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--rx-header-height));
}

.rx-sidebar {
  width: var(--rx-sidebar-width);
  background: var(--rx-bg-sidebar);
  border-right: 1px solid var(--rx-border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-shrink: 0;
  overflow-y: auto;
  max-height: calc(100vh - var(--rx-header-height));
  position: sticky;
  top: var(--rx-header-height);
}

.rx-nav-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rx-nav-title {
  font-size: 9.5px;
  font-weight: 800;
  color: var(--rx-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 10px 2px;
}

.rx-nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--rx-text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
  cursor: pointer;
}

.rx-nav-link i {
  font-size: 15px;
  width: 20px;
  text-align: center;
  color: var(--rx-text-dim);
  transition: color 0.15s ease;
}

.rx-nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.rx-nav-link:hover i {
  color: var(--rx-primary-light);
}

.rx-nav-link.active {
  background: linear-gradient(90deg, rgba(5, 150, 105, 0.22), rgba(5, 150, 105, 0.08));
  color: #fff;
  border-left: 3px solid var(--rx-primary-light);
  font-weight: 700;
}

.rx-nav-link.active i {
  color: var(--rx-primary-light);
}

.rx-nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Main Content Stage */
.rx-main {
  flex: 1;
  padding: 24px 28px;
  background: transparent;
  min-width: 0;
  overflow-y: auto;
}

/* View Header */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}

.view-header h2 {
  font-size: 21px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-header p {
  font-size: 13px;
  color: var(--rx-text-muted);
  margin-top: 3px;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Button System */
.rx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.rx-btn-primary {
  background: var(--rx-primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--rx-primary-glow);
}

.rx-btn-primary:hover {
  background: var(--rx-primary-hover);
  transform: translateY(-1px);
}

.rx-btn-outline {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--rx-border-strong);
  color: var(--rx-text-main);
}

.rx-btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--rx-text-muted);
}

.rx-btn-success {
  background: #10b981;
  color: #064e3b;
  font-weight: 700;
}

.rx-btn-danger {
  background: #ef4444;
  color: #fff;
}

.rx-btn-danger:hover {
  background: #dc2626;
}

/* Card System */
.rx-card {
  background: var(--rx-bg-card);
  border: 1px solid var(--rx-border);
  border-radius: var(--rx-radius);
  padding: 20px;
  backdrop-filter: blur(8px);
  margin-bottom: 20px;
}

.rx-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.rx-card-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--rx-bg-card);
  border: 1px solid var(--rx-border);
  border-radius: var(--rx-radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--rx-border-strong);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--rx-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* Table System */
.rx-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--rx-border);
}

.rx-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}

.rx-table th {
  background: rgba(15, 23, 42, 0.9);
  padding: 12px 14px;
  font-weight: 700;
  color: var(--rx-text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--rx-border);
  white-space: nowrap;
}

.rx-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rx-border);
  color: #e2e8f0;
}

.rx-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-instock {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-lowstock {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-expired {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-schedule {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Form Controls */
.rx-input, .rx-select, .rx-textarea {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--rx-border-strong);
  border-radius: 8px;
  padding: 9px 12px;
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rx-input:focus, .rx-select:focus, .rx-textarea:focus {
  border-color: var(--rx-primary);
  box-shadow: 0 0 0 3px var(--rx-primary-glow);
}

/* Modals */
.rx-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.rx-modal-card {
  background: #0b1528;
  border: 1px solid var(--rx-border-strong);
  border-radius: 14px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: rxModalIn 0.2s ease-out;
}

@keyframes rxModalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

.rx-modal-body {
  padding: 22px;
}

.rx-modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--rx-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Toast Notifications */
.rx-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.rx-toast {
  background: #0f172a;
  border: 1px solid var(--rx-border-strong);
  padding: 12px 18px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  transition: all 0.25s ease;
}

.toast-success { border-color: #10b981; }
.toast-success i { color: #10b981; }
.toast-error { border-color: #ef4444; }
.toast-error i { color: #ef4444; }
.toast-info { border-color: #38bdf8; }
.toast-info i { color: #38bdf8; }

/* POS Specific Layout */
.pos-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1080px) {
  .pos-container {
    grid-template-columns: 1fr;
  }
}

/* Thermal POS Print Rules */
@media print {
  body * {
    visibility: hidden;
  }
  #thermalPrintTarget, #thermalPrintTarget * {
    visibility: visible;
  }
  #thermalPrintTarget {
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #000;
    background: #fff;
    padding: 4mm;
  }
}
