/* SurgTrack UAE - Custom Styles */
:root {
  --primary: #0f4c81;
  --primary-light: #1a6db5;
  --accent: #00a651;
  --accent-dark: #007a3d;
  --danger: #dc2626;
  --warning: #d97706;
  --text-dark: #1e293b;
  --bg-main: #f0f4f8;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg-main); color: var(--text-dark); margin: 0; }

/* ====== Layout ====== */
#sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--primary);
  color: white; display: flex; flex-direction: column;
  z-index: 100; transition: transform 0.3s;
  overflow-y: auto;
}
#main-content { margin-left: var(--sidebar-w); min-height: 100vh; }
#topbar {
  background: white; border-bottom: 1px solid #e2e8f0;
  padding: 0 24px; height: 64px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* ====== Sidebar ====== */
.sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-logo h1 { font-size: 22px; font-weight: 700; margin: 0; color: white; }
.sidebar-logo p { font-size: 11px; color: rgba(255,255,255,.65); margin: 2px 0 0; }
.nav-section { padding: 12px 0 4px; }
.nav-section-label { font-size: 10px; font-weight: 600; text-transform: uppercase;
  color: rgba(255,255,255,.45); padding: 0 20px 6px; letter-spacing: .8px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  color: rgba(255,255,255,.8); cursor: pointer; transition: all .2s;
  border-left: 3px solid transparent; font-size: 14px; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.1); color: white;
  border-left-color: #00a651; }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }

/* ====== Cards ====== */
.card { background: white; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.07);
  padding: 20px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #f1f5f9; }
.card-title { font-size: 16px; font-weight: 600; color: var(--text-dark); }

