/* =========================
   Enlace Médico - Base CSS
   Ruta: core/static/core/css/base.css
   ========================= */

/* ---- Variables ---- */
:root{
  --navy: #071a2b;
  --navy-2: #061821;
  --gold: #c7a24a;

  --bg: #eef3f9;
  --card: #ffffff;

  --text: #071a2b;
  --muted: rgba(7, 26, 43, .65);
  --line: rgba(7, 26, 43, .10);

  --shadow: 0 18px 45px rgba(7, 26, 43, .10);
  --shadow-2: 0 26px 70px rgba(7, 26, 43, .18);

  --radius: 18px;

  /* Design tokens */
  --radius-sm: 12px;
  --radius-lg: 22px;

  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;

  --font-sm: 0.92rem;
  --font-base: 1rem;
  --font-lg: 1.08rem;

  --focus-ring: 0 0 0 4px rgba(199, 162, 74, .22);

  --ease: cubic-bezier(.2,.9,.2,1);
  --t-fast: 160ms var(--ease);
  --t: 220ms var(--ease);

  --btn-py: 10px;
  --btn-px: 16px;
  --btn-gap: 8px;

  --card-pad: 18px;
  --card-border: 1px solid rgba(7, 26, 43, .10);

  /* Capas */
  --z-header: 9000;
  --z-subnav: 8500;
  --z-dropdown: 99999;

  /* Modales */
  --z-modal: 120000;
  --z-modal-backdrop: 119000;

  /* Home modal */
  --z-home-modal-backdrop: 119100;
  --z-home-modal: 119200;

  /* Aproximación para sticky del subnav */
  --header-h: 72px;
}

/* ---- Reset suave + anti overflow global ---- */
*{ box-sizing: border-box; }
html, body{ height: 100%; width: 100%; overflow-x: hidden; }

html{ background: #e9e6e6; }

body{
  margin: 0;
  font-family: "Poppins", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: transparent;
  position: relative;
  z-index: 0;
}

/* Evita que el fondo se mueva cuando un modal está abierto */
body.modal-open{ overflow: hidden; }

/* Todo el contenido por encima del fondo */
body > *{ position: relative; }

/* ---- Modales: siempre por encima de TODO ---- */
.modal,
.modalx{ z-index: var(--z-modal) !important; }
.modal-backdrop{ z-index: var(--z-modal-backdrop) !important; }

/* Evita overflow por imágenes / svg / video */
img, svg, video{
  max-width: 100%;
  height: auto;
  display: block;
}

/* Texto largo (links/correos) no rompen layout */
p, a, span, h1, h2, h3, h4, h5, h6{
  overflow-wrap: anywhere;
  word-break: break-word;
}

a{ color: inherit; text-decoration: none; }
a:hover{ text-decoration: none; }

/* ---- Container (UNIFICADO, sin peleas) ---- */
.container{
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 16px;
}

/* ---- Utilidades ---- */
.w-100{ width: 100%; }
.gap-2{ gap: .5rem; }
.text-center{ text-align: center; }

/* ---- Botones ---- */
.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  border-radius: 999px;
  padding: .7rem 1.05rem;
  font-weight: 800;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  user-select: none;
}

.btn:active{ transform: translateY(0); opacity: .96; }
.btn:hover{ transform: translateY(-1px); }

.btn-ghost{
  background: rgba(199, 162, 74, .16);
  border-color: rgba(199, 162, 74, .55);
  color: var(--navy);
  box-shadow: 0 10px 22px rgba(199, 162, 74, .10);
}
.btn-ghost:hover{ background: rgba(199, 162, 74, .22); }

.btn-gold{
  background: var(--gold);
  border-color: rgba(199, 162, 74, .50);
  color: #141414;
  box-shadow: 0 12px 26px rgba(199, 162, 74, .18);
}
.btn-gold:hover{ filter: brightness(1.03); }

