/**
 * Everroux Standard UI — sticky header, File menu, tab navigation.
 * Reference: Residential Dead Load Calculator V1.
 * Sync: node "../Shared Assets/everroux-standard-ui/copy-standard-ui.mjs"
 */
:root {
  --blue: #1f4e79;
  --copper: #d97706;
  --ee-navy: var(--blue);
  --ee-sage: #547d63;
  --ee-sage-dark: #3d5c47;
  --ee-sage-mid: #6f917c;
  --ee-sage-light: #93ac9d;
  --ee-gray: #828283;
  --bg: #eef1ef;
  --surface: #ffffff;
  --border: #c5ccc6;
  --text: #1a2e34;
  --muted: var(--ee-gray);
  --accent: var(--ee-navy);
  --accent-secondary: var(--ee-sage);
  --accent-soft: #e6ede8;
  --radius: 0.5rem;
  --shadow: 0 1px 3px rgba(0, 63, 91, 0.08);
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --er-font-family: var(--font);
  /* Ultra Compact form defaults — overridden by everroux-density.css / data-density */
  --er-type-app-title: 18px;
  --er-type-section: 12px;
  --er-type-subhead: 12px;
  --er-type-label: 11px;
  --er-type-value: 12px;
  --er-type-result: 12px;
  --er-type-table: 11px;
  --er-type-note: 11px;
  --er-type-fine: 10px;
  --er-type-unit: 10px;
  --er-weight-regular: 400;
  --er-weight-medium: 500;
  --er-weight-semibold: 600;
  --er-input-height: 26px;
  --er-btn-height: 26px;
  --er-section-header-height: 24px;
  --er-section-pad: 6px;
  --er-card-pad: 6px;
  --er-page-margin: 8px;
  --er-section-gap: 8px;
  --er-label-gap: 2px;
  --er-grid-gap: 4px;
  --er-field-num-width: 80px;
  --er-radius-dense: 3px;
}

.app--dark {
  --bg: #1a1f23;
  --surface: #2d3436;
  --border: #4f5b66;
  --text: #e6e8eb;
  --muted: #9ca3af;
  --accent-soft: #3d4549;
}

/* ——— Sticky top chrome ——— */
.app-top {
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.12);
}

.app-top__inner {
  max-width: none;
  margin: 0;
  padding: 0 0.75rem;
}

/* ——— Brand banner ——— */
.app-header {
  background: var(--blue);
  color: #fff;
  border-bottom: 3px solid var(--copper);
  padding: 0.65rem 0;
}

.app-header__bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  justify-self: start;
}

.app-header__logo {
  flex-shrink: 0;
  height: 40px;
  width: 40px;
  object-fit: contain;
  display: block;
  border-radius: 10px;
}

.app-header__copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
}

.app-header__app-name {
  margin: 0;
  font-size: var(--er-type-app-title);
  font-weight: var(--er-weight-semibold);
  letter-spacing: 0.01em;
  color: #fff;
  line-height: 1.2;
}

.app-header__subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: rgb(255 255 255 / 0.9);
  line-height: 1.25;
}

.app-header__doc-title {
  margin: 0;
  justify-self: center;
  text-align: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.05rem;
  font-weight: var(--er-weight-semibold);
  letter-spacing: 0.01em;
  color: #1f2933;
  line-height: 1.2;
}

input.app-header__doc-title {
  display: block;
  width: 100%;
  max-width: 460px;
  margin-inline: auto;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  color: #1f2933;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 0.35rem;
  padding: 0.35rem 0.6rem;
  cursor: text;
  box-sizing: border-box;
}

input.app-header__doc-title::placeholder {
  color: rgb(31 41 51 / 0.45);
}

input.app-header__doc-title:hover {
  border-color: rgba(255, 255, 255, 0.7);
  background: #fff;
}

input.app-header__doc-title:focus {
  outline: none;
  border-color: var(--copper);
  background: #fff;
  text-overflow: clip;
}

.app-header__doc-block {
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  width: 100%;
}