/* ====== Stat Cards ====== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 12px; padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07); display: flex; gap: 16px; align-items: center; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: #64748b; margin-top: 2px; }

/* ====== Buttons ====== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px;
  border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer;
  border: none; transition: all .2s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-danger { background: #fee2e2; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* ====== Forms ====== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500;
  color: #374151; margin-bottom: 6px; }
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid #e2e8f0;
  border-radius: 8px; font-size: 14px; color: var(--text-dark);
  transition: border-color .2s; background: white; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,76,129,.1); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-section { background: #f8fafc; border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.form-section-title { font-size: 13px; font-weight: 600; color: var(--primary);
  margin-bottom: 14px; display: flex; align-items: center; gap: 6px; }

/* ====== Tables ====== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: #f8fafc; padding: 12px 14px; text-align: left;
  font-size: 12px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .5px; }
.data-table td { padding: 12px 14px; border-top: 1px solid #f1f5f9; font-size: 14px; vertical-align: middle; }
.data-table tr:hover td { background: #f8fafc; cursor: pointer; }

/* ====== Badges ====== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-planned { background: #dbeafe; color: #1e40af; }
.badge-urgent { background: #fce7f3; color: #9d174d; }
.badge-routine { background: #f1f5f9; color: #475569; }
.badge-oncological { background: #fce7f3; color: #831843; }
.badge-general { background: #dbeafe; color: #1e40af; }
.badge-hernia { background: #d1fae5; color: #065f46; }
.badge-cosmetic { background: #ede9fe; color: #5b21b6; }

/* ====== AI Panel ====== */
.ai-panel { background: linear-gradient(135deg, #0f4c81 0%, #1a6db5 100%);
  color: white; border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.ai-panel-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-weight: 600; font-size: 16px; }
.ai-panel-header i { font-size: 20px; color: #93c5fd; }
.ai-result-item { background: rgba(255,255,255,.1); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 8px; font-size: 13px; }
.ai-badge { display: inline-block; background: rgba(255,255,255,.2); padding: 2px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 600; margin: 2px; }
.ai-missing { background: #fef9c3; color: #854d0e; border-radius: 8px; padding: 12px; margin-top: 10px; }
.ai-missing h4 { margin: 0 0 8px; font-size: 13px; color: #854d0e; }

/* ====== Timeline ====== */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px;
  width: 2px; background: #e2e8f0; }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-item::before { content: ''; position: absolute; left: -20px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; border: 2px solid white; }
.timeline-item.completed::before { background: var(--accent); }
.timeline-item.overdue::before { background: var(--danger); }
.timeline-item.upcoming::before { background: var(--warning); }

/* ====== Modal ====== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 1000; display: flex; align-items: flex-start; justify-content: center;
  padding: 20px; overflow-y: auto; }
.modal { background: white; border-radius: 16px; width: 100%; max-width: 700px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); margin: auto; }
.modal-wide { max-width: 900px; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: white; z-index: 1; }
.modal-title { font-size: 18px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #f1f5f9;
  display: flex; justify-content: flex-end; gap: 10px; }

/* ====== Auth ====== */
#auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f4c81 0%, #1a6db5 50%, #00a651 100%); }
.auth-box { background: white; border-radius: 20px; padding: 40px;
  width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo h1 { font-size: 28px; font-weight: 700; color: var(--primary); margin: 0; }
.auth-logo p { color: #64748b; font-size: 14px; margin: 4px 0 0; }

/* ====== Page content ====== */
.page { display: none; padding: 24px; }
.page.active { display: block; }
.page-header { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text-dark); }
.page-subtitle { font-size: 13px; color: #64748b; margin-top: 2px; }

/* ====== Patient card ====== */
.patient-card { background: white; border-radius: 12px; padding: 16px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07); cursor: pointer; transition: all .2s;
  border: 2px solid transparent; display: flex; align-items: center; gap: 14px; }
.patient-card:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(15,76,129,.1); }
.patient-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }

/* ====== Steps ====== */
.step-indicator { display: flex; align-items: center; gap: 0; margin-bottom: 24px; }
.step { display: flex; align-items: center; gap: 8px; }
.step-num { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #94a3b8; }
.step.active .step-num { background: var(--primary); border-color: var(--primary); color: white; }
.step.done .step-num { background: var(--accent); border-color: var(--accent); color: white; }
.step-label { font-size: 12px; color: #94a3b8; }
.step.active .step-label, .step.done .step-label { color: var(--text-dark); font-weight: 500; }
.step-line { flex: 1; height: 2px; background: #e2e8f0; margin: 0 8px; min-width: 20px; }
.step-line.done { background: var(--accent); }

/* ====== Misc ====== */
.search-bar { display: flex; align-items: center; gap: 10px; background: #f8fafc;
  border: 1.5px solid #e2e8f0; border-radius: 8px; padding: 0 14px; }
.search-bar input { border: none; background: transparent; padding: 10px 0;
  font-size: 14px; outline: none; flex: 1; }
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; display: flex; gap: 8px; align-items: flex-start; }
.alert-warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.tabs { display: flex; gap: 0; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab { padding: 10px 20px; font-size: 14px; font-weight: 500; cursor: pointer;
  color: #64748b; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; background: #f1f5f9; color: #475569; margin: 2px; }
.divider { border: none; border-top: 1px solid #f1f5f9; margin: 16px 0; }
.text-muted { color: #64748b; }
.text-small { font-size: 12px; }
.fw-600 { font-weight: 600; }
.risk-high { color: #dc2626; font-weight: 600; }
.risk-low { color: #059669; font-weight: 600; }
.risk-intermediate { color: #d97706; font-weight: 600; }
.uae-flag { display: inline-flex; gap: 3px; font-size: 10px; align-items: center; }
.progress-bar { background: #e2e8f0; border-radius: 99px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width .3s; }
.notification-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { animation: spin 1s linear infinite; }
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0; }
}

/* Global PDF Drop Overlay */
#global-drop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(99, 102, 241, 0.10);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#global-drop-inner {
  background: white;
  border: 3px dashed #6366f1;
  border-radius: 24px;
  padding: 56px 72px;
  text-align: center;
  box-shadow: 0 25px 60px rgba(99,102,241,.25);
  animation: dropPulse .8s ease-in-out infinite alternate;
}
@keyframes dropPulse {
  from { transform: scale(1);    box-shadow: 0 25px 60px rgba(99,102,241,.20); }
  to   { transform: scale(1.02); box-shadow: 0 30px 80px rgba(99,102,241,.35); }
}