/* === EM: DOC PREVIEW MODAL === */
.doc-preview-modal .modal-dialog{
  max-width: clamp(520px, 88vw, 980px);
}
.doc-preview-modal .modal-content{
  border-radius: var(--radius);
  overflow: hidden;
  height: clamp(520px, 78vh, 760px);
  max-height: 86vh;
}
.doc-preview-modal .modal-body{
  padding: 0 !important;
  flex: 1 1 auto;
  overflow: hidden;
  background: #0b1c24;
}
.doc-preview-modal .modal-header,
.doc-preview-modal .modal-footer{
  background: #fff;
}
.doc-preview-modal iframe{
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

@media (max-width: 576px){
  .doc-preview-modal .modal-dialog{
    max-width: 96vw;
    margin: .75rem auto;
  }
  .doc-preview-modal .modal-content{
    height: 86vh;
    max-height: 90vh;
  }
}

/* ---- Header ---- */
.site-header{
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  overflow: visible !important;

  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  border-bottom: 1px solid rgba(255, 255, 255, .10);

  /* Safe area notch */
  padding-top: env(safe-area-inset-top);
}

.header-wrap{
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding: 14px 0;
  overflow: visible !important;
  min-width: 0;
}

/* ===== Brand ===== */
.brand{
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 auto;
  min-width: 0;
}

.brand__logo{
  height: 56px;
  padding: 4px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(199,162,74,.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.brand__logo-img{
  height: 100%;
  width: auto;
  object-fit: contain;
  object-position: center;
  display: block;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.22));
}

.brand__name{
  color: #fff;
  font-weight: 900;
  letter-spacing: -.2px;
  max-width: 48vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Nav links ===== */
.nav{
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.nav__link{
  color: rgba(255, 255, 255, .90);
  font-weight: 700;
  opacity: .92;
}
.nav__link:hover{
  opacity: 1;
  text-decoration: underline;
  text-decoration-color: rgba(199, 162, 74, .75);
  text-underline-offset: 6px;
}

/* ===== Header actions ===== */
.header-actions{
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Toggle móvil */
.nav-toggle{
  display: none;
  border: 1px solid rgba(255, 255, 255, .20);
  background: rgba(255, 255, 255, .06);
  color: #fff;
  border-radius: 12px;
  padding: .55rem .75rem;
  font-weight: 900;
  cursor: pointer;
}

/* Botones (dorado) en header */
.site-header .btn-ghost{
  background: var(--gold) !important;
  border-color: rgba(199, 162, 74, .60) !important;
  color: #141414 !important;
}
.site-header .btn-ghost:hover{
  filter: brightness(1.04) !important;
}

/* ---- Subnav ---- */
.subnav{
  position: sticky;
  top: var(--header-h);
  z-index: var(--z-subnav);

  border-top: 1px solid rgba(255, 255, 255, .10);
  background: linear-gradient(180deg, rgba(6, 24, 33, .92), rgba(7, 26, 43, .92));
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 36px rgba(0, 0, 0, .18);

  overflow: hidden;
  max-height: 90px;

  will-change: max-height, opacity, transform;
  transform: translateZ(0);
  backface-visibility: hidden;

  transition: max-height .22s ease, opacity .16s ease, transform .22s ease;
}

.subnav__inner{
  padding: 10px 0 14px;
  display: flex;
  gap: 10px;
  align-items: center;

  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  padding-bottom: 6px;

  transition: opacity .16s ease, transform .22s ease;
}
.subnav__inner::-webkit-scrollbar{ display: none; }

.subnav__pill{
  display: inline-flex;
  align-items: center;
  padding: .55rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .20);
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .92);
  font-weight: 800;
  white-space: nowrap;
  scroll-snap-align: start;
}
.subnav__pill:hover{
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .30);
  color: #fff;
}

.subnav__badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  height:18px;
  margin-left:8px;
  border-radius:999px;
  background: rgba(199,162,74,.95);
  color:#071a2b;
  font-weight: 1000;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(0,0,0,.22);
}

/* Subnav oculto */
.subnav.is-hidden{
  max-height: 0;
  opacity: 0;
  transform: translate3d(0, -10px, 0);
  pointer-events: none;
}
.subnav.is-hidden .subnav__inner{
  opacity: 0;
  transform: translate3d(0, -6px, 0);
}

/* ---- Dropdown usuario ---- */
.user-menu{
  position: relative;
  z-index: calc(var(--z-dropdown) - 1);
  --menu-w: 280px;
}
.user-menu__btn{
  position: relative;
  z-index: var(--z-dropdown);
  pointer-events: auto;
}
.user-menu__chev{
  opacity: .9;
  color: rgba(255, 255, 255, .92);
}

.user-menu__panel{
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  transform: translateX(-50%);
  width: min(var(--menu-w), calc(100vw - 24px));

  max-height: min(560px, calc(100dvh - var(--header-h) - 18px));
  max-height: min(560px, calc(100vh - var(--header-h) - 18px));

  background: #fff;
  border: 1px solid rgba(7, 26, 43, .12);
  border-radius: 18px;
  box-shadow: var(--shadow);

  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;

  padding: 0;
  display: none;
  z-index: var(--z-dropdown);
}
.user-menu.is-open .user-menu__panel{ display: block; }