.app-header__doc-subtitle {
  max-width: 460px;
  margin: 0.15rem 0 0;
  padding: 0 0.25rem;
  color: rgb(255 255 255 / 0.86);
  font-size: 0.72rem;
  line-height: 1.25;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header__actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.app-header__action-btn {
  background: rgb(255 255 255 / 0.15);
  border: 1px solid rgb(255 255 255 / 0.35);
  color: #fff;
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78rem;
  font-family: inherit;
}

.app-header__action-btn:hover {
  background: rgb(255 255 255 / 0.25);
}

.app-header__spacer {
  display: none;
}

/* ——— Tab bar + File menu ——— */
.app-top .tab-bar {
  display: block;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-top .tab-bar .tab-bar__row,
.app-top .tab-bar .app-top__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
}

.file-menu {
  position: relative;
  margin-right: 0.35rem;
}

.file-menu__panel {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  z-index: 300;
  min-width: 9.5rem;
  padding: 0.35rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.file-menu__panel[hidden] {
  display: none !important;
}

.file-menu__item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.85rem;
  border: none;
  background: none;
  text-align: left;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.file-menu__item:hover,
.file-menu__item:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}

.file-menu__item:disabled,
.file-menu__item--muted {
  opacity: 0.55;
  cursor: default;
}

.file-menu__separator {
  height: 1px;
  margin: 0.35rem 0;
  background: var(--border);
}

.file-menu__label {
  padding: 0.25rem 0.85rem 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted, #667);
}

.file-menu__recent {
  max-height: 12rem;
  overflow: auto;
}

.app-top .tab-btn {
  flex: 0 0 auto;
  min-width: 0;
  margin-bottom: -1px;
  padding: 0.55rem 0.9rem;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.app-top .tab-btn:hover {
  color: var(--text);
  background: none;
}

.app-top .tab-btn--active {
  color: var(--blue);
  border-bottom-color: var(--copper);
  background: none;
  box-shadow: none;
}

/* ——— Tab panels + wizard footer ——— */
.tab-panel[hidden] {
  display: none !important;
}

.tab-footer {
  display: flex;
  justify-content: space-between;
  margin-top: var(--er-section-gap, 8px);
  padding-top: var(--er-space-3, 4px);
  border-top: 1px solid var(--border);
}

.btn-tab-nav {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-tab-nav:hover:not(:disabled) {
  border-color: var(--accent-secondary);
  color: var(--accent);
}

.btn-tab-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ——— Responsive ——— */
@media (max-width: 34rem), ((hover: none) and (pointer: coarse) and (max-width: 900px)) {
  .app-header {
    padding: 0.55rem 0;
  }

  .app-header__bar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 0.5rem;
  }

  .app-header__brand {
    gap: 0.65rem;
  }

  .app-header__logo {
    height: 36px;
    width: 36px;
  }

  .app-header__app-name {
    font-size: 0.85rem;
  }

  .app-header__doc-title {
    font-size: 0.92rem;
  }

  .app-header__actions {
    gap: 0.35rem;
  }

  .app-header__action-btn {
    padding: 0.28rem 0.5rem;
    font-size: 0.72rem;
  }
}

@media (min-width: 960px) {
  .app-header {
    padding: 0.7rem 0;
  }
}

/* ——— Unsaved changes dialog (File menu) ——— */
.unsaved-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.unsaved-dialog[hidden] {
  display: none !important;
}

.unsaved-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.unsaved-dialog__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 26rem);
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}

.unsaved-dialog__title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: var(--blue);
}

.unsaved-dialog__message {
  margin: 0 0 1.1rem;
  color: var(--text);
  line-height: 1.45;
}

.unsaved-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.unsaved-dialog .btn-primary,
.unsaved-dialog .btn-secondary {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.unsaved-dialog .btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
}

.unsaved-dialog .btn-primary:hover {
  filter: brightness(1.08);
}

.unsaved-dialog .btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.unsaved-dialog .btn-secondary:hover {
  border-color: var(--accent-secondary);
  color: var(--accent);
}

/* ——— About dialog (matches everroux-app-shell) ——— */
.everroux-about-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.everroux-about-backdrop[hidden] {
  display: none !important;
}

.everroux-about {
  background: var(--surface);
  border-radius: 12px;
  max-width: 480px;
  width: 90%;
  padding: 1.25rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.everroux-about__banner {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  color: #fff;
  background: var(--blue);
}

.app--dark .everroux-about__banner {
  background: var(--surface);
  border: 1px solid var(--border);
}

.everroux-about__banner h2 {
  margin: 0;
  color: #fff;
  font-size: 1.1rem;
}

.everroux-about__banner p {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  opacity: 0.9;
}

.everroux-about__body {
  font-size: 0.88rem;
  line-height: 1.45;
  margin-bottom: 1rem;
}

.everroux-about__body p {
  margin: 0 0 0.5rem;
}

.everroux-about__close {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.45rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}

.everroux-about__close:hover {
  filter: brightness(1.08);
}

.app--dark .page {
  background: var(--bg);
  color: var(--text);
}

.app--dark body,
body.app--dark {
  background: var(--bg);
  color: var(--text);
}
