/* ========================================
   App Shell — Modern Application Interface
   v2 — Premium redesign
   Used on: calculators.html, collision.html, ai-check.html, indictment.html, expertise-review.html
   ======================================== */

/* ---- Shell Container ---- */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 72px);
  margin-top: 72px;
  background: #f8f9fb;
}

/* Diagram: fixed height, no scroll */
.app-shell--diagram {
  height: calc(100vh - 72px);
  min-height: auto;
  overflow: hidden;
}

/* ---- Modern Topbar (replaces macOS titlebar) ---- */
.app-shell__titlebar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  height: 44px;
  background: linear-gradient(180deg, #1d1729 0%, #251d3a 100%);
  border-bottom: 1px solid rgba(114, 67, 242, 0.2);
  flex-shrink: 0;
  user-select: none;
}

.app-shell__dots {
  display: flex;
  gap: 7px;
}

.app-shell__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  opacity: 0.85;
}

.app-shell__dot--red { background: #ff5f57; }
.app-shell__dot--yellow { background: #ffbd2e; }
.app-shell__dot--green { background: #28c940; }

.app-shell__window-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.3px;
  flex: 1;
  text-align: center;
  margin-right: 40px;
}

/* ---- Body (sidebar + content) ---- */
.app-shell__body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ---- Sidebar Navigation ---- */
.app-shell__sidebar {
  width: 220px;
  background: linear-gradient(180deg, #1d1729 0%, #231b38 100%);
  border-right: 1px solid rgba(114, 67, 242, 0.1);
  padding: 20px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px - 44px);
  overflow-y: auto;
}

/* Diagram: sidebar not sticky */
.app-shell--diagram .app-shell__sidebar {
  position: static;
  height: auto;
}

/* Sidebar section label */
.app-shell__sidebar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.3);
  padding: 12px 20px 8px;
}

/* Nav items */
.app-shell__nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  margin: 0 10px;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 10px;
  border-left: none;
  transition: all 0.2s ease;
}

.app-shell__nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85);
}

.app-shell__nav-item--active {
  color: #fff;
  background: linear-gradient(135deg, rgba(114, 67, 242, 0.3), rgba(114, 67, 242, 0.15));
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(114, 67, 242, 0.15);
}

.app-shell__nav-item--active svg {
  stroke: #a78bfa;
}

.app-shell__nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.app-shell__nav-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.2;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.app-shell__nav-badge--free {
  background: rgba(5, 150, 105, 0.15);
  color: #6ee7b7;
  border-color: rgba(5, 150, 105, 0.2);
}

/* Sidebar footer */
.app-shell__sidebar-footer {
  margin-top: auto;
  padding: 16px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.app-shell__sidebar-plan {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(114, 67, 242, 0.12), rgba(167, 139, 250, 0.08));
  border: 1px solid rgba(114, 67, 242, 0.15);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  transition: all 0.2s;
}

.app-shell__sidebar-plan:hover {
  background: linear-gradient(135deg, rgba(114, 67, 242, 0.2), rgba(167, 139, 250, 0.15));
  color: rgba(255, 255, 255, 0.85);
}

.app-shell__sidebar-plan svg {
  flex-shrink: 0;
  stroke: #a78bfa;
}

/* ---- Content Area ---- */
.app-shell__content {
  flex: 1;
  min-width: 0;
  background: #f8f9fb;
  overflow-y: auto;
}

