/*
 * HMV Digital — responsive workspace
 *
 * Esta capa se carga después de theme.css y hmv-law.css. Centraliza el
 * comportamiento responsive que antes quedaba repartido entre límites de
 * 1100, 1140 y 1200 px. Los componentes operativos aprovechan el monitor;
 * formularios, modales y lectura conservan sus propios anchos controlados.
 */

:root {
  --hmv-workspace-max: 2400px;
  --hmv-workspace-gutter: clamp(10px, 1.45vw, 28px);
  --hmv-workspace-block-start: clamp(12px, 1.3vw, 20px);
}

html {
  max-width: 100%;
  overflow-x: clip;
}

body {
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
}

/* Área de trabajo global: amplia, centrada y con respiración adaptativa. */
.hmv-container {
  min-width: 0;
  width: 100%;
}

.hmv-workspace {
  width: min(100%, var(--hmv-workspace-max));
  min-width: 0;
  margin: var(--hmv-workspace-block-start) auto 28px;
  padding-inline: var(--hmv-workspace-gutter);
}

.hmv-workspace > *,
.hmv-workspace :is(.dash-wrap, .dash-grid, .dash-stats, .hmv-grid, .hmv-row) > * {
  min-width: 0;
}

/* Header alineado con el workspace, sin la vieja columna de 1140/1200 px. */
header.hmv-topbar {
  width: 100% !important;
  margin-bottom: 0 !important;
}

header.hmv-topbar .hmv-topbar-inner {
  width: min(100%, var(--hmv-workspace-max)) !important;
  max-width: var(--hmv-workspace-max) !important;
  min-width: 0;
  margin: 0 auto !important;
  padding: 10px var(--hmv-workspace-gutter) !important;
}

header.hmv-topbar .hmv-topbar-brand-row {
  width: auto;
  min-width: 0;
  flex: 0 0 auto;
}

header.hmv-topbar .hmv-topbar-actions {
  min-width: 0;
}

.hmv-footer-inner {
  max-width: var(--hmv-workspace-max) !important;
}

/* Superficies operativas conocidas: no deben heredar una columna angosta. */
.hmv-workspace > :is(
  .cal-page,
  .rx-shell,
  .op-page,
  .cc-page,
  .lab-page
) {
  width: 100%;
  max-width: none !important;
  min-width: 0;
  margin-inline: 0 !important;
}

/* Calendarios quirúrgicos: siete columnas siempre dentro del ancho real. */
.hmv-workspace .cal-page {
  padding-inline: 0 !important;
}

.hmv-workspace :is(.mes-grid, .mes-head, .mes-week, .sem-grid) {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.hmv-workspace :is(.mes-head, .mes-week) {
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
}

.hmv-workspace :is(.mes-head-cell, .mes-cell, .sem-col) {
  min-width: 0;
}

.hmv-workspace .mes-cell {
  overflow: hidden;
}

.hmv-workspace .mes-cir {
  max-width: 100%;
}

/* El scroll, si una tabla extraordinaria lo necesita, vive en su componente. */
.hmv-table-wrap,
.hmv-workspace [style*="overflow-x:auto"],
.hmv-workspace [style*="overflow-x: auto"] {
  max-width: 100%;
  overscroll-behavior-inline: contain;
}

/* Focus visible consistente para navegación y controles globales. */
:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid rgba(90, 29, 109, .32);
  outline-offset: 2px;
}

/*
 * A 1180 CSS px el conjunto de navegación deja de ser eficiente en una sola
 * fila (incluye 1280 px a zoom 110 % y 1366 px a zoom 125 %). Se reutiliza
 * el botón existente y se abre un panel compacto, apto para escritorio.
 */
@media (max-width: 1180px) {
  header.hmv-topbar .hmv-topbar-inner {
    display: block !important;
  }

  header.hmv-topbar .hmv-topbar-brand-row {
    width: 100%;
  }

  header.hmv-topbar .hmv-hamburger {
    display: flex;
  }

  header.hmv-topbar #hmv-nav {
    display: none !important;
    width: 100% !important;
    max-height: calc(100dvh - 78px);
    margin: 8px 0 0 !important;
    padding: 10px 0 4px;
    overflow-y: auto !important;
    overflow-x: clip !important;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: stretch !important;
    gap: 8px !important;
    text-align: left !important;
  }

  header.hmv-topbar #hmv-nav.hmv-nav-open {
    display: grid !important;
  }

  header.hmv-topbar #hmv-nav > :is(a, form, div) {
    width: 100%;
    min-width: 0;
  }

  header.hmv-topbar #hmv-nav > a,
  header.hmv-topbar #hmv-nav > form > input,
  header.hmv-topbar #hmv-nav > div > button {
    width: 100% !important;
    min-height: 38px;
    justify-content: flex-start !important;
  }

  header.hmv-topbar #hmv-nav > form > input {
    max-width: none;
  }
}

@media (max-width: 800px) {
  :root {
    --hmv-workspace-gutter: 10px;
    --hmv-workspace-block-start: 10px;
  }

  .hmv-workspace .cal-hero {
    padding-top: 16px;
    padding-bottom: 14px;
    margin-bottom: 14px;
  }

  .hmv-workspace .mes-nav,
  .hmv-workspace .cal-nav {
    gap: 8px;
  }

  .hmv-workspace .mes-period,
  .hmv-workspace .cal-nav-period {
    min-width: 150px;
  }
}

@media (max-width: 640px) {
  header.hmv-topbar #hmv-nav {
    grid-template-columns: 1fr;
  }

  .hmv-workspace .mes-head-cell {
    font-size: .64rem;
    letter-spacing: .025em;
  }

  .dia-modal {
    width: min(100%, 460px) !important;
    max-height: calc(100dvh - 24px) !important;
    padding: 18px !important;
  }
}

@media print {
  html,
  body {
    overflow: visible;
  }

  .hmv-workspace {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }
}
