/* ============================================================
   ClinicOps Pro - Design System
   Paleta: Índigo profundo + Teal clínico + grises neutros
   Tipografía: Inter
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* === TOKENS === */
:root {
  --indigo:       #1E2B6F;
  --indigo-mid:   #2D3F9E;
  --indigo-light: #EEF2FF;
  --teal:         #0FA47F;
  --teal-light:   #E6F7F2;
  --teal-dark:    #0a7a5f;
  --amber:        #F59E0B;
  --amber-light:  #FEF3C7;
  --amber-dark:   #b45309;
  --red:          #EF4444;
  --red-light:    #FEE2E2;
  --red-dark:     #b91c1c;
  --gray-50:      #F9FAFB;
  --gray-100:     #F3F4F6;
  --gray-200:     #E5E7EB;
  --gray-300:     #D1D5DB;
  --gray-400:     #9CA3AF;
  --gray-500:     #6B7280;
  --gray-600:     #4B5563;
  --gray-700:     #374151;
  --gray-800:     #1F2937;
  --gray-900:     #111827;
  --white:        #FFFFFF;

  --sidebar-w:    220px;
  --topbar-h:     60px;
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
  --shadow:       0 2px 8px rgba(0,0,0,0.10);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.12);
  --font:         'Inter', -apple-system, sans-serif;
  --transition:   0.15s ease;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800); line-height: 1.5; }
a { color: var(--indigo-mid); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: var(--font); }
img { max-width: 100%; }

/* === LAYOUT PRINCIPAL === */
.co-layout { display: flex; min-height: 100vh; }

/* === SIDEBAR === */
.sidebar {
  width: var(--sidebar-w);
  background: var(--indigo);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.brand-logo {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.4px;
}
.brand-logo span { color: var(--teal); }

.brand-sub {
  font-size: 9px;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.nav-section { padding: 14px 10px 2px; }

.nav-label {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 4px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: rgba(255,255,255,0.58);
  font-size: 12.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 1px;
  text-decoration: none;
}

.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; text-decoration: none; }

.nav-item.active {
  background: rgba(15,164,127,0.18);
  color: #fff;
}

.nav-item.active .nav-dot { background: var(--teal); }

.nav-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name  { font-size: 12px; font-weight: 600; color: #fff; line-height: 1.3; }
.user-role  { font-size: 10px; color: rgba(255,255,255,0.4); }

/* === CONTENIDO PRINCIPAL === */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* === TOPBAR === */
.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 12px;
}

.topbar-left h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -0.3px;
}

.topbar-left p {
  font-size: 11px;
  color: var(--gray-400);
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

/* === MAIN CONTENT === */
.content { padding: 24px; flex: 1; }

/* === BOTONES === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), opacity var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn:hover { text-decoration: none; opacity: 0.9; }

.btn-primary   { background: var(--indigo-mid); color: #fff; }
.btn-success   { background: var(--teal);       color: #fff; }
.btn-danger    { background: var(--red);         color: #fff; }
.btn-warning   { background: var(--amber);       color: #fff; }
.btn-ghost     { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-50); }
.btn-sm        { padding: 5px 10px; font-size: 11.5px; }
.btn-icon      { padding: 7px; }

/* === CARDS === */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--gray-800);
}

.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--gray-100); background: var(--gray-50); }

/* === KPI CARDS === */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }

.kpi-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.kpi-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  margin-bottom: 12px;
}

.kpi-icon.teal   { background: var(--teal-light); }
.kpi-icon.amber  { background: var(--amber-light); }
.kpi-icon.red    { background: var(--red-light); }
.kpi-icon.indigo { background: var(--indigo-light); }

