/* MediCollab RMIK - Modern Design System */
:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --secondary: #0d9488;
  --secondary-light: #ccfbf1;
  --dark: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;
  
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #6366f1;
  --info-light: #e0e7ff;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: #f8fafc;
  color: var(--slate-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Navbar */
.app-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--slate-200);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--dark);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #0284c7, #0d9488);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.35rem;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--dark);
  line-height: 1.2;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--slate-500);
  font-weight: 500;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--slate-100);
  padding: 0.3rem;
  border-radius: var(--radius-full);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  border: none;
  background: transparent;
  color: var(--slate-600);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.nav-btn:hover {
  color: var(--dark);
}

.nav-btn.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* User & Collaboration Switcher */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.team-badge {
  background: var(--primary-light);
  color: var(--primary-hover);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #bae6fd;
}

.user-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
}

.user-selector label {
  color: var(--slate-500);
  font-size: 0.75rem;
  font-weight: 600;
}

.user-selector select {
  border: none;
  background: transparent;
  font-weight: 700;
  color: var(--dark);
  font-size: 0.825rem;
  cursor: pointer;
  outline: none;
}

/* Main Container */
.main-content {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
}

/* View Sections */
.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero / Welcome Banner */
.hero-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0d9488 100%);
  color: white;
  padding: 2rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: '';
  position: absolute;
  top: -30%;
  right: -10%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.25) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.hero-subtitle {
  color: #cbd5e1;
  font-size: 0.95rem;
  max-width: 750px;
  line-height: 1.6;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.stat-box {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 1rem;
  border-radius: var(--radius-md);
}

.stat-label {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  margin-top: 0.25rem;
}

/* Card Components */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--slate-100);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.btn-secondary {
  background: var(--slate-100);
  color: var(--slate-700);
  border-color: var(--slate-200);
}

.btn-secondary:hover {
  background: var(--slate-200);
  color: var(--dark);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #059669;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.775rem;
}

/* Floating Collaborative Toolbar */
.form-sticky-bar {
  position: sticky;
  top: 65px;
  z-index: 90;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.form-status-info {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.timer-badge {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.completeness-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-bar-container {
  width: 140px;
  height: 10px;
  background: var(--slate-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0d9488, #10b981);
  width: 0%;
  transition: width 0.3s ease;
}

.autosave-text {
  font-size: 0.775rem;
  color: var(--slate-500);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Form Styles */
.form-section {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  position: relative;
}

.form-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--slate-100);
}

.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.85rem;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--dark);
}

.section-editor-tag {
  font-size: 0.75rem;
  color: var(--slate-500);
  background: var(--slate-100);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.section-comp-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
}

.form-group.col-span-full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--slate-700);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-tag {
  font-size: 0.7rem;
  color: var(--primary);
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  background-color: var(--white);
  color: var(--dark);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control {
  min-height: 85px;
  resize: vertical;
}

/* Medical Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
}

.med-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.med-table th {
  background: var(--slate-100);
  color: var(--slate-700);
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--slate-200);
  white-space: nowrap;
}

.med-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--slate-200);
  vertical-align: middle;
}

.med-table tr:last-child td {
  border-bottom: none;
}

.med-table input, .med-table select {
  width: 100%;
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  outline: none;
}

.med-table input:focus {
  border-color: var(--primary);
}

/* Reference Split Modal / Drawer */
.reference-modal {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: 520px;
  max-width: 95vw;
  height: 100vh;
  background: var(--white);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  flex-direction: column;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.reference-modal.active {
  display: flex;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--slate-50);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.case-doc-preview {
  background: #fdfdfd;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  font-size: 0.85rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

.case-doc-preview h4 {
  font-size: 0.95rem;
  color: var(--primary);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px dashed var(--slate-300);
}

.case-doc-preview h4:first-child {
  margin-top: 0;
}

/* Modal Overlay */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
}

.modal-backdrop.active {
  display: block;
}

/* Scoring & Evaluation Report Styles */
.score-hero {
  background: linear-gradient(135deg, #0284c7 0%, #0d9488 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-lg);
}

.score-big {
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
}

.score-predicate {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.35rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 0.5rem;
  backdrop-filter: blur(4px);
}

.score-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.score-metric-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border-top: 4px solid var(--primary);
}

.score-metric-card.accent-green { border-top-color: var(--success); }
.score-metric-card.accent-amber { border-top-color: var(--warning); }
.score-metric-card.accent-indigo { border-top-color: var(--info); }

.score-metric-title {
  font-size: 0.8rem;
  color: var(--slate-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-metric-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--dark);
  margin-top: 0.25rem;
}

.score-metric-desc {
  font-size: 0.775rem;
  color: var(--slate-500);
  margin-top: 0.25rem;
}

/* Audit Trail & Collaboration Table */
.audit-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.audit-chip.captain {
  background: #fef3c7;
  color: #92400e;
}

.audit-chip.member {
  background: var(--primary-light);
  color: var(--primary-hover);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: var(--dark);
  color: white;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideUp 0.3s ease-out;
}

.toast.success { background: #065f46; border-left: 4px solid #10b981; }
.toast.error { background: #881337; border-left: 4px solid #f43f5e; }
.toast.info { background: #1e1b4b; border-left: 4px solid #6366f1; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Print Styles for Medical Record & Grade Report */
@media print {
  body {
    background: white;
    color: black;
    font-size: 11pt;
  }

  .app-header, .form-sticky-bar, .nav-tabs, .btn, .modal-backdrop, .reference-modal, .toast-container, .no-print {
    display: none !important;
  }

  .main-content {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  .card, .form-section {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
    margin-bottom: 1rem;
    padding: 1rem;
  }

  .print-only-header {
    display: block !important;
    text-align: center;
    border-bottom: 2px solid black;
    padding-bottom: 10px;
    margin-bottom: 15px;
  }
}

.print-only-header {
  display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }
  .nav-tabs {
    width: 100%;
    overflow-x: auto;
  }
  .form-sticky-bar {
    top: 0;
  }
}
