/* Componentes transversales Municipium Bureau — MPS-008 fase 1. */

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  box-shadow: var(--focus-ring);
}

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 200;
  padding: var(--space-3) var(--space-4);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-weight: var(--font-weight-heavy);
  box-shadow: var(--shadow-md);
  transform: translateY(-160%);
  transition: transform var(--duration-fast) var(--easing-standard);
}

.skip-link:focus { transform: translateY(0); }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Botones */
.c-button,
.btn {
  min-height: 44px;
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-family-sans);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-heavy);
  line-height: var(--line-height-tight);
  transition: border-color var(--duration-normal) var(--easing-standard), box-shadow var(--duration-normal) var(--easing-standard), transform var(--duration-normal) var(--easing-standard);
}

.c-button:hover,
.btn:hover { border-color: var(--color-accent-600); }

.c-button--primary,
.btn-primary {
  border-color: var(--color-brand-950);
  background: var(--color-brand-950);
  color: var(--color-text-inverse);
}

.c-button--secondary,
.btn-ghost {
  background: var(--color-surface-subtle);
  color: var(--color-brand-950);
}

.c-button--danger { border-color: var(--color-danger); background: var(--color-danger); color: var(--color-text-inverse); }
.c-button:disabled,
.btn:disabled,
.c-button[aria-disabled="true"],
.btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.65; transform: none; }

/* Formularios y selectores */
.c-field { display: grid; gap: var(--space-2); }
.c-field__label,
label { color: var(--color-brand-950); font-weight: var(--font-weight-heavy); }
.c-field__help,
.helptext,
.microcopy { color: var(--color-text-secondary); font-size: var(--font-size-sm); line-height: var(--line-height-body); }
.c-field__error,
.errorlist { color: var(--color-danger); font-weight: var(--font-weight-bold); }

.c-input,
.c-select,
.c-textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  min-height: 44px;
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-primary);
  font: inherit;
}

:is(.c-input, .c-select, .c-textarea, input, select, textarea)[aria-invalid="true"] { border-color: var(--color-danger); }

/* Tablas */
.c-table-wrap,
.table-wrap { overflow-x: auto; border: var(--border-width) solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.c-table,
.table { width: 100%; border-collapse: collapse; background: var(--color-surface); }
.c-table caption,
.table caption { padding: var(--space-4); color: var(--color-text-secondary); font-weight: var(--font-weight-bold); text-align: left; }
.c-table th,
.c-table td,
.table th,
.table td { padding: var(--space-4); border-bottom: var(--border-width) solid var(--color-border); color: var(--color-text-primary); text-align: left; vertical-align: top; }
.c-table th,
.table th { background: var(--color-surface-muted); color: var(--color-brand-950); font-weight: var(--font-weight-heavy); }

/* Filtros */
.c-filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); padding: var(--space-4); border: var(--border-width) solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }
.c-filter-bar__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-inline-start: auto; }

/* Modales */
.c-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: var(--space-5); }
.c-modal[hidden] { display: none; }
.c-modal__backdrop { position: absolute; inset: 0; background: rgba(0, 20, 63, 0.62); }
.c-modal__dialog { position: relative; width: min(46rem, 100%); max-height: 85vh; overflow: auto; border: var(--border-width) solid var(--color-border-strong); border-radius: var(--radius-xl); padding: var(--space-6); background: var(--color-surface); box-shadow: var(--shadow-lg); }

/* Alertas */
.c-alert,
.message { display: grid; gap: var(--space-1); border: var(--border-width) solid var(--color-border-strong); border-radius: var(--radius-md); padding: var(--space-4); background: var(--color-surface); color: var(--color-text-primary); box-shadow: var(--shadow-md); }
.c-alert--info,
.message-info { border-color: var(--color-info); background: var(--color-info-surface); color: var(--color-info); }
.c-alert--success,
.message-success { border-color: var(--color-success); background: var(--color-success-surface); color: var(--color-success); }
.c-alert--warning,
.message-warning { border-color: var(--color-warning); background: var(--color-warning-surface); color: var(--color-warning); }
.c-alert--danger,
.message-error { border-color: var(--color-danger); background: var(--color-danger-surface); color: var(--color-danger); }

