/* ============================================
   SISTEMA CIF - Estilos Globales
   Paleta: azul institucional + blanco + gris claro
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@300;400;500;600;700&family=Source+Serif+4:wght@400;600&display=swap');

:root {
  --primary: #1a6ea8;
  --primary-dark: #145a8a;
  --primary-light: #e8f2fa;
  --primary-mid: #3b8ec4;
  --accent: #f0a500;
  --accent-hover: #d4920a;
  --success: #2e7d32;
  --success-light: #e8f5e9;
  --danger: #c0392b;
  --danger-light: #fdecea;
  --warning: #e67e22;

  --white: #ffffff;
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --border: #d0dae6;
  --border-light: #e8edf3;

  --text-primary: #1a2533;
  --text-secondary: #4a5e72;
  --text-muted: #7a8fa6;
  --text-label: #5a6e82;

  --sidebar-w: 200px;
  --header-h: 56px;
  --header-t: 46px;
  --subheader-h: 48px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);

  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 10px;
}

.circle {
    list-style-type: circle;
}
.square {
    list-style-type: square;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================
   BROWSER BAR (decorativo)
   ============================================ */
.left {float: left;}
.right {
  font-family:Arial, Helvetica, sans-serif;font-size:12px;
  float: right;
  color: #fff;
}
.browser-bar {
  background: #e8eaed;
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 6px;
  border-bottom: 1px solid #ccc;
  flex-shrink: 0;
}
.browser-dot { width: 11px; height: 11px; border-radius: 50%; }
.browser-dot.red   { background: #ff5f57; }
.browser-dot.yellow{ background: #febc2e; }
.browser-dot.green { background: #28c840; }
.browser-url {
  flex: 1;
  margin: 0 12px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 12px;
  height: 22px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 12px;
  color: #555;
  max-width: 500px;
}

/* ============================================
   HEADER principal
   ============================================ */
.app-header {
  background: var(--primary);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 10;
}
.table-header {
  background: var(--primary);
  height: var(--header-t);
  width: 100%;
  padding: 0 20px;
}
.app-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.app-header .logo-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.2);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
}
.button-icon {
  width: max-content; height: 29px; padding: 2px;
  background: rgba(255,255,255,0.2);
  border-style: none;
  border-radius: 6px;
  display: inline;
  font-weight: 700; font-size: 14px; color: #fff;
}
.app-header .logo-text {
  font-size: 15px; font-weight: 600; color: #fff;
  line-height: 1.2;
}
.app-header .logo-subtitle {
  font-size: 11px; color: rgba(255,255,255,0.75); font-weight: 400;
}
.header-spacer { flex: 1; }
.header-patient-info {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 6px 12px;
  color: #fff;
}
.header-patient-info .patient-name {
  font-weight: 600; font-size: 13px;
}
.header-patient-info .patient-meta {
  font-size: 11px; color: rgba(255,255,255,0.8);
}
.header-avatar {
  width: 30px; height: 30px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #fff;
}
.header-user {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  cursor: pointer;
}

/* ============================================
   SUB-HEADER (breadcrumb / título de sección)
   ============================================ */
.sub-header {
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  height: var(--subheader-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 8px;
}
.sub-header .page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.sub-header .breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
}
.sub-header .breadcrumb a { color: var(--primary); }
.sub-header .breadcrumb .sep { color: var(--border); }
.sub-header .header-actions { margin-left: auto; display: flex; gap: 8px; }

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */
.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.app-body {
  display: flex;
  flex: 1;
}
.caja {
    -webkit-transition: background-color 200ms cubic-bezier(0,0,0.2,1);
    transition: background-color 200ms cubic-bezier(0,0,0.2,1);
    background-color: #fff;    border: 1px solid #dadce0;
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 24px;
    page-break-inside: avoid;
    word-wrap: break-word;
}
/* ============================================
   SIDEBAR NAVEGACIÓN
   ============================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  flex-shrink: 0;
}
.sidebar-patient-mini {
  padding: 12px 14px 16px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 8px;
  text-align: center;
}
.sidebar-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 2px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600; color: var(--primary);
  margin: 0 auto 8px;
}
.sidebar-patient-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
}
.sidebar-patient-age {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
}

.nav-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
  padding: 8px 14px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  font-size: 13px; color: var(--text-secondary);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}
.div-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  font-size: 13px; color: var(--text-secondary);
  border-left: 3px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}
.div-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}
.nav-item .nav-icon {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 14px;
}

/* ============================================
   CONTENIDO PRINCIPAL
   ============================================ */
.main-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-h) - var(--subheader-h) - 36px);
}