/* For diagram */
.app-shell--diagram .app-shell__content {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.app-shell--diagram .diagram-editor {
  flex: 1;
  min-height: 0;
}

/* ---- Content Header ---- */
.app-content-header {
  padding: 32px 40px 24px;
  border-bottom: 1px solid #eef0f3;
  background: #fff;
}

.app-content-header__title {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--color-text-dark, #1d1729);
  margin-bottom: 6px;
  font-family: var(--ff-heading, 'Montserrat', sans-serif);
}

.app-content-header__subtitle {
  font-size: 0.875rem;
  color: var(--color-text-muted, #9ca3af);
  line-height: 1.5;
}

/* ---- Content Body ---- */
.app-content-body {
  padding: 0;
}

/* Remove extra padding from sections when inside app shell */
.app-shell .section {
  padding: var(--space-2xl, 32px) 0;
}

.app-shell .section--white {
  background: transparent;
}

.app-shell .section--glass-bg {
  background: #fff;
}

/* Trust bar adjustments */
.app-shell .trust-bar {
  padding: 0 0 var(--space-lg) 0;
}

/* ---- PRO Banner inside app ---- */
.app-shell .pro-simple-banner {
  background: linear-gradient(135deg, #1d1729, #2d1f4e);
  border-color: rgba(155, 109, 255, 0.3);
}
.app-shell .pro-simple-banner__title {
  color: #f0ecf9;
}
.app-shell .pro-simple-banner__text {
  color: #b8aed0;
}

/* ---- Responsive: Tablet ---- */
@media (max-width: 991px) {
  .app-shell {
    margin-top: 62px;
  }

  .app-shell__body {
    flex-direction: column;
  }

  .app-shell__sidebar {
    width: 100%;
    flex-direction: row;
    padding: 0;
    border-right: none;
    border-bottom: 1px solid rgba(114, 67, 242, 0.1);
    overflow-x: auto;
    gap: 0;
    position: static;
    height: auto;
    background: #1d1729;
  }

  .app-shell__sidebar-label {
    display: none;
  }

  .app-shell__nav-item {
    border-radius: 0;
    white-space: nowrap;
    padding: 14px 18px;
    margin: 0;
    font-size: 13px;
    border-bottom: 2px solid transparent;
  }

  .app-shell__nav-item--active {
    background: transparent;
    border-bottom-color: var(--color-accent-purple, #7243f2);
    box-shadow: none;
  }

  .app-shell__sidebar-footer {
    display: none;
  }

  .app-shell__titlebar {
    height: 38px;
    padding: 0 16px;
  }

  .app-content-header {
    padding: 24px 20px 18px;
  }

  /* Diagram: auto height on tablet/mobile (show notice instead of editor) */
  .app-shell--diagram {
    height: auto;
    min-height: calc(100vh - 62px);
    overflow: visible;
  }
}

/* ---- Responsive: Mobile ---- */
@media (max-width: 576px) {
  .app-shell__titlebar {
    height: 34px;
    padding: 0 12px;
  }

  .app-shell__window-title {
    font-size: 11px;
    margin-right: 32px;
  }

  .app-shell__dot {
    width: 8px;
    height: 8px;
  }

  .app-content-header {
    padding: 18px 16px 14px;
  }

  .app-content-header__title {
    font-size: 1.25rem;
  }

  .app-shell__nav-item {
    padding: 10px 12px;
    font-size: 12px;
    gap: 6px;
  }

  .app-shell__nav-icon {
    width: 16px;
    height: 16px;
  }

  .app-shell__nav-badge {
    display: none;
  }
}

/* ============================================
   Split Calculator Card Layout
   ============================================ */

/* ---- Split Container ---- */
.calc-panel__split {
  display: flex;
  min-height: 280px;
}

.calc-panel__main {
  flex: 3;
  padding: 28px 32px;
  min-width: 0;
}

/* Input grid inside main */
.calc-panel__main .calc-input-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 24px;
}

/* ---- Notes Panel (right side) ---- */
.calc-panel__notes {
  flex: 2;
  padding: 0;
  background: #fafbfc;
  border-left: 1px solid #eef0f3;
  display: flex;
  flex-direction: column;
  min-width: 260px;
  max-width: 380px;
}

.calc-notes__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid #eef0f3;
  font-size: 12px;
  font-weight: 700;
  color: #1d1729;
  letter-spacing: 0.3px;
  flex-shrink: 0;
  background: rgba(114, 67, 242, 0.03);
}

.calc-notes__header svg {
  opacity: 0.5;
  flex-shrink: 0;
}

.calc-notes__count {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  background: rgba(114, 67, 242, 0.1);
  color: #7243f2;
  padding: 1px 7px;
  border-radius: 10px;
  line-height: 1.4;
}

.calc-notes__list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calc-notes__list::-webkit-scrollbar {
  width: 3px;
}

.calc-notes__list::-webkit-scrollbar-thumb {
  background: rgba(114, 67, 242, 0.15);
  border-radius: 3px;
}

.calc-notes__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px 16px;
  color: #d1d5db;
  font-size: 11px;
  flex: 1;
}

/* ---- Note Item ---- */
.calc-note {
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid #eef0f3;
  transition: all 0.15s;
  cursor: pointer;
}

.calc-note:hover {
  border-color: rgba(114, 67, 242, 0.2);
  box-shadow: 0 2px 8px rgba(114, 67, 242, 0.06);
}

.calc-note__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.calc-note__name {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  color: #1d1729;
  padding: 0;
  outline: none;
}

.calc-note__name::placeholder {
  color: #d1d5db;
  font-weight: 400;
  font-style: italic;
}

.calc-note__name:focus {
  color: #7243f2;
}

.calc-note__value {
  font-size: 13px;
  font-weight: 700;
  color: #7243f2;
  white-space: nowrap;
  flex-shrink: 0;
}

.calc-note__date {
  font-size: 8px;
  color: #9ca3af;
  margin-top: 2px;
}

.calc-note__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
  justify-content: flex-end;
}

