/* ═══════════════════════════════════════════════════════
   MEDICORE — Hoja de Estilos Principal
   ═══════════════════════════════════════════════════════ */

:root {
  --primary: #0A6EBD;
  --primary-light: #E8F4FD;
  --primary-dark: #064F8C;
  --secondary: #00C49A;
  --secondary-light: #E0FBF4;
  --accent: #F97316;
  --accent-light: #FEF3EC;
  --danger: #EF4444;
  --danger-light: #FEF2F2;
  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --success: #10B981;
  --success-light: #ECFDF5;
  --dark: #0F172A;
  --dark2: #1E293B;
  --dark3: #334155;
  --mid: #64748B;
  --light: #F8FAFC;
  --light2: #F1F5F9;
  --light3: #E2E8F0;
  --text: #1E293B;
  --text2: #475569;
  --white: #FFFFFF;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 2px 12px rgba(15,23,42,.08);
  --shadow-lg: 0 8px 30px rgba(15,23,42,.12);
  --header-bg: #0F172A;
  --footer-bg: #1E293B;
  --sidebar-w: 260px;
  --font: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: .2s ease;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--light);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Login ─────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark2) 50%, #0A2E52 100%);
  position: relative;
  overflow: hidden;
}
#login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 50%, rgba(10,110,189,.3) 0%, transparent 60%),
              radial-gradient(circle at 80% 20%, rgba(0,196,154,.2) 0%, transparent 50%);
}
.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 20px;
  padding: 3rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,.4);
  position: relative;
  z-index: 1;
}
.login-logo { font-size: 2.5rem; text-align: center; margin-bottom: .5rem; }
.login-title { text-align: center; font-size: 1.6rem; font-weight: 700; color: var(--dark); margin-bottom: .25rem; }
.login-sub { text-align: center; font-size: .85rem; color: var(--mid); margin-bottom: 2rem; }
.login-demos { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 1.5rem; }
.demo-btn { font-size: .75rem; padding: 4px 10px; border: 1px solid var(--light3); border-radius: 20px; cursor: pointer; background: var(--light); color: var(--text2); transition: var(--transition); }
.demo-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* ── Layout Principal ──────────────────────────────── */
#app { display: none; min-height: 100vh; flex-direction: column; }
#app.active { display: flex; }

/* HEADER */
.mc-header {
  background: var(--header-bg);
  color: #fff;
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,.3);
}
.mc-header .logo { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.mc-header .logo span { opacity: .7; font-weight: 400; font-size: .8rem; }
.mc-header .spacer { flex: 1; }
.mc-header .header-actions { display: flex; align-items: center; gap: .75rem; }
.user-badge { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.1); padding: 6px 12px; border-radius: 30px; font-size: .82rem; cursor: pointer; transition: var(--transition); }
.user-badge:hover { background: rgba(255,255,255,.2); }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 600; }
.header-icon-btn { background: rgba(255,255,255,.1); border: none; color: #fff; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.header-icon-btn:hover { background: rgba(255,255,255,.2); }
.notif-badge { position: relative; }
.notif-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; border: 2px solid var(--header-bg); }

/* BODY LAYOUT */
.mc-body { display: flex; flex: 1; min-height: calc(100vh - 60px - 48px); }

/* SIDEBAR */
.mc-sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--light3);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width var(--transition);
  flex-shrink: 0;
}
.sidebar-section { padding: .75rem 1rem .25rem; }
.sidebar-section-title { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--mid); padding: 0 .5rem; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  cursor: pointer; font-size: .875rem; color: var(--text2);
  transition: var(--transition); margin: 2px 0;
  text-decoration: none;
}
.nav-item:hover { background: var(--light2); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: .7rem; padding: 2px 6px; border-radius: 10px; font-weight: 600; }

/* MAIN CONTENT */
.mc-main { flex: 1; overflow-y: auto; padding: 1.5rem; background: var(--light); min-width: 0; }

/* FOOTER */
.mc-footer {
  background: var(--footer-bg);
  color: rgba(255,255,255,.6);
  text-align: center;
  padding: 12px;
  font-size: .78rem;
  border-top: 1px solid rgba(255,255,255,.1);
}

/* ── Componentes ───────────────────────────────────── */

/* Página título */
.page-header { margin-bottom: 1.5rem; }
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--dark); display: flex; align-items: center; gap: 10px; }
.page-subtitle { font-size: .875rem; color: var(--mid); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }

/* Tarjetas */
.card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.25rem; }
.card-title { font-size: .95rem; font-weight: 600; color: var(--dark); margin-bottom: 1rem; display: flex; align-items: center; gap: 8px; }
.card-grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Stat cards */
.stat-card { background: var(--white); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow); display: flex; align-items: center; gap: 1rem; transition: var(--transition); }
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-info .stat-num { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-info .stat-label { font-size: .8rem; color: var(--mid); margin-top: 4px; }
.stat-info .stat-delta { font-size: .78rem; color: var(--success); font-weight: 500; }

/* Botones */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius); border: none; font-family: var(--font); font-size: .875rem; font-weight: 500; cursor: pointer; transition: var(--transition); text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { filter: brightness(.9); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: var(--light2); color: var(--text2); }
.btn-ghost:hover { background: var(--light3); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* Formularios */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text2); margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--light3);
  border-radius: var(--radius); font-family: var(--font); font-size: .875rem;
  color: var(--text); background: var(--white); transition: var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-control:disabled { background: var(--light2); color: var(--mid); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; gap: 1rem; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 700px) { .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; } }
.form-hint { font-size: .75rem; color: var(--mid); margin-top: 4px; }

/* Tablas */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { background: var(--light2); padding: 11px 14px; text-align: left; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mid); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--light3); transition: var(--transition); }
tbody tr:hover { background: var(--light); }
tbody td { padding: 11px 14px; color: var(--text); }
.table-actions { display: flex; gap: 6px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-secondary { background: var(--secondary-light); color: #007A62; }
.badge-neutral { background: var(--light2); color: var(--mid); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; opacity: 0; transition: opacity .2s; pointer-events: none; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--white); border-radius: var(--radius-lg); width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(0,0,0,.2); transform: translateY(20px); transition: transform .2s; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--light3); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--mid); padding: 4px; border-radius: 6px; transition: var(--transition); }
.modal-close:hover { background: var(--light2); color: var(--danger); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--light3); display: flex; justify-content: flex-end; gap: 8px; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--light3); margin-bottom: 1.5rem; gap: 0; overflow-x: auto; }
.tab-btn { padding: 10px 18px; border: none; background: none; font-family: var(--font); font-size: .875rem; color: var(--mid); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition); white-space: nowrap; font-weight: 500; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn:hover:not(.active) { color: var(--text); background: var(--light2); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Alertas */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: .875rem; margin-bottom: 1rem; display: flex; align-items: flex-start; gap: 10px; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); border-left: 4px solid var(--primary); }
.alert-warning { background: var(--warning-light); color: #7C4D00; border-left: 4px solid var(--warning); }
.alert-danger { background: var(--danger-light); color: #7F1D1D; border-left: 4px solid var(--danger); }
.alert-success { background: var(--success-light); color: #064E3B; border-left: 4px solid var(--success); }

/* Search */
.search-box { position: relative; }
.search-box input { padding-left: 36px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--mid); font-size: .9rem; pointer-events: none; }

/* Status colors */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--success); }
.dot-yellow { background: var(--warning); }
.dot-red { background: var(--danger); }
.dot-blue { background: var(--primary); }
.dot-gray { background: var(--mid); }

/* Timeline */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: .5rem; top: 0; bottom: 0; width: 2px; background: var(--light3); }
.timeline-item { position: relative; padding-bottom: 1.5rem; }
.timeline-dot { position: absolute; left: -1.75rem; width: 14px; height: 14px; border-radius: 50%; background: var(--primary); border: 3px solid var(--white); box-shadow: 0 0 0 2px var(--primary); top: 4px; }
.timeline-time { font-size: .75rem; color: var(--mid); margin-bottom: 4px; }
.timeline-content { background: var(--light); border-radius: var(--radius); padding: 12px; border: 1px solid var(--light3); }

/* Vital signs */
.vitals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; }
.vital-card { text-align: center; padding: .875rem; border-radius: var(--radius); border: 1.5px solid var(--light3); transition: var(--transition); }
.vital-card:hover { border-color: var(--primary); background: var(--primary-light); }
.vital-val { font-size: 1.4rem; font-weight: 700; color: var(--dark); }
.vital-unit { font-size: .7rem; color: var(--mid); }
.vital-name { font-size: .75rem; color: var(--text2); margin-top: 4px; font-weight: 500; }

/* Pharmacy / inventory */
.stock-low { color: var(--danger); font-weight: 600; }
.stock-ok { color: var(--success); }
.progress-bar { height: 6px; border-radius: 3px; background: var(--light3); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width .5s; }

/* Print */
@media print {
  .mc-header, .mc-sidebar, .mc-footer, .no-print { display: none !important; }
  .mc-main { padding: 0; }
  body { background: #fff; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--light3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--mid); }

/* Animaciones */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .3s ease; }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--mid); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }
.empty-state p { font-size: .9rem; }
