/* VascuPhysio — Clinical Assessment Platform CSS */
/* Hospital EMR/EHR Grade Styles */

:root {
  --brand-blue: #1e3a5f;
  --brand-teal: #0f766e;
  --brand-light: #2563eb;
  --sidebar-width: 280px;
  --header-height: 64px;
}

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }
.dark ::-webkit-scrollbar-track { background: #1e293b; }
.dark ::-webkit-scrollbar-thumb { background: #475569; }

/* ===== LAYOUT ===== */
#app { min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: linear-gradient(180deg, #1e3a5f 0%, #1e40af 60%, #0f766e 100%);
  position: fixed;
  left: 0; top: 0;
  z-index: 50;
  transition: transform 0.3s ease;
  overflow-y: auto;
}
.sidebar.collapsed { transform: translateX(-100%); }

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}
.main-content.full-width { margin-left: 0; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* ===== HEADER ===== */
.app-header {
  height: var(--header-height);
  background: white;
  border-bottom: 2px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.dark .app-header { background: #1e293b; border-color: #334155; }

/* ===== SIDEBAR NAV ===== */
.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  padding: 1rem 1rem 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1rem;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 0;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: white;
  border-left-color: #60a5fa;
  font-weight: 600;
}
.nav-item .nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: white;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 10px;
}

/* ===== CARDS ===== */
.card {
  background: white;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  overflow: hidden;
}
.dark .card { background: #1e293b; border-color: #334155; }

.card-header {
  background: linear-gradient(135deg, #1e3a5f, #1e40af);
  color: white;
  padding: 0.875rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.dark .section-card { background: #1e293b; border-color: #334155; }

.section-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  color: #1e3a5f;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.dark .section-header { background: #0f172a; border-color: #334155; color: #93c5fd; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dark .form-label { color: #94a3b8; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background: white;
  color: #111827;
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.5;
}
.dark .form-input, .dark .form-select, .dark .form-textarea {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-input.error { border-color: #ef4444; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { cursor: pointer; }

.form-radio-group, .form-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.radio-option, .checkbox-option {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.8125rem;
  transition: all 0.15s;
  background: white;
  user-select: none;
}
.dark .radio-option, .dark .checkbox-option {
  border-color: #334155; background: #0f172a;
}
.radio-option:hover, .checkbox-option:hover { border-color: #2563eb; background: #eff6ff; }
.radio-option.selected, .checkbox-option.selected {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}
.dark .radio-option.selected, .dark .checkbox-option.selected {
  background: #1e3a5f; color: #93c5fd;
}

/* NRS Slider */
.nrs-slider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.375rem;
}
.nrs-slider input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  background: linear-gradient(to right, #16a34a, #eab308, #ef4444);
  border-radius: 3px;
  outline: none;
}
.nrs-slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: #2563eb;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.nrs-value {
  min-width: 2rem;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  color: #2563eb;
}

/* ===== TABLES ===== */
.clinical-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.clinical-table th {
  background: #1e3a5f;
  color: white;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
}
.clinical-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}
.dark .clinical-table td { border-color: #334155; }
.clinical-table tr:nth-child(even) td { background: #f8fafc; }
.dark .clinical-table tr:nth-child(even) td { background: #0f172a; }
.clinical-table td input, .clinical-table td select {
  width: 100%;
  padding: 0.25rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  font-size: 0.8125rem;
  background: white;
}
.dark .clinical-table td input, .dark .clinical-table td select {
  background: #1e293b; border-color: #475569; color: #f1f5f9;
}

/* ===== SCORE BADGES ===== */
.score-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 700;
}
.score-normal { background: #dcfce7; color: #16a34a; }
.score-mild { background: #fef9c3; color: #ca8a04; }
.score-moderate { background: #fed7aa; color: #ea580c; }
.score-severe { background: #fee2e2; color: #dc2626; }
.score-critical { background: #fce7f3; color: #9d174d; }
.dark .score-normal { background: #14532d; color: #86efac; }
.dark .score-mild { background: #713f12; color: #fde68a; }
.dark .score-moderate { background: #7c2d12; color: #fdba74; }
.dark .score-severe { background: #7f1d1d; color: #fca5a5; }

/* Score Card */
.score-card {
  border: 2px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem;
  text-align: center;
  transition: all 0.2s;
}
.score-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.score-card .score-number {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.25rem;
}
.score-card .score-label {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.score-card .score-interpretation {
  font-size: 0.8125rem;
  margin-top: 0.25rem;
  font-weight: 600;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  outline: none;
  white-space: nowrap;
}
.btn-primary { background: #1e3a5f; color: white; }
.btn-primary:hover { background: #1e40af; }
.btn-secondary { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-success { background: #16a34a; color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-teal { background: #0f766e; color: white; }
.btn-teal:hover { background: #0d9488; }
.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.75rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== TABS ===== */
.tab-bar {
  display: flex;
  border-bottom: 2px solid #e2e8f0;
  background: white;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.dark .tab-bar { background: #1e293b; border-color: #334155; }
.tab-btn {
  padding: 0.75rem 1.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  color: #64748b;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  outline: none;
}
.tab-btn:hover { color: #1e3a5f; background: #f8fafc; }
.tab-btn.active { color: #1e3a5f; border-bottom-color: #2563eb; background: white; }
.dark .tab-btn.active { color: #93c5fd; background: #1e293b; border-bottom-color: #60a5fa; }

/* ===== ALERTS ===== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert-red { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-yellow { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-green { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-blue { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.dark .alert-red { background: #450a0a; border-color: #7f1d1d; color: #fca5a5; }
.dark .alert-yellow { background: #451a03; border-color: #78350f; color: #fde68a; }

/* ===== PROGRESS STEPS ===== */
.progress-steps {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  background: white;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
}
.dark .progress-steps { background: #1e293b; border-color: #334155; }
.step-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.step-circle {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border: 2px solid #d1d5db;
  color: #94a3b8;
  background: white;
  transition: all 0.2s;
}
.step-circle.done { background: #16a34a; border-color: #16a34a; color: white; }
.step-circle.active { background: #2563eb; border-color: #2563eb; color: white; }
.step-label { font-size: 0.75rem; color: #64748b; font-weight: 500; }
.step-label.active { color: #2563eb; font-weight: 700; }
.step-connector { width: 40px; height: 2px; background: #e2e8f0; margin: 0 0.25rem; }
.step-connector.done { background: #16a34a; }

/* ===== PATIENT CARD ===== */
.patient-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
}
.dark .patient-card { background: #1e293b; border-color: #334155; }
.patient-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-color: #2563eb; }
.patient-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3a5f, #0f766e);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.125rem;
  font-weight: 700;
  flex-shrink: 0;
}
.ceap-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: #dbeafe;
  color: #1e40af;
}

/* ===== DASHBOARD STATS ===== */
.stat-card {
  background: white;
  border-radius: 0.75rem;
  padding: 1.25rem;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.dark .stat-card { background: #1e293b; border-color: #334155; }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* ===== VEIN DIAGRAM ===== */
.vein-diagram-container {
  position: relative;
  display: inline-block;
}
.vein-diagram-container svg { display: block; }
.vein-marker {
  position: absolute;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid white;
  cursor: pointer;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: white;
  font-weight: 700;
}

/* ===== QUESTIONNAIRE ===== */
.question-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s;
}
.dark .question-item { background: #0f172a; border-color: #334155; }
.question-item.answered { border-color: #86efac; background: #f0fdf4; }
.dark .question-item.answered { background: #052e16; border-color: #166534; }
.question-number {
  font-size: 0.7rem;
  font-weight: 700;
  color: #2563eb;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.question-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.625rem;
  line-height: 1.5;
}
.dark .question-text { color: #e2e8f0; }

/* ===== SOAP NOTES ===== */
.soap-section {
  border-left: 4px solid #2563eb;
  padding: 0.875rem 1rem;
  background: #eff6ff;
  border-radius: 0 0.5rem 0.5rem 0;
  margin-bottom: 0.75rem;
}
.dark .soap-section { background: #1e3a5f; }
.soap-section.subjective { border-color: #7c3aed; background: #f5f3ff; }
.soap-section.objective { border-color: #0f766e; background: #f0fdfa; }
.soap-section.assessment { border-color: #ea580c; background: #fff7ed; }
.soap-section.plan { border-color: #16a34a; background: #f0fdf4; }
.dark .soap-section.subjective { background: #2e1065; }
.dark .soap-section.objective { background: #042f2e; }
.dark .soap-section.assessment { background: #431407; }
.dark .soap-section.plan { background: #052e16; }
.soap-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.375rem;
}

/* ===== RED FLAG ALERT ===== */
.red-flag-alert {
  background: linear-gradient(135deg, #7f1d1d, #991b1b);
  color: white;
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  animation: pulse-red 2s infinite;
}
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: white;
  border-radius: 0.75rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.dark .modal-box { background: #1e293b; }
.modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #1e3a5f, #1e40af);
  color: white;
  border-radius: 0.75rem 0.75rem 0 0;
}
.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.dark .modal-footer { border-color: #334155; }

/* ===== PRINT STYLES ===== */
@media print {
  .sidebar, .app-header, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .section-card { break-inside: avoid; }
  body { background: white; color: black; }
}

/* ===== ANIMATIONS ===== */
.fade-in { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== UTILITIES ===== */
.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.required-star::after { content: ' *'; color: #ef4444; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
@media (max-width: 768px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideInRight 0.2s ease;
  max-width: 360px;
}
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { background: #16a34a; color: white; }
.toast-error { background: #dc2626; color: white; }
.toast-info { background: #2563eb; color: white; }
.toast-warning { background: #d97706; color: white; }

/* ===== FOLLOW-UP TIMELINE ===== */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: 0.5rem; top: 0; bottom: 0; width: 2px; background: #e2e8f0; }
.dark .timeline::before { background: #334155; }
.timeline-item { position: relative; margin-bottom: 1.5rem; }
.timeline-dot {
  position: absolute;
  left: -2rem;
  top: 0.25rem;
  width: 1rem; height: 1rem;
  border-radius: 50%;
  background: #2563eb;
  border: 2px solid white;
  box-shadow: 0 0 0 2px #2563eb;
}
.dark .timeline-dot { border-color: #1e293b; }

/* ===== RESPONSIVE GRID ===== */
.assessment-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 640px) { .assessment-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .assessment-grid { grid-template-columns: repeat(3, 1fr); } }

/* ===== LOADING ===== */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.375rem;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== AUTOSAVE INDICATOR ===== */
.autosave-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: #16a34a;
  padding: 0.25rem 0.5rem;
  background: #f0fdf4;
  border-radius: 9999px;
}

/* Hide scrollbar for tab bar */
.tab-bar::-webkit-scrollbar { height: 0; }

/* Ensure inputs inside tables are compact */
.clinical-table td .form-input { min-width: 80px; }