.calc-note__btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  color: #9ca3af;
  font-size: 12px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 3px;
}

.calc-note__btn:hover {
  background: rgba(114, 67, 242, 0.08);
  color: #7243f2;
}

.calc-note__btn--del:hover {
  background: rgba(248, 113, 113, 0.1);
  color: #ef4444;
}

.calc-note__btn--load {
  font-weight: 600;
  color: #7243f2;
}

.calc-note__btn--load:hover {
  background: rgba(114, 67, 242, 0.12);
}

/* ---- Results Header with PDF ---- */
.calc-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 6px;
  margin-top: 8px;
  border-top: 1px solid #eef0f3;
}

.calc-results-header__label {
  font-size: 10px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* PDF button — small inline version */
.calc-pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  background: rgba(114, 67, 242, 0.08);
  color: #7243f2;
}

.calc-pdf-btn:hover {
  background: rgba(114, 67, 242, 0.15);
}

.calc-pdf-btn__pro {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.calc-pdf-btn svg {
  flex-shrink: 0;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .calc-panel__split {
    flex-direction: column;
  }

  .calc-panel__notes {
    max-width: none;
    border-left: none;
    border-top: 1px solid #eef0f3;
    max-height: 240px;
  }

  .calc-panel__main .calc-input-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 576px) {
  .calc-panel__main {
    padding: 20px 16px;
  }

  .calc-panel__main .calc-input-row {
    grid-template-columns: 1fr;
  }

  .calc-panel__notes {
    max-height: 200px;
  }
}

/* Hide header backgrounds on app pages */
[data-page="calculators"] .page-hero,
[data-page="calculators"] .page-hero--modern {
  display: none;
}

/* ─── App-shell pages: always-solid header ────────────────────────
   On pages that use the macOS-style .app-shell__titlebar we need the
   site-header to be solid white at all scroll positions, otherwise
   the transparent header at scrollTop=0 visually clashes with the
   dark titlebar below it (especially on narrow / half-screen widths,
   where the logo looks like it's getting clipped). */
body[data-page="calculators"] .site-header,
body[data-page="collision"]   .site-header,
body[data-page="indictment"]  .site-header,
body[data-page="ai-check"]    .site-header,
body[data-page="expertise-review"] .site-header,
body[data-page="diagram"]     .site-header {
  background: #ffffff;
  box-shadow: 0 1px 16px rgba(0, 0, 0, 0.06);
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}
/* Tighten the gap between header and app-shell on smaller viewports
   so the macOS titlebar feels visually anchored to the header instead
   of "swallowing" the bottom of the logo. */
@media (max-width: 900px) {
  body[data-page="calculators"] .app-shell,
  body[data-page="collision"]   .app-shell,
  body[data-page="indictment"]  .app-shell,
  body[data-page="ai-check"]    .app-shell,
  body[data-page="expertise-review"] .app-shell,
  body[data-page="diagram"]     .app-shell {
    margin-top: 64px;
    min-height: calc(100vh - 64px);
  }
}