/* Tarjetas e indicadores */
.c-card,
.card { border: var(--border-width) solid var(--color-border); border-radius: var(--radius-xl); padding: var(--space-6); background: var(--color-surface); box-shadow: var(--shadow-md); }
.c-indicator,
.status,
.badge { display: inline-flex; align-items: center; gap: var(--space-2); width: max-content; max-width: 100%; border: var(--border-width) solid var(--color-border-strong); border-radius: var(--radius-pill); padding: var(--space-2) var(--space-3); background: var(--color-surface-muted); color: var(--color-brand-950); font-size: var(--font-size-sm); font-weight: var(--font-weight-heavy); }
.c-indicator--success { border-color: var(--color-success); color: var(--color-success); }
.c-indicator--warning { border-color: var(--color-warning); color: var(--color-warning); }
.c-indicator--danger { border-color: var(--color-danger); color: var(--color-danger); }

/* Navegación */
.c-nav,
.app-menu { display: grid; gap: var(--space-2); }
.c-nav a,
.app-menu a { min-height: 44px; display: flex; align-items: center; border: var(--border-width) solid transparent; border-radius: var(--radius-md); padding: var(--space-3); color: var(--color-text-secondary); font-weight: var(--font-weight-bold); }
.c-nav a:hover,
.c-nav a[aria-current="page"],
.app-menu a:hover,
.app-menu a.active { border-color: var(--color-border-strong); background: var(--color-surface-muted); color: var(--color-brand-950); }

.contrast-toggle { white-space: nowrap; }

/* Ajustes responsivos del shell comercial en escritorio. */
@media (min-width: 1181px) {
  .site-header .nav { gap: 12px; }
  .site-header .logo { flex: 0 0 auto; }
  .site-header .logo img { height: 46px; max-width: 205px; }
  .site-header .nav-links {
    min-width: 0;
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: clamp(6px, 0.55vw, 10px);
    font-size: clamp(0.76rem, 0.68vw, 0.85rem);
  }
  .site-header .nav-links > a:not(.btn) {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .site-header .nav-links .btn {
    min-height: 38px;
    flex: 0 0 auto;
    padding: 9px 12px;
    white-space: nowrap;
  }
}

@media (min-width: 921px) and (max-width: 1180px) {
  .site-header .nav-burger { display: inline-flex; }
  .site-header .nav-links {
    position: absolute;
    left: 16px;
    right: 16px;
    top: calc(100% + 8px);
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    padding: var(--space-4);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-md);
  }
  .site-header .nav-toggle:checked ~ .nav-links { display: flex; }
  .site-header .nav-links .btn { width: 100%; }
}

@media (min-width: 921px) {
  .use-case-tags li {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    text-align: center;
  }
}

/* Estilos antes inline del shell comercial */
.trust-proof-section { max-width: 100vw; overflow-x: clip; padding: var(--space-16) 0; border-block: var(--border-width) solid var(--color-border); background: var(--color-surface-subtle); }
.trust-proof-section .container { width: min(1180px, calc(100vw - 32px)); max-width: calc(100vw - 32px); }
.trust-proof-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); margin-top: var(--space-6); }
.trust-proof-card { min-width: 0; position: relative; overflow: hidden; display: grid; gap: var(--space-3); border: var(--border-width) solid var(--color-border); border-radius: var(--radius-xl); padding: var(--space-5); background: var(--color-surface); box-shadow: var(--shadow-md); }
.trust-proof-card::before { content: ""; position: absolute; width: 7rem; height: 7rem; right: -3.5rem; top: -3.5rem; border-radius: var(--radius-pill); background: var(--color-surface-muted); }
.trust-proof-icon { width: 2.75rem; height: 2.75rem; position: relative; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-md); color: var(--color-brand-700); background: var(--color-surface-muted); font-size: var(--font-size-lg); }
.trust-proof-card h3,
.trust-proof-card p { position: relative; margin: 0; }
.trust-proof-card p { color: var(--color-text-secondary); font-weight: var(--font-weight-medium); line-height: var(--line-height-body); }
.trust-proof-cta { margin-top: var(--space-6); display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); border: var(--border-width) solid var(--color-border-strong); border-radius: var(--radius-xl); padding: var(--space-6); background: var(--color-surface); box-shadow: var(--shadow-md); }
.trust-proof-cta p { margin: 0; max-width: 48rem; color: var(--color-text-secondary); font-weight: var(--font-weight-bold); }