.kpi-label { font-size: 11px; color: var(--gray-400); font-weight: 500; margin-bottom: 6px; }
.kpi-value { font-size: 30px; font-weight: 800; color: var(--gray-800); letter-spacing: -1.5px; line-height: 1; }
.kpi-value sup { font-size: 14px; letter-spacing: 0; }
.kpi-trend { font-size: 11px; color: var(--gray-400); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.kpi-up   { color: var(--teal);  font-weight: 600; }
.kpi-down { color: var(--red);   font-weight: 600; }
.kpi-warn { color: var(--amber); font-weight: 600; }

/* === TABLAS === */
.table-wrap { overflow-x: auto; }

table.co-table {
  width: 100%;
  border-collapse: collapse;
}

.co-table th {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 16px;
  text-align: left;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.co-table td {
  padding: 11px 16px;
  font-size: 12.5px;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.co-table tbody tr:hover td { background: var(--gray-50); }
.co-table tbody tr:last-child td { border-bottom: none; }

.td-mono { font-family: 'Courier New', monospace; font-size: 11px; color: var(--indigo-mid); font-weight: 600; }
.td-bold { color: var(--gray-800); font-weight: 600; }
.td-muted { color: var(--gray-400); font-size: 11px; }

/* === BADGES === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: '●'; font-size: 7px; }

.badge-ok   { background: var(--teal-light);  color: var(--teal-dark); }
.badge-warn { background: var(--amber-light); color: var(--amber-dark); }
.badge-crit { background: var(--red-light);   color: var(--red-dark); }
.badge-info { background: var(--indigo-light);color: var(--indigo-mid); }
.badge-gray { background: var(--gray-100);    color: var(--gray-500); }

/* === FORMS === */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

label.form-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
}

.form-control, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: var(--font);
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--indigo-mid);
  box-shadow: 0 0 0 3px rgba(45,63,158,0.12);
}

.form-control::placeholder { color: var(--gray-400); }

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

.form-hint { font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--red-dark); margin-top: 4px; font-weight: 500; }

/* === ALERTAS FLASH === */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.flash-success { background: var(--teal-light); color: var(--teal-dark); border-left: 3px solid var(--teal); }
.flash-error   { background: var(--red-light);  color: var(--red-dark);  border-left: 3px solid var(--red); }
.flash-warn    { background: var(--amber-light); color: var(--amber-dark);border-left: 3px solid var(--amber); }
.flash-info    { background: var(--indigo-light);color: var(--indigo-mid);border-left: 3px solid var(--indigo-mid); }

/* === ALERTAS SIDEBAR (panel derecho) === */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background var(--transition);
}
.alert-item:hover { background: var(--gray-50); }
.alert-item:last-child { border-bottom: none; }

.alert-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.dot-red   { background: var(--red); }
.dot-amber { background: var(--amber); }
.dot-teal  { background: var(--teal); }

.alert-text { font-size: 12px; font-weight: 500; color: var(--gray-800); line-height: 1.4; }
.alert-meta { font-size: 10.5px; color: var(--gray-400); margin-top: 2px; }

/* === PROGRESS BARS === */
.progress-bar { height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.fill-teal   { background: var(--teal); }
.fill-amber  { background: var(--amber); }
.fill-red    { background: var(--red); }
.fill-indigo { background: var(--indigo-mid); }

/* === GRID LAYOUTS === */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }

/* === MODAL === */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal { background: var(--white); border-radius: var(--radius-lg); width: 100%; max-width: 580px; box-shadow: var(--shadow-md); }
.modal-lg { max-width: 780px; }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 700; color: var(--gray-800); }
.modal-close { background: none; border: none; font-size: 20px; color: var(--gray-400); cursor: pointer; line-height: 1; padding: 2px; }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 8px; background: var(--gray-50); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* === TABS === */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--gray-200); margin-bottom: 20px; }
.tab { padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--gray-500); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--transition), border-color var(--transition); }
.tab:hover { color: var(--gray-800); }
.tab.active { color: var(--indigo-mid); border-color: var(--indigo-mid); font-weight: 600; }

/* === SEARCH BAR === */
.search-bar { display: flex; align-items: center; gap: 8px; background: var(--gray-100); border-radius: var(--radius-sm); padding: 7px 12px; }
.search-bar input { background: none; border: none; font-size: 13px; color: var(--gray-800); flex: 1; outline: none; }
.search-bar input::placeholder { color: var(--gray-400); }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--gray-400); }

/* === CÓDIGO IMPRIMIBLE === */
.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--indigo-light);
  color: var(--indigo-mid);
  font-family: 'Courier New', monospace;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 5px;
  letter-spacing: 0.04em;
}

/* === URGENCIA === */
.urgencia-vencido { color: var(--red-dark); font-weight: 600; }
.urgencia-critica { color: var(--red); font-weight: 600; }
.urgencia-pronto  { color: var(--amber-dark); }
.urgencia-ok      { color: var(--teal-dark); }

/* === UTILIDADES === */
.text-muted    { color: var(--gray-400); }
.text-sm       { font-size: 11.5px; }
.text-xs       { font-size: 10.5px; }
.text-bold     { font-weight: 700; }
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }

/* === PRINT === */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-wrap { margin-left: 0; }
  .content { padding: 0; }
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4   { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-220px); }
  .sidebar.open { transform: translateX(0); width: 220px; }
  .main-wrap { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}
