/* ============================================================================
   Amfit Provider Portal — Shared CSS
   ============================================================================
   Loaded by every portal page (login, dashboard, orders, etc.) on top of
   /css/style.css (the marketing-site base). This file owns:

     1. Portal-wide body adjustments (background, type scale)
     2. Sticky portal header pattern
     3. Auth shell layout (login / reset-password)
     4. Common portal page chrome (intro, breadcrumbs, sign-out)

   Page-specific styles (the order form, the dashboard grid, etc.) still
   live inline on those pages.
   ============================================================================ */


/* ---------- 1. Portal-wide body adjustments ---------- */

body.portal-body {
  background: #FAF6EB;
  font-size: 15px;
  line-height: 1.5;
}
/* Kill the marketing paper-grain overlay on portal pages */
body.portal-body::after { display: none; }


/* ---------- 2. Sticky portal header ---------- */

.portal-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 246, 235, 0.92);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.portal-header__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.portal-header__logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.portal-header__logo img { height: 26px; width: auto; display: block; }

.portal-header__crumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 0.75rem;
  padding-left: 1.25rem;
  border-left: 1px solid var(--border);
}
.portal-header__crumbs a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}
.portal-header__crumbs a:hover { color: var(--red); }
.portal-header__crumbs .sep { color: var(--text-muted); }
.portal-header__crumbs .current { color: var(--text-primary); font-weight: 500; }

.portal-header__spacer { flex: 1; }

.portal-header__user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.85rem 0.4rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.portal-header__user:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.portal-header__avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.portal-header__user-name { font-weight: 500; color: var(--text-primary); }
.portal-header__user-id {
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.portal-header__caret {
  margin-left: 0.35rem;
  font-size: 9px;
  color: var(--text-muted);
}

/* User dropdown menu */
.portal-header__menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}
.portal-header__menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.portal-header__menu-item {
  display: block;
  width: 100%;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease;
}
.portal-header__menu-item:hover { background: rgba(166, 25, 46, 0.06); color: var(--red); }
.portal-header__menu-divider {
  height: 1px;
  background: var(--border);
  margin: 0.4rem 0.5rem;
}

/* Mobile header */
@media (max-width: 640px) {
  .portal-header__crumbs { display: none; }
  .portal-header__user-id { display: none; }
  .portal-header__inner { padding: 0.7rem 1rem; }
}


/* ---------- 3. Auth shell (login + reset-password) ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background:
    radial-gradient(circle at 20% 0%, rgba(166, 25, 46, 0.04), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(180, 145, 109, 0.06), transparent 50%),
    #FAF6EB;
}
.auth-shell__logo {
  margin-bottom: 2rem;
}
.auth-shell__logo img { height: 36px; width: auto; display: block; }

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.25rem 2rem;
  box-shadow:
    0 1px 2px rgba(24, 21, 18, 0.04),
    0 8px 24px rgba(24, 21, 18, 0.06);
}
.auth-card__title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
  color: var(--text-primary);
}
.auth-card__subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.auth-field {
  margin-bottom: 1.1rem;
}
.auth-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.auth-field input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-field input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(166, 25, 46, 0.1);
}
.auth-field input:disabled {
  background: rgba(24, 21, 18, 0.03);
  cursor: not-allowed;
}

.auth-submit {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background 0.15s ease, transform 0.05s ease;
}
.auth-submit:hover:not(:disabled) { background: var(--red-hover); }
.auth-submit:active:not(:disabled) { transform: translateY(1px); }
.auth-submit:disabled {
  background: rgba(24, 21, 18, 0.25);
  cursor: not-allowed;
}

.auth-meta {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}
.auth-meta a {
  color: var(--red);
  text-decoration: none;
  font-weight: 500;
}
.auth-meta a:hover { text-decoration: underline; }

.auth-footnote {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.6;
}
.auth-footnote a { color: var(--text-secondary); text-decoration: underline; }

/* Status messages on auth cards */
.auth-message {
  margin-top: 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  display: none;
}
.auth-message.is-shown { display: block; }
.auth-message.is-error {
  background: rgba(166, 25, 46, 0.08);
  border: 1px solid rgba(166, 25, 46, 0.2);
  color: #74101f;
}
.auth-message.is-success {
  background: rgba(60, 130, 80, 0.08);
  border: 1px solid rgba(60, 130, 80, 0.25);
  color: #2e5b3c;
}
.auth-message.is-info {
  background: rgba(24, 21, 18, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}


/* ---------- 4. App layout: header + persistent left sidebar + content ---------- */

.portal-app {
  display: grid;
  grid-template-columns: 240px 1fr;
  align-items: start;
  min-height: calc(100vh - 60px);  /* below the sticky header */
}
@media (max-width: 1100px) {
  .portal-app { grid-template-columns: 1fr; }
}

.portal-sidebar {
  position: sticky;
  top: 60px;                       /* sit just under the sticky header */
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 1.25rem 0.75rem 2rem;
  background: rgba(255, 255, 255, 0.4);
  border-right: 1px solid var(--border);
}
.portal-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.portal-sidebar__item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.2;
  transition: background 0.12s ease, color 0.12s ease;
  font-family: inherit;
}
.portal-sidebar__item:hover {
  background: rgba(166, 25, 46, 0.05);
  color: var(--red);
}
.portal-sidebar__item.is-active {
  background: rgba(166, 25, 46, 0.08);
  color: var(--red);
  font-weight: 500;
}
.portal-sidebar__item svg { width: 16px; height: 16px; flex-shrink: 0; }
.portal-sidebar__external {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}
.portal-sidebar__divider {
  height: 1px;
  background: var(--border);
  margin: 0.85rem 0.5rem;
}
.portal-sidebar__section {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 1rem 0.85rem 0.4rem;
}

/* Mobile drawer */
@media (max-width: 1100px) {
  .portal-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 200;
    background: #FAF6EB;
    border-right: 1px solid var(--border);
    box-shadow: 6px 0 20px rgba(24, 21, 18, 0.08);
    padding-top: 4.5rem;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  .portal-sidebar.is-open { transform: translateX(0); }
  .portal-sidebar__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(24, 21, 18, 0.35);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
  }
  .portal-sidebar__backdrop.is-open {
    opacity: 1;
    visibility: visible;
  }
}

/* Hamburger button in header */
.portal-header__menuBtn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-right: 0.25rem;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background 0.15s ease;
}
.portal-header__menuBtn:hover { background: rgba(255, 255, 255, 0.9); }
@media (max-width: 1100px) {
  .portal-header__menuBtn { display: inline-flex; }
}

/* The main content column inside the app layout — fills the right column of
   the .portal-app grid so wide monitors don't get a fat strip of dead space
   next to the sidebar. Page-level content (dashboard hero, panels, order
   form) handles its own max-width if/when it needs one. */
.portal-main {
  width: 100%;
  padding: 2.5rem 2.25rem 6rem;
}
@media (max-width: 720px) {
  .portal-main { padding: 1.75rem 1.25rem 4rem; }
}
.portal-intro {
  margin-bottom: 2.25rem;
}
.portal-intro h1 {
  font-size: clamp(1.85rem, 1.5rem + 1.2vw, 2.5rem);
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
}
.portal-intro p {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 56ch;
}

/* Prevent flash-of-unauth content while requireAuth() resolves */
body.portal-body[data-auth="checking"] .portal-gated { visibility: hidden; }
body.portal-body[data-auth="ready"]    .portal-gated { visibility: visible; }
