/**
 * 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: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

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

.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: 0.95rem;
  font-weight: 700;
  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: 650;
  letter-spacing: 0.01em;
  color: #fff;
  line-height: 1.2;
}

input.app-header__doc-title {
  display: block;
  width: 100%;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  padding: 0.2rem 0.45rem;
  cursor: text;
  box-sizing: border-box;
}

input.app-header__doc-title::placeholder {
  color: rgb(255 255 255 / 0.55);
}

input.app-header__doc-title:hover {
  border-color: rgb(255 255 255 / 0.28);
  background: rgb(255 255 255 / 0.08);
}

input.app-header__doc-title:focus {
  outline: none;
  border-color: var(--copper);
  background: rgb(255 255 255 / 0.12);
  text-overflow: clip;
}

.app-header__spacer {
  justify-self: end;
  width: 1px;
  height: 1px;
}

/* ——— 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;
}

.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: 1.25rem;
  padding-top: 1rem;
  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__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;
  }
}

@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);
}
