/*
 * FacturaProRD UI modernization foundation.
 * This layer is intentionally small and semantic: it fixes focus, containment
 * and modal viewport contracts without restyling business modules globally.
 */

:where(.app-workspace, .view-root, .page, .page__header, .page__title-group, .page__toolbar) {
  min-width: 0;
}

.topbar__start,
.topbar__actions,
.topbar__summary,
.user-pill,
.user-pill__copy {
  min-width: 0;
}

.topbar__start {
  flex: 1 1 auto;
}

.topbar__actions {
  flex: 0 1 auto;
}

.topbar__summary {
  max-width: 100%;
}

.topbar__summary :is(strong, small),
.user-pill__copy :is(strong, span) {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-pill {
  max-width: min(280px, 30vw);
}

.user-pill__copy {
  max-width: 190px;
}

:where(.card, .modal, .modal__header, .modal__body, .modal__footer) {
  min-width: 0;
}

:where(.app-shell, .modal-root) :where(
  a[href],
  button,
  input,
  select,
  textarea,
  [role="button"],
  [role="tab"],
  [tabindex]:not([tabindex="-1"])
):focus-visible {
  outline: 3px solid var(--theme-focus, var(--color-primary, #2563eb));
  outline-offset: 2px;
}

.modal[tabindex="-1"]:focus {
  outline: none;
}

.modal__header > :first-child {
  min-width: 0;
}

.modal__title,
.modal__subtitle {
  overflow-wrap: anywhere;
}

.modal__body {
  min-height: 0;
  max-width: 100%;
  scrollbar-gutter: stable;
}

.modal__footer {
  flex-shrink: 0;
}

.modal__header [data-modal-action="close"] {
  min-width: 36px;
  min-height: 36px;
}

:where(.login-form__text-button, .auth-card__hint a, .signup-panel__brand > a) {
  display: inline-flex;
  min-height: 36px;
  margin-inline: -6px;
  padding: 8px 6px;
  align-items: center;
  justify-content: center;
}

.route-state-page {
  display: grid;
  min-height: min(620px, calc(100dvh - 150px));
  place-items: center;
}

.route-state {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  width: min(100%, 680px);
  padding: clamp(24px, 4vw, 44px);
  gap: 22px;
  align-items: start;
}

.route-state__icon {
  display: grid;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  place-items: center;
  color: var(--theme-info, #0ea5e9);
  background: color-mix(in srgb, currentColor 12%, var(--theme-card-bg, #fff));
}

.route-state--warning .route-state__icon { color: var(--theme-warning, #f59e0b); }
.route-state--danger .route-state__icon { color: var(--theme-danger, #ef4444); }

.route-state__icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.route-state__content { min-width: 0; }

.route-state__eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--theme-text-muted, #52627a);
  font-size: 0.72rem;
  font-weight: var(--theme-weight-bold, 700);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.route-state__title {
  margin: 0;
  color: var(--theme-text, #0f172a);
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.16;
}

.route-state__description {
  max-width: 56ch;
  margin: 10px 0 22px;
  color: var(--theme-text-muted, #52627a);
  line-height: 1.65;
}

.route-state__action { width: fit-content; }

@media (max-width: 640px) {
  .modal-overlay {
    align-items: end;
  }

  .modal {
    width: 100%;
    max-width: 100%;
  }

  .modal__footer .btn {
    min-height: 40px;
  }

  .route-state-page { min-height: calc(100dvh - 120px); }

  .route-state {
    grid-template-columns: minmax(0, 1fr);
    padding: 24px 20px;
  }
}