.user-menu__head{
  padding: 12px 18px;
  font-size: .82rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: rgba(7, 26, 43, .55);
  font-weight: 900;
  background: rgba(7, 26, 43, .02);
}
.user-menu__panel > .user-menu__head:first-child{
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
}

.user-menu__sep{
  height: 1px;
  background: rgba(7, 26, 43, .10);
  margin: 8px 0;
}

.user-menu__panel a,
.user-menu__panel button{
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 18px;

  font-weight: 900;
  color: var(--navy);
  line-height: 1.2;

  background: transparent;
  border: 0;
  cursor: pointer;
  white-space: normal;
}
.user-menu__panel a:hover,
.user-menu__panel button:hover{
  background: rgba(7, 26, 43, .04);
}

.user-menu__item--danger{ color: #b42318 !important; }
.user-menu__item--btn{ background: transparent; }

.user-menu__panel *{ float: none !important; }

/* Capas sin clicks raros */
.site-header::before,
.site-header::after,
.subnav::before,
.subnav::after{
  pointer-events: none !important;
}

/* Perfil */
.user-toggle{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .20);
  background: rgba(255, 255, 255, .06);
  padding: .55rem .85rem;
  cursor: pointer;
  color: rgba(255, 255, 255, .92);
}

.user-avatar-fallback{
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(199, 162, 74, .18);
  border: 2px solid rgba(199, 162, 74, .35);
  color: #fff;
  font-weight: 900;
}

.user-avatar{
  width: 40px;
  height: 40px;
  border-radius: 999px;
  object-fit: cover;
  background: rgba(255, 255, 255, .08);
  border: 2px solid rgba(199, 162, 74, .35);
}

.user-meta{
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  text-align: left;
}
.user-name{
  font-weight: 900;
  font-size: 14px;
  color: #fff;
}
.user-role{
  font-size: 12px;
  color: rgba(255, 255, 255, .75);
}

/* ---- Mobile nav ---- */
.mobile-nav{
  display: none;
  padding: 10px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, .10);
}
.mobile-nav.is-open{ display: block; }

.mobile-link{
  display: block;
  padding: 10px 0;
  color: rgba(255, 255, 255, .92);
  font-weight: 800;
}
.mobile-link:hover{ text-decoration: underline; }