.commercial-footer { border-top: var(--border-width) solid var(--color-border); padding: var(--space-12) 0; background: var(--color-surface-subtle); }
.commercial-footer-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: var(--space-8); align-items: start; }
.commercial-footer-brand { display: grid; gap: var(--space-4); }
.commercial-footer-brand img { height: 3.25rem; max-width: 17.5rem; object-fit: contain; }
.commercial-footer-brand p,
.commercial-footer-card p { margin: 0; color: var(--color-text-secondary); font-weight: var(--font-weight-medium); line-height: var(--line-height-body); }
.commercial-footer-card { display: grid; gap: var(--space-5); border: var(--border-width) solid var(--color-border-strong); border-radius: var(--radius-xl); padding: var(--space-6); background: var(--color-surface); box-shadow: var(--shadow-md); }
.commercial-footer-card h2 { margin: 0; font-size: clamp(1.45rem, 2.1vw, 2.25rem); }
.commercial-footer-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.commercial-footer-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.commercial-footer-detail { min-width: 0; display: grid; gap: var(--space-1); border: var(--border-width) solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); background: var(--color-surface); }
.commercial-footer-detail span { color: var(--color-text-secondary); font-size: var(--font-size-xs); font-weight: var(--font-weight-heavy); letter-spacing: 0.06em; text-transform: uppercase; }
.commercial-footer-detail a,
.commercial-footer-detail strong { color: var(--color-brand-950); font-weight: var(--font-weight-heavy); overflow-wrap: anywhere; }
.institution-switcher { display: grid; gap: var(--space-2); margin: var(--space-4) 0; }
.institution-switcher label { font-size: var(--font-size-sm); }
.institution-switcher select { width: 100%; }
.institution-switcher .btn { width: 100%; }

html[data-contrast="high"] body { background: var(--color-surface); }
html[data-contrast="high"] :where(.site-header, .panel, .card, .c-card, .message, .commercial-footer-card, .trust-proof-card, .trust-proof-cta) { background-image: none; border-width: 2px; }
html[data-contrast="high"] :where(a, button) { text-decoration-thickness: 0.12em; text-underline-offset: 0.18em; }
html[data-contrast="high"] :where(a:not(.btn):not(.c-button)):hover { text-decoration: underline; }

@media (prefers-contrast: more) {
  :root:not([data-contrast="standard"]) { --color-border: #000000; --color-border-strong: #000000; --focus-ring: 0 0 0 4px #ffbf00; }
}

@media (forced-colors: active) {
  .btn,
  .c-button,
  .card,
  .c-card,
  .message,
  .c-alert { forced-color-adjust: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

@media (max-width: 920px) {
  .trust-proof-grid,
  .commercial-footer-grid,
  .commercial-footer-details { grid-template-columns: 1fr; }
  .trust-proof-cta { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .trust-proof-section .container { width: calc(100vw - 22px); max-width: calc(100vw - 22px); }
  .trust-proof-cta .btn,
  .commercial-footer-actions .btn,
  .c-filter-bar__actions { width: 100%; }
}
