/* ============================================================
   MediSync - Components CSS
   Charts, Timeline, Print, Dashboard widgets
   ============================================================ */

/* ---- Patient Card ---- */
.patient-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: white; border-radius: var(--radius);
  border: 1px solid var(--gray-200); transition: var(--transition);
}
.patient-card:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.patient-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.patient-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.patient-meta-id { font-size: .72rem; color: var(--gray-400); font-family: 'JetBrains Mono', monospace; }
.patient-meta-name { font-weight: 700; color: var(--gray-800); font-size: .9rem; }

/* ---- Appointment Item ---- */
.appt-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.appt-item:last-child { border-bottom: none; }
.appt-time { min-width: 60px; font-size: .8rem; font-weight: 700; color: var(--primary); font-family: 'JetBrains Mono', monospace; }
.appt-info { flex: 1; }
.appt-patient { font-weight: 600; font-size: .875rem; color: var(--gray-800); }
.appt-doctor  { font-size: .78rem; color: var(--gray-500); }
.appt-token { min-width: 36px; height: 36px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; }

/* ---- Status Indicators ---- */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.active,   .status-dot.completed { background: var(--success); }
.status-dot.pending,  .status-dot.scheduled { background: var(--warning); }
.status-dot.cancelled,.status-dot.inactive  { background: var(--danger); }
.status-dot.in_progress,.status-dot.processing { background: var(--primary); animation: pulse 1.5s infinite; }

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }

/* ---- Ward Map ---- */
.ward-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.ward-card { background: white; border: 1.5px solid var(--gray-200); border-radius: var(--radius); padding: 14px; text-align: center; transition: var(--transition); }
.ward-card.available { border-color: var(--success); }
.ward-card.occupied  { border-color: var(--danger); }
.ward-name { font-weight: 700; font-size: .85rem; color: var(--gray-800); margin-bottom: 6px; }
.ward-beds { font-size: .78rem; color: var(--gray-500); }
.ward-progress { margin-top: 8px; height: 6px; border-radius: 4px; background: var(--gray-100); overflow: hidden; }
.ward-progress-fill { height: 100%; border-radius: 4px; background: var(--success); transition: width .5s ease; }
.ward-progress-fill.warning { background: var(--warning); }
.ward-progress-fill.danger  { background: var(--danger); }

/* ---- Progress Bar ---- */
.progress { height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }
.progress-fill.primary { background: var(--primary); }
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger  { background: var(--danger); }

/* ---- Timeline ---- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: var(--gray-200); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot { position: absolute; left: -24px; top: 4px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid white; box-shadow: 0 0 0 2px var(--gray-300); background: var(--gray-400); }
.timeline-dot.primary { background: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.timeline-dot.success { background: var(--success); box-shadow: 0 0 0 2px var(--success-light); }
.timeline-dot.warning { background: var(--warning); }
.timeline-dot.danger  { background: var(--danger); }
.timeline-time  { font-size: .72rem; color: var(--gray-400); font-family: 'JetBrains Mono', monospace; margin-bottom: 4px; }
.timeline-title { font-weight: 700; font-size: .85rem; color: var(--gray-800); }
.timeline-body  { font-size: .8rem; color: var(--gray-500); margin-top: 4px; }

/* ---- Vital Signs Widget ---- */
.vitals-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.vital-card { background: var(--gray-50); border-radius: var(--radius); padding: 14px; text-align: center; border: 1px solid var(--gray-200); }
.vital-value { font-size: 1.6rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; color: var(--gray-900); line-height: 1; }
.vital-unit  { font-size: .7rem; color: var(--gray-400); margin-top: 2px; }
.vital-label { font-size: .75rem; color: var(--gray-500); margin-top: 6px; font-weight: 600; }
.vital-card.normal .vital-value { color: var(--success); }
.vital-card.warning .vital-value { color: var(--warning); }
.vital-card.critical .vital-value { color: var(--danger); }