.mobile-actions{
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

/* ---- Main ---- */
.site-main{
  min-height: 60vh;
  padding: 24px 0 40px;
}

/* ---- Footer ---- */
.site-footer{
  background: #0a1f33;
  color: rgba(255, 255, 255, .88);
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding-bottom: env(safe-area-inset-bottom);
}

.footer-wrap{
  padding: 28px 0;
  display: grid;
  grid-template-columns: 1.2fr .7fr 1fr;
  gap: 22px;
  align-items: start;
}

.footer-brand{
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.footer-logo-img{
  width: 46px;
  height: 46px;
  border-radius: 999px;
  object-fit: contain;
  padding: 6px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(199, 162, 74, .24);
}

.footer-title{
  margin: 0;
  font-weight: 900;
  color: #fff;
}

.footer-desc{
  margin: .35rem 0 0;
  color: rgba(255, 255, 255, .74);
  line-height: 1.35;
}

.footer-h{
  margin: 0 0 10px;
  font-weight: 900;
  color: #fff;
}

.footer-links a{
  display: block;
  padding: 6px 0;
  color: rgba(255, 255, 255, .80);
}
.footer-links a:hover{
  color: #fff;
  text-decoration: underline;
}

.social-row{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.social{
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .04);
}
.social svg{
  width: 18px;
  height: 18px;
  fill: rgba(255, 255, 255, .90);
}
.social:hover{
  border-color: rgba(199, 162, 74, .45);
  background: rgba(199, 162, 74, .12);
}

.footer-note{
  margin: 0;
  color: rgba(255, 255, 255, .72);
}

.footer-bottom{
  border-top: 1px solid rgba(255, 255, 255, .10);
}

.bottom-wrap{
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  color: rgba(255, 255, 255, .72);
}

.dot{ opacity: .65; }

.legal{
  color: rgba(255, 255, 255, .78);
}
.legal:hover{
  color: #fff;
  text-decoration: underline;
}

/* ===== Estilo "Crear cuenta" en login ===== */
.auth-alt a,
.login-alt a,
.form-alt a{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .55rem .9rem;
  border-radius: 999px;
  background: var(--gold);
  border: 1px solid rgba(199, 162, 74, .50);
  color: #141414;
  font-weight: 900;
  text-decoration: none;
  margin-left: 8px;
  box-shadow: 0 12px 26px rgba(199, 162, 74, .18);
}
.auth-alt a:hover,
.login-alt a:hover,
.form-alt a:hover{
  filter: brightness(1.03);
  transform: translateY(-1px);
}

/* =========================
   COMPONENTES (Tokens → UI)
   ========================= */
.em-card{ background: var(--card); border: var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); }
.em-card__body{ padding: var(--card-pad); }

.em-input, .em-select, .em-textarea{
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(7,26,43,.16);
  padding: 12px 14px;
  background: rgba(255,255,255,.92);
  color: var(--text);
  outline: none;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.em-input:focus, .em-select:focus, .em-textarea:focus{
  border-color: rgba(199,162,74,.65);
  box-shadow: var(--focus-ring);
}

.em-badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: .82rem;
  border: 1px solid rgba(7,26,43,.12);
  background: rgba(255,255,255,.65);
}
.em-badge--gold{ border-color: rgba(199,162,74,.35); background: rgba(199,162,74,.12); color: #6b5215; }
.em-badge--ok{ border-color: rgba(40,167,69,.28); background: rgba(40,167,69,.12); color: #1f6a33; }

/* ---- Skeleton ---- */
.skeleton{
  position: relative;
  overflow: hidden;
  background: rgba(7,26,43,.08);
  border-radius: 12px;
}
.skeleton::after{
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: skeleton 1.15s infinite;
}
@keyframes skeleton{
  100%{ transform: translateX(100%); }
}
.skeleton--line{ height: 12px; }
.skeleton--h{ height: 18px; }
.skeleton--block{ height: 72px; }
.skeleton--circle{ width: 52px; height: 52px; border-radius: 999px; }

/* ---- Micro animaciones (suaves) ---- */
.btn, .nav__link, .portal-tab, .section-card, .card, .social{
  transition: transform var(--t), box-shadow var(--t), opacity var(--t), background-color var(--t), border-color var(--t);
}
.btn:active{ transform: translateY(1px) scale(.99); }
.section-card:hover{ transform: translateY(-2px); box-shadow: var(--shadow-2); }

@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- Empty states ---- */
.empty-state{
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px dashed rgba(7,26,43,.20);
  background: rgba(255,255,255,.72);
  align-items: center;
}
.empty-state__art{ position: relative; }
.empty-state__icon{
  width: 54px; height: 54px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 26px;
  background: rgba(7,26,43,.06);
  border: 1px solid rgba(7,26,43,.10);
}
.empty-state__svg{ width: 100%; height: 64px; margin-top: 10px; }
.empty-state__title{ font-weight: 700; letter-spacing: .2px; }
.empty-state__subtitle{ color: var(--muted); margin-top: 4px; }
.empty-state__actions{ margin-top: 12px; }

@media (max-width: 520px){
  .empty-state{ grid-template-columns: 1fr; }
  .empty-state__svg{ display: none; }
}

/* ---- Facility / Hospital logos ---- */
.facility-badge{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.facility-icon{
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(7,26,43,.12);
  background: #fff;
  flex: 0 0 auto;
}
.facility-icon--sm{ width: 20px; height: 20px; border-radius: 6px; }
.facility-icon--lg{ width: 34px; height: 34px; border-radius: 8px; }

/* ---- Responsive ---- */
@media (max-width: 960px){
  .footer-wrap{ grid-template-columns: 1fr; }
}

@media (max-width: 860px){
  .nav{ display: none; }
  .nav-toggle{
    display: inline-flex;
    margin-left: auto;
  }

  /* 🔥 clave: evita cortes y overflow */
  .header-wrap{
    justify-content: space-between;
    gap: 10px;
  }
  .header-actions{ display: none; }

  :root{ --header-h: 68px; }
}

@media (max-width: 640px){
  .brand__logo{ height: 46px; padding: 3px 10px; border-radius: 14px; }
  .site-main{ padding: 18px 0 32px; }
}

@media (max-width: 520px){
  .brand__name{ display: none; }
  .user-name{ max-width: 180px; }
  .user-menu{ --menu-w: 320px; }
}
@media (max-width: 860px){
  .header-wrap{
    padding-right: 10px; /* empuja el botón un poco a la izquierda */
  }
}

/* y si lo quieres aún más hacia adentro en teléfonos chicos */
@media (max-width: 520px){
  .header-wrap{
    padding-right: 14px;
  }
}
@media (max-width: 860px){
  /* más aire a los lados */
  .container{ padding-inline: 14px; }

  /* empuja un poquito el botón hacia adentro */
  .nav-toggle{ margin-right: 6px; }

  /* marca que el header se sienta centrado */
  .header-wrap{ align-items: center; }
}
