:root {
  --primary: #047857;
  --primary-light: #10b981;
  --primary-dark: #065f46;
  --primary-bg: #ecfdf5;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --success: #16a34a;
  --success-bg: #f0fdf4;
}

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

body {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #0b1329;
  color: #f8fafc;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Top Navigation Bar */
.navbar {
  height: 60px;
  background-color: #0f172a;
  border-bottom: 1px solid #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
}

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

.brand-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.3px;
}

.brand-title span {
  color: #10b981;
  font-weight: 600;
  font-size: 13px;
  margin-left: 6px;
}

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

.btn {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #047857, #059669);
}

.btn-generate {
  width: 100%;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: white;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 800;
  border-radius: 8px;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
  letter-spacing: 0.3px;
}

.btn-generate:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
  transform: translateY(-1px);
}

.btn-generate span {
  font-size: 15px;
}

/* Report Summary Card */
.report-summary-card {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid #38bdf8;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.1);
}

.summary-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
}

.summary-booking-tag {
  font-size: 10px;
  background: #0369a1;
  color: #e0f2fe;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.summary-card-stats {
  display: flex;
  gap: 8px;
}

.stat-badge {
  font-size: 9.5px;
  font-weight: 700;
  background: #064e3b;
  color: #6ee7b7;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #059669;
}

.stat-badge-alert {
  background: #7f1d1d;
  color: #fca5a5;
  border-color: #dc2626;
}

.btn-secondary {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #334155;
}

.btn-secondary:hover {
  background: #334155;
  color: white;
}

.btn-outline {
  background: transparent;
  color: #94a3b8;
  border-color: #334155;
}

.btn-outline:hover {
  background: #1e293b;
  color: white;
}