/* ============================================
   CARDS / CONTENEDORES
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 10px;
}
.card-title {
  font-size: 14px; font-weight: 600; color: var(--text-primary);
}
.card-body { padding: 16px 20px; }

/* ============================================
   BOTONES
   ============================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); }
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ============================================
   FORMULARIOS
   ============================================ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-label);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 8px 11px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  background: #fff;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,110,168,0.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.char-count { font-size: 11px; color: var(--text-muted); text-align: right; margin-top: 3px; }

/* ============================================
   TABLAS
   ============================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--primary-light); }
.data-table .sub-row td {
  background: #f8fbfe;
  padding-left: 36px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}
.data-table .sub-row:hover td { background: #eef5fc; }
.data-table .group-header td {
  background: #f0f6fc;
  font-weight: 600;
  color: var(--primary-dark);
  border-top: 2px solid var(--primary-light);
}

/* ============================================
   BADGES / ESTADO
   ============================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: #fef3e2; color: var(--warning); }
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-neutral { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ============================================
   RADIO / OPCIONES CIF
   ============================================ */
.radio-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.radio-option:hover { border-color: var(--primary); background: var(--primary-light); }
.radio-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}
.radio-option input[type="radio"] { margin-top: 2px; accent-color: var(--primary); }
.radio-option .option-code {
  font-family: monospace; font-size: 12px; font-weight: 700;
  color: var(--primary);
  min-width: 48px;
}
.radio-option .option-text { font-size: 13px; color: var(--text-primary); }

/* ============================================
   ÁRBOL CIF (clasificador)
   ============================================ */
.cif-tree { font-size: 13px; }
.cif-node {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}
.cif-node:hover { background: var(--primary-light); }
.cif-node.selected { background: #ddeefa; }
.cif-toggle {
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}
.cif-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: var(--primary);
  color: #fff;
  font-size: 11px; font-weight: 700;
  border-radius: 4px;
  flex-shrink: 0;
}
.cif-label { color: var(--text-primary); }
.cif-code { font-family: monospace; font-size: 11px; color: var(--text-muted); margin-left: 4px; }
.cif-children { margin-left: 20px; border-left: 1px dashed var(--border); padding-left: 8px; }
.cif-separator { height: 1px; background: var(--border-light); margin: 4px 0; }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: none; border: none;
  cursor: pointer; font-size: 18px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ============================================
   ALERTS / NOTIFICACIONES
   ============================================ */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 12px;
}
.alert-info { background: var(--primary-light); border-left: 3px solid var(--primary); color: var(--primary-dark); }
.alert-success { background: var(--success-light); border-left: 3px solid var(--success); color: var(--success); }
.alert-warning { background: #fef3e2; border-left: 3px solid var(--warning); color: var(--warning); }

/* ============================================
   UPLOAD ZONE
   ============================================ */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg);
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.upload-zone .upload-icon { font-size: 28px; margin-bottom: 8px; }
.upload-zone .upload-text { font-size: 13px; font-weight: 500; }
.upload-zone .upload-hint { font-size: 11px; margin-top: 4px; }

.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.file-item .file-icon { font-size: 16px; color: var(--primary); }
.file-item .file-name { flex: 1; font-size: 13px; color: var(--text-primary); }
.file-item .file-remove {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px; padding: 2px;
  border-radius: 50%;
}
.file-item .file-remove:hover { color: var(--danger); background: var(--danger-light); }

/* ============================================
   UTILIDADES
   ============================================ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-muted { color: var(--text-muted); font-size: 12px; }
.text-right { text-align: right; }
.font-mono { font-family: monospace; }
.font-bold { font-weight: 600; }
.divider { height: 1px; background: var(--border-light); margin: 16px 0; }
.section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted);
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}
.info-row {
  display: flex; gap: 8px; margin-bottom: 8px; font-size: 13px;
}
.info-row .info-label {
  color: var(--text-muted); min-width: 140px; flex-shrink: 0;
}
.info-row .info-value { color: var(--text-primary); font-weight: 500; }

/* ============================================
   PÁGINA COMPLETA WRAPPER
   ============================================ */
.page-frame {
  width: 1366px;
  min-height: 768px;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px var(--border);
}
@media (max-width: 1400px) {
  .page-frame { width: 100%; }
}
