/* Portal CSS — Clean, professional client-facing design */

/* =============================================================================
   THEME VARIABLES
   ============================================================================= */

:root[data-bs-theme="light"] {
    --portal-bg: #f8f9fa;
    --portal-card-bg: #ffffff;
    --portal-nav-bg: #212529;
    --portal-footer-border: #dee2e6;
    --portal-card-border: #dee2e6;
    --portal-card-shadow: rgba(0, 0, 0, 0.075);
    --portal-card-hover-shadow: rgba(0, 0, 0, 0.1);
    --portal-backup-code-bg: #ffffff;
    --portal-backup-code-border: #dee2e6;
    --portal-text-muted: #6c757d;
}

:root[data-bs-theme="dark"] {
    --portal-bg: #1a1d21;
    --portal-card-bg: #212529;
    --portal-nav-bg: #11141a;
    --portal-footer-border: #373b3e;
    --portal-card-border: #373b3e;
    --portal-card-shadow: rgba(0, 0, 0, 0.25);
    --portal-card-hover-shadow: rgba(0, 0, 0, 0.4);
    --portal-backup-code-bg: #2b3035;
    --portal-backup-code-border: #495057;
    --portal-text-muted: #9ca3af;
}

/* =============================================================================
   BASE LAYOUT
   ============================================================================= */

.portal-body {
    background-color: var(--portal-bg);
    min-height: 100vh;
}

.portal-nav {
    background-color: var(--portal-nav-bg) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.portal-footer {
    border-top: 1px solid var(--portal-footer-border);
}

/* =============================================================================
   CARDS
   ============================================================================= */

.card {
    border: none;
    border-radius: 0.5rem;
    background-color: var(--portal-card-bg);
}

.card.shadow-sm {
    box-shadow: 0 0.125rem 0.5rem var(--portal-card-shadow) !important;
}

/* Module cards on dashboard */
.card.h-100 {
    transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.card.h-100:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem var(--portal-card-hover-shadow) !important;
}

/* Dark mode card border for definition */
[data-bs-theme="dark"] .card {
    border: 1px solid var(--portal-card-border);
}

/* =============================================================================
   FORM ELEMENTS & COMPONENTS
   ============================================================================= */

/* MFA code input */
input[autocomplete="one-time-code"] {
    letter-spacing: 0.5em;
    font-family: monospace;
}

/* Backup codes grid */
.backup-code {
    font-family: monospace;
    font-size: 1.1rem;
    padding: 0.25rem 0.5rem;
    background: var(--portal-backup-code-bg);
    border: 1px solid var(--portal-backup-code-border);
    border-radius: 0.25rem;
}

/* =============================================================================
   THEME TOGGLE
   ============================================================================= */

.portal-theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 1rem;
}

.portal-theme-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.portal-theme-switch input {
    display: none;
}

.portal-theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border-radius: 24px;
    transition: background-color 0.3s;
}

.portal-theme-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
}

.portal-theme-switch input:checked + .portal-theme-slider {
    background-color: #6366f1;
}

.portal-theme-switch input:checked + .portal-theme-slider::before {
    transform: translateX(20px);
}