/* Main Split View */
.main-content {
  flex-grow: 1;
  display: grid;
  grid-template-columns: 460px 1fr;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* Sidebar / Left Controls */
.sidebar {
  background-color: #0f172a;
  border-right: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  gap: 14px;
}

.section-label {
  font-size: 11px;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-panel {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px;
}

/* Sample Chooser Pills */
.sample-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sample-chip {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.sample-chip.active, .sample-chip:hover {
  border-color: #10b981;
  background: #064e3b;
}

.sample-chip-title {
  font-size: 11.5px;
  font-weight: 800;
  color: #ffffff;
}

.sample-chip-desc {
  font-size: 9.5px;
  color: #94a3b8;
  margin-top: 2px;
}

/* Template Switcher */
.template-select {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  color: #ffffff;
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}

.template-select:focus {
  border-color: #10b981;
}

/* Upload Zone */
.dropzone {
  border: 2px dashed #334155;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #0f172a;
}

.dropzone:hover {
  border-color: #10b981;
  background: #064e3b;
}

.dropzone-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

.dropzone-text {
  font-size: 11px;
  font-weight: 700;
  color: #e2e8f0;
}

.dropzone-sub {
  font-size: 9.5px;
  color: #64748b;
}

/* JSON Code Editor */
.json-editor-wrap {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.json-textarea {
  width: 100%;
  height: 220px;
  background: #090e1a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #38bdf8;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  padding: 10px;
  resize: vertical;
  outline: none;
  line-height: 1.4;
}

.json-textarea:focus {
  border-color: #10b981;
}

/* Live Validation Badge */
.status-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}

.status-ok { background: #065f46; color: #6ee7b7; border: 1px solid #10b981; }
.status-err { background: #7f1d1d; color: #fca5a5; border: 1px solid #ef4444; }

/* Right Viewport / PDF Preview */
.preview-viewport {
  background-color: #1e293b;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.zoom-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.zoom-btn:hover {
  color: white;
  background: #334155;
}

.zoom-label {
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  min-width: 45px;
  text-align: center;
}

/* Report Frame */
.report-paper-container {
  width: 210mm;
  transform-origin: top center;
  transition: transform 0.2s ease;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  background: white;
  margin-bottom: 40px;
}

/* Hide UI on Print */
@media print {
  body {
    background: white;
    color: black;
    height: auto;
    overflow: visible;
  }
  .navbar, .sidebar, .preview-toolbar {
    display: none !important;
  }
  .main-content {
    display: block;
    height: auto;
  }
  .preview-viewport {
    padding: 0;
    background: white;
    overflow: visible;
  }
  .report-paper-container {
    width: 100%;
    box-shadow: none;
    margin: 0;
    transform: none !important;
  }
}

/* Presentation Mode (Client Demo) */
body.presentation-mode .sidebar {
  display: none !important;
}
body.presentation-mode .main-content {
  grid-template-columns: 1fr !important;
}
body.presentation-mode .navbar {
  background-color: #0b1329;
}


/* --- History Drawer & Modal --- */
.history-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.history-overlay.open {
  display: block;
  opacity: 1;
}
.history-drawer {
  position: fixed;
  top: 0;
  right: -430px;
  width: 420px;
  max-width: 92vw;
  height: 100vh;
  background: #0f172a;
  border-left: 1px solid #1e293b;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.history-drawer.open {
  right: 0;
}
.history-header {
  padding: 16px 20px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0b1329;
}
.history-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
}
.history-count-badge {
  background: #047857;
  color: white;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 700;
}
.history-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.history-close-btn:hover {
  color: #fff;
}
.history-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  gap: 8px;
  background: #111d38;
}
.history-search-input {
  flex: 1;
  background: #0b1329;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 7px 12px;
  color: #f8fafc;
  font-size: 12px;
  outline: none;
}
.history-search-input:focus {
  border-color: #047857;
}
.history-refresh-btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.history-refresh-btn:hover {
  background: #334155;
  color: #fff;
}
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.history-empty {
  text-align: center;
  color: #64748b;
  font-size: 13px;
  padding: 40px 20px;
  line-height: 1.5;
}
.history-card {
  background: #162036;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}
.history-card:hover {
  border-color: #047857;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.history-card-patient {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
}
.history-card-meta {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}
.history-card-time {
  font-size: 10px;
  color: #64748b;
  white-space: nowrap;
}
.history-card-pills {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.history-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.history-pill-red {
  background: rgba(220, 38, 38, 0.18);
  color: #f87171;
  border: 1px solid rgba(220, 38, 38, 0.4);
}
.history-pill-amber {
  background: rgba(217, 119, 6, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(217, 119, 6, 0.4);
}
.history-pill-green {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.history-pill-source {
  background: #1e293b;
  color: #cbd5e1;
}
.history-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.history-btn {
  flex: 1;
  background: #0f172a;
  border: 1px solid #334155;
  color: #cbd5e1;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.15s ease;
}
.history-btn:hover {
  background: #047857;
  color: #fff;
  border-color: #047857;
}
.history-btn-view {
  background: rgba(4, 120, 87, 0.15);
  border-color: #047857;
  color: #34d399;
}
.history-btn-view:hover {
  background: #047857;
  color: white;
}


/* --- Studio Lock Screen Modal --- */
.studio-lock-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 30%, #1e293b 0%, #0b1329 100%);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}
.studio-lock-screen.unlocked {
  display: none !important;
}
.studio-lock-card {
  width: 380px;
  max-width: 90vw;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 32px 28px;
  text-align: center;
}
.studio-lock-logo h2 {
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 4px;
}
.studio-lock-logo p {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 24px;
}
.studio-lock-input-wrap {
  position: relative;
  margin-bottom: 14px;
}
.studio-lock-input-wrap input {
  width: 100%;
  background: #0b1329;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px 40px 12px 14px;
  color: #f8fafc;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.studio-lock-input-wrap input:focus {
  border-color: #047857;
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.2);
}
.studio-eye-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.6;
}
.studio-eye-btn:hover {
  opacity: 1;
}
.studio-lock-error {
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #f87171;
  font-size: 12px;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 14px;
}
.studio-lock-submit-btn {
  width: 100%;
  background: #047857;
  border: none;
  border-radius: 8px;
  color: #ffffff;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}
.studio-lock-submit-btn:hover {
  background: #059669;
}
.studio-lock-footer {
  margin-top: 24px;
  font-size: 11px;
  color: #64748b;
}