/* ---- Queue Display ---- */
.queue-display { display: flex; align-items: center; justify-content: space-between; padding: 20px; background: linear-gradient(135deg, var(--primary), var(--secondary)); border-radius: var(--radius-lg); color: white; margin-bottom: 20px; }
.queue-current { text-align: center; }
.queue-current .label { font-size: .75rem; opacity: .7; text-transform: uppercase; letter-spacing: .08em; }
.queue-current .number { font-size: 4rem; font-weight: 900; line-height: 1; font-family: 'JetBrains Mono', monospace; }
.queue-next .number { font-size: 2rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; }

/* ---- Chart Container ---- */
.chart-container { position: relative; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--gray-600); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ---- Print Receipt / Invoice ---- */
@media print {
  .print-header { text-align: center; margin-bottom: 24px; }
  .print-header h1 { font-size: 1.4rem; font-weight: 800; }
  .print-divider { border: none; border-top: 2px dashed #ccc; margin: 16px 0; }
  .print-row { display: flex; justify-content: space-between; font-size: .875rem; padding: 4px 0; }
  .print-total { font-size: 1.1rem; font-weight: 800; padding-top: 8px; border-top: 2px solid #333; }
  .no-print { display: none !important; }
}

/* ---- Sidebar Overlay (mobile) ---- */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; }
.sidebar-overlay.active { display: block; }

/* ---- Login Page ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--gray-900) 0%, #1a2744 50%, var(--gray-900) 100%); position: relative; overflow: hidden; }
.login-page::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 30% 50%, rgba(14,165,233,.15) 0%, transparent 60%), radial-gradient(ellipse at 70% 50%, rgba(99,102,241,.1) 0%, transparent 60%); }
.login-card { background: white; border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); padding: 40px; width: 100%; max-width: 440px; position: relative; z-index: 1; }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon { width: 56px; height: 56px; border-radius: var(--radius); background: linear-gradient(135deg, var(--primary), var(--secondary)); display: flex; align-items: center; justify-content: center; color: white; font-size: 1.6rem; margin: 0 auto 12px; }
.login-logo h1 { font-size: 1.5rem; font-weight: 800; color: var(--gray-900); }
.login-logo p  { font-size: .875rem; color: var(--gray-500); }
.login-footer  { text-align: center; margin-top: 24px; font-size: .8rem; color: var(--gray-400); }

/* ---- Responsive table wrapper ---- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- Tooltip ---- */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--gray-900); color: white; font-size: .72rem; padding: 5px 10px; border-radius: var(--radius-sm); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 1200; }
[data-tooltip]:hover::after { opacity: 1; }

/* ---- Lab Result Flag Colors ---- */
.result-normal   { color: var(--success); }
.result-high     { color: var(--danger); }
.result-low      { color: var(--warning); }
.result-critical { color: var(--danger); font-weight: 800; animation: pulse 1.5s infinite; }

/* ---- Prescription Item ---- */
.rx-item { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.rx-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.rx-medicine-name { font-weight: 700; color: var(--gray-800); }
.rx-dosage { font-size: .8rem; color: var(--gray-500); }

/* ---- Invoice Print ---- */
.invoice-paper { max-width: 800px; margin: 0 auto; background: white; }
.invoice-header { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 28px; border-bottom: 3px solid var(--primary); }
.invoice-to h4 { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--gray-400); margin-bottom: 6px; }
.invoice-body { padding: 28px; }
.invoice-footer { padding: 20px 28px; background: var(--gray-50); border-top: 1px solid var(--gray-200); }
.invoice-total-box { background: var(--gray-900); color: white; border-radius: var(--radius); padding: 16px 20px; }
.invoice-total-row { display: flex; justify-content: space-between; font-size: .875rem; padding: 4px 0; }
.invoice-total-row.grand { font-size: 1.1rem; font-weight: 800; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.2); margin-top: 6px; }