.portal-theme-icon {
    font-size: 0.85rem;
    width: 1rem;
    text-align: center;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

/* Bootstrap sets `white-space: nowrap` on .navbar-brand, so a long
   operator-set org name could not wrap and widened the initial containing block
   past the viewport — mobile Chrome then scales the WHOLE portal down to fit
   (measured: a 420px brand forced a 432px ICB on a 375px phone, i.e. every page
   rendered at 87%). See CLAUDE.md "mobile page renders zoomed out".
   Not inside a media query: the org name is operator-set and arbitrary, so
   refusing to wrap is wrong at every width. `overflow-wrap: anywhere` (unlike
   `break-word`) also counts toward min-content sizing, so the flex item can
   shrink and a single unbroken word can never re-widen the page. */
.portal-nav .navbar-brand {
    white-space: normal;
    overflow-wrap: anywhere;
}

/* One card width for the portal's short forms (was inline on each template). */
.portal-form-card {
    max-width: 640px;
}

@media (max-width: 768px) {
    .portal-nav .navbar-brand {
        font-size: 1rem;
    }

    h2 {
        font-size: 1.5rem;
    }
}

/* Top nav overflow fix (2026-07-20): with many modules enabled the menu was
   cramming next to the logo/org name and wrapping links to two lines
   ("Remote Access"). On desktop, drop the whole menu to its own full-width
   second line and keep each link on one line. Mobile (<992px) is unchanged —
   it uses the collapse/hamburger. */
@media (min-width: 992px) {
    .portal-nav .container {
        flex-wrap: wrap;
    }
    .portal-nav .navbar-collapse {
        order: 3;
        flex-basis: 100%;
        width: 100%;
    }
    .portal-nav .navbar-nav .nav-link {
        white-space: nowrap;
    }
}

/* Shared public questionnaire layout; existing selectors preserved. */

      .public-form-body { color-scheme: light; }
      .public-form-body { background: #eef2f7; color: #1f2937; }
      body.public-form-body { min-height: 100vh; margin: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
      .public-form-nav {
        background: linear-gradient(135deg, #2b6cb0 0%, #2c5282 100%);
        color: #ffffff;
        padding: 12px 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
      }
      .public-form-nav .fw-semibold { color: #ffffff; }
      .form-section-card {
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        margin-top: 20px;
      }
      .form-section-card .card-header {
        background: #f8fafc;
        border-bottom: 1px solid #e5e7eb;
        font-weight: 600;
        color: #111827;
      }
      .btn-primary { background: #2b6cb0; border-color: #2b6cb0; }
      .btn-primary:hover, .btn-primary:focus { background: #2c5282; border-color: #2c5282; }
      .public-form-footer { color: #6b7280; font-size: 12px; }
      .sticky-submit {
        position: sticky; bottom: 0;
        background: rgba(238, 242, 247, 0.95);
        border-top: 1px solid #e5e7eb;
        padding: 12px 0;
        margin-top: 20px;
      }
      /* Honeypot — visually removed but present for bots */
      .contact-preference-field {
        position: absolute; left: -9999px; top: -9999px;
        height: 1px; width: 1px; overflow: hidden;
      }


/* Shared customer surfaces. Forms keep their existing field/section DOM. */
.portal-reading-width { max-width: 900px; }
.portal-identity { overflow-wrap: anywhere; max-width: 24rem; }
.navbar-brand { white-space: normal; overflow-wrap: anywhere; }
.navbar-nav, .navbar-collapse { min-width: 0; }
.portal-skip-link:focus { display: block; padding: .75rem; background: var(--bs-body-bg); }
.secure-card {
    background: var(--portal-card-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--portal-card-border);
    border-radius: .5rem;
    box-shadow: 0 .125rem .5rem var(--portal-card-shadow);
    padding: clamp(1rem, 3vw, 1.75rem);
    margin-top: 1.25rem;
    overflow-wrap: anywhere;
}
.secure-card .list-group-item { color: var(--bs-body-color); background: var(--portal-card-bg); }
.secure-card .message-body { line-height: 1.6; }
.secure-card img { max-width: 100%; height: auto; }
.expiry-warning, .revoked-warning { padding: 1rem; border-left: 4px solid; border-radius: .25rem; margin-bottom: 1rem; }
.expiry-warning { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); border-color: var(--bs-warning); }
.revoked-warning { background: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); border-color: var(--bs-danger); }
.portal-actions .list-group-item { display: flex; align-items: center; gap: .75rem; min-height: 48px; }
@media (max-width: 575.98px) {
    .portal-nav .navbar-brand { max-width: calc(100% - 5rem); margin-right: .5rem; min-width: 0; }
    .portal-nav .navbar-toggler { flex-shrink: 0; }
    .portal-nav .nav-link, .portal-nav .btn { min-height: 44px; display: flex; align-items: center; }
    .secure-card { padding: 1rem; }
}

/* Long account names must not push the full module menu off-screen. */
.portal-account-label { max-width: 14rem; }
