/* ============================================================================
   Park Industries® Internal Portal
   Brand palette (PI Brand Style & Visual Guide):
     Midnight Express #04173F (primary)   Scarlet #FF2400 (primary accent)
     Forged Pewter    #A9A392 (secondary) Steel Blue #5494CC (secondary)
   Typography: Industry Black / Franklin Gothic are licensed print fonts.
   Web alternates per the guide: Figtree (Google Fonts) with Arial fallback.
   Headings are always uppercase per the brand voice.
   ========================================================================== */

:root {
    --pi-midnight: #04173F;
    --pi-scarlet: #FF2400;
    --pi-pewter: #A9A392;
    --pi-steel: #5494CC;
    --pi-ink: #1a1a1a;
    --pi-paper: #f4f4f2;
    --pi-white: #ffffff;
    --pi-border: #e2e0db;
    --font-body: "Figtree", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    color: var(--pi-ink);
    background: var(--pi-paper);
    font-size: 15px;
}

h1, h2, h3, h4 {
    font-family: var(--font-body);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--pi-midnight);
}

h1 {
    font-size: 1.7rem;
    border-bottom: 4px solid var(--pi-scarlet);
    display: inline-block;
    padding-bottom: 6px;
}

a { color: var(--pi-steel); }

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --------------------------------- Top bar ------------------------------- */
.topbar {
    background: var(--pi-midnight);
    border-bottom: 4px solid var(--pi-scarlet);
    color: var(--pi-white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
}

.brand { text-decoration: none; display: flex; flex-direction: column; gap: 4px; }

.brand-logo { height: 42px; width: auto; display: block; }

.brand-sub {
    color: var(--pi-pewter);
    font-weight: 700;
    font-size: 0.65rem;
    letter-spacing: 4px;
}

.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-name { color: var(--pi-white); font-weight: 600; }

/* User menu (dropdown under the name in the top bar). */
.user-menu { position: relative; }

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    font-family: var(--font-body);
}

.user-menu-trigger:hover { background: rgba(255, 255, 255, 0.08); }

.user-menu-caret { color: var(--pi-pewter); font-size: 1.2rem; line-height: 1; }

/* Invisible full-screen layer so clicking anywhere closes the menu. */
.user-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 41;
    min-width: 180px;
    background: var(--pi-white);
    border: 1px solid var(--pi-border);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
}

.user-menu-item {
    display: block;
    padding: 11px 16px;
    color: var(--pi-midnight);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.user-menu-item:hover { background: var(--pi-paper); }
.user-menu-item + .user-menu-item { border-top: 1px solid var(--pi-border); }

/* --------------------------------- Layout -------------------------------- */
.body-row { display: flex; flex: 1; }

.sidenav {
    width: 230px;
    background: var(--pi-white);
    border-right: 1px solid var(--pi-border);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: block;
    padding: 11px 24px;
    color: var(--pi-midnight);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 1.5px;
    border-left: 4px solid transparent;
}

.nav-item:hover { background: var(--pi-paper); }

.nav-item.active {
    border-left-color: var(--pi-scarlet);
    background: var(--pi-paper);
}

.nav-section {
    margin: 20px 24px 6px;
    color: var(--pi-pewter);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 3px;
    border-top: 1px solid var(--pi-border);
    padding-top: 14px;
}

/* Customer ("acting as") switcher, shown at the top of the side nav for multi-customer logins. */
.customer-switcher {
    padding: 0 24px 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--pi-border);
}

.customer-switcher-label {
    display: block;
    margin-bottom: 6px;
    color: var(--pi-pewter);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 3px;
}

.customer-switcher-select {
    width: 100%;
    padding: 8px 10px;
    background: var(--pi-white);
    border: 1px solid var(--pi-border);
    color: var(--pi-midnight);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
}

.content { flex: 1; padding: 32px 40px; max-width: 1200px; }

.footer {
    background: var(--pi-midnight);
    color: rgba(255, 255, 255, 0.88);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 22px 32px;
    font-size: 0.95rem;
    letter-spacing: normal;
}

.footer a { color: #8fb3e0; text-decoration: underline; }
.footer a:hover { color: var(--pi-white); }

.footer-badge { display: inline-flex; align-items: center; }
.footer-badge-img { height: 54px; width: auto; display: block; }

/* --------------------------------- Modal --------------------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 23, 63, 0.55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 16px;
    overflow-y: auto;
    z-index: 1000;
}

.modal {
    background: var(--pi-white);
    border: 1px solid var(--pi-border);
    border-top: 6px solid var(--pi-scarlet);
    width: 100%;
    max-width: 480px;
    padding: 24px 28px 28px;
    box-shadow: 0 12px 40px rgba(4, 23, 63, 0.25);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-head h3 { margin: 0; font-size: 1rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--pi-pewter);
    cursor: pointer;
    padding: 0 4px;
}

.modal-close:hover { color: var(--pi-scarlet); }

.modal-sub { color: #555; margin: 4px 0 8px; font-size: 0.9rem; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.perm-view { margin: 0; }

.perm-view-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
}

.perm-view-row + .perm-view-row { border-top: 1px solid var(--pi-border); }
.perm-view-row dt { margin: 0; }
.perm-view-row dd { margin: 0; }

.perm-view-scope { margin: 0; }

/* --------------------------------- Cards --------------------------------- */
.card {
    background: var(--pi-white);
    border: 1px solid var(--pi-border);
    border-top: 4px solid var(--pi-midnight);
    padding: 24px;
    margin-bottom: 24px;
}

.card h3 { margin-top: 0; font-size: 1rem; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.card-link {
    text-decoration: none;
    color: inherit;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.card-link:hover { border-top-color: var(--pi-scarlet); transform: translateY(-2px); }
.card-link p { color: #555; }

.no-access-card { max-width: 560px; margin: 48px auto; text-align: center; border-top-color: var(--pi-scarlet); }

.back-link {
    text-decoration: none;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    color: var(--pi-pewter);
}
.back-link:hover { color: var(--pi-scarlet); }

.detail-card { max-width: 640px; }

.detail-list dt {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: var(--pi-pewter);
    margin-top: 14px;
}

.detail-list dd { margin: 4px 0 0; }

.two-col {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.2fr);
    gap: 24px;
    align-items: start;
}

/* The two min-320px panes plus the 244px sidebar and content padding need
   ~1024px. Below that, stack them so neither pane gets squeezed/overflows. */
@media (max-width: 1024px) {
    .two-col { grid-template-columns: 1fr; }
}

/* ------------------------------ Responsive ------------------------------- */
/* Tablet / small laptop: stack the side nav above the content as a horizontal bar. */
@media (max-width: 900px) {
    .two-col { grid-template-columns: 1fr; }
    .body-row { flex-direction: column; }

    .sidenav {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 6px 12px;
        border-right: none;
        border-bottom: 1px solid var(--pi-border);
    }

    /* Active marker moves from the left edge to the bottom edge in the horizontal bar. */
    .nav-item { border-left: none; border-bottom: 3px solid transparent; padding: 10px 14px; }
    .nav-item.active { border-left-color: transparent; border-bottom-color: var(--pi-scarlet); background: var(--pi-paper); }

    /* Section label and switcher take their own full-width row. */
    .nav-section { width: 100%; margin: 6px 14px 0; padding-top: 8px; }
    .customer-switcher { width: 100%; border-bottom: none; padding: 8px 14px; margin-bottom: 0; }

    .content { padding: 24px 20px; }
}

/* Wide tables scroll horizontally inside their card instead of overflowing the page. */
@media (max-width: 768px) {
    .table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Tables marked .table-cards become a stack of labeled cards instead of scrolling.
       Each row is a card; each cell shows its column header (from data-label) on the left
       and the value on the right. (Higher specificity .table.table-cards beats .table above.) */
    .table.table-cards {
        display: block;
        overflow-x: visible;
        white-space: normal;
    }

    .table-cards thead { display: none; }
    .table-cards tbody { display: block; }

    .table-cards tr {
        display: block;
        background: var(--pi-white);
        border: 1px solid var(--pi-border);
        border-top: 3px solid var(--pi-midnight);
        padding: 4px 14px;
        margin-bottom: 14px;
    }

    .table-cards td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 16px;
        padding: 8px 0;
        border-bottom: 1px solid var(--pi-border);
        text-align: right;
    }

    .table-cards tr td:last-child { border-bottom: none; }

    .table-cards td::before {
        content: attr(data-label);
        flex: none;
        font-weight: 800;
        text-transform: uppercase;
        font-size: 0.65rem;
        letter-spacing: 1.5px;
        color: var(--pi-pewter);
        text-align: left;
    }

    /* Dim the whole card for inactive rows rather than per-cell. */
    .table-cards tr.row-inactive { opacity: 0.5; }
    .table-cards tr.row-inactive td { opacity: 1; }
}

/* Phone: tighten spacing, scale type down, stack the footer and wrap action rows. */
@media (max-width: 600px) {
    html, body { font-size: 14px; }
    .topbar { padding: 12px 16px; }
    .brand-logo { height: 34px; }
    .content { padding: 18px 14px; }
    h1 { font-size: 1.4rem; }
    .footer { flex-direction: column; gap: 6px; text-align: center; padding: 14px 16px; }
    .modal-card { width: 100%; }
    .table-actions { flex-wrap: wrap; }
    .user-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* -------------------------------- Buttons -------------------------------- */
.btn {
    display: inline-block;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 800;
    letter-spacing: 1.5px;
    font-size: 0.8rem;
    padding: 12px 26px;
    text-decoration: none;
    text-transform: uppercase;
}

.btn-primary { background: var(--pi-scarlet); color: var(--pi-white); }
.btn-primary:hover { background: #d61f00; }
.btn-navy { background: var(--pi-midnight); color: var(--pi-white); }
.btn-navy:hover { background: #0a2a66; }
.btn-secondary { background: var(--pi-steel); color: var(--pi-white); }

.btn-outline {
    background: transparent;
    color: inherit;
    border: 2px solid currentColor;
    padding: 6px 14px;
}

.btn-sm { padding: 6px 14px; font-size: 0.7rem; }

/* Destructive actions (e.g. hard delete): scarlet outline, fills on hover. */
.btn-danger {
    background: transparent;
    color: var(--pi-scarlet);
    border: 2px solid var(--pi-scarlet);
    padding: 6px 14px;
}
.btn-danger:hover { background: var(--pi-scarlet); color: var(--pi-white); }

.table-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.hdr-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.detail-subhead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0 0 16px; }
.detail-subhead .lead { margin: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --------------------------------- Forms ---------------------------------- */
.form-label {
    display: block;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: var(--pi-midnight);
    margin: 16px 0 6px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--pi-border);
    font-family: var(--font-body);
    font-size: 0.95rem;
    margin-bottom: 4px;
    background: var(--pi-white);
}

.form-input:focus { outline: 2px solid var(--pi-steel); }
.form-input-inline { width: auto; margin: 0; }
.search-input { margin-bottom: 16px; }

.perm-fieldset {
    border: 1px solid var(--pi-border);
    margin: 16px 0;
    padding: 12px 16px;
}

.perm-fieldset legend {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: var(--pi-midnight);
    padding: 0 6px;
}

.check { display: block; margin: 8px 0; font-weight: 600; }

.validation-message, .error-msg { color: var(--pi-scarlet); font-weight: 600; margin-top: 8px; }
.success-msg { color: #1b7a3d; font-weight: 600; margin-top: 8px; }
.muted { color: #777; font-size: 0.85rem; }
.lead { font-size: 1.05rem; color: #444; }

/* ------------------------------- Pagination ------------------------------- */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.pagination-info { display: flex; align-items: center; gap: 16px; color: #777; font-size: 0.85rem; }
.pagination-size { display: flex; align-items: center; gap: 6px; }
.pagination-size select { margin: 0; padding: 4px 8px; font-size: 0.85rem; }
.pagination-controls { display: flex; align-items: center; gap: 12px; }
.pagination-page { font-size: 0.85rem; font-weight: 600; color: var(--pi-midnight); }
.btn-sm:disabled { opacity: 0.45; cursor: default; }

/* --------------------------------- Tables --------------------------------- */
.table { width: 100%; border-collapse: collapse; margin-top: 8px; }

.table th {
    text-align: left;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 2px;
    color: var(--pi-pewter);
    border-bottom: 2px solid var(--pi-midnight);
    padding: 8px 10px;
}

.table td { padding: 10px; border-bottom: 1px solid var(--pi-border); }
.row-inactive td { opacity: 0.45; }

.status {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 3px 10px;
    color: var(--pi-white);
    background: var(--pi-pewter);
}

.status-submitted { background: var(--pi-pewter); }
.status-inreview { background: var(--pi-steel); }
.status-scheduled { background: var(--pi-midnight); }
.status-completed { background: #1b7a3d; }
.status-cancelled { background: var(--pi-scarlet); }

/* -------------------------------- Sign-in --------------------------------- */
/* The split-screen auth layout (sign-in) lives in design-system.css (.auth-*).
   The shared form, social-button, and divider styles those pages use are kept below. */
.btn-lg { padding: 14px 40px; font-size: 0.9rem; }

/* ---------------------- Embedded credentials + social --------------------- */
.signin-form { text-align: left; margin-top: 4px; }
.signin-form .form-input { margin-bottom: 14px; }

.signin-submit { width: 100%; }

.signin-forgot {
    display: block;
    text-align: center;
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--pi-midnight);
}

.signin-error {
    background: #fdeae6;
    border-left: 4px solid var(--pi-scarlet);
    color: #8a1700;
    text-align: left;
    font-size: 0.85rem;
    padding: 10px 14px;
    margin-bottom: 16px;
}

.signin-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0 16px;
    color: #999;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.signin-divider::before,
.signin-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--pi-border);
}

.signin-social { display: flex; gap: 10px; }

.btn-social {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 8px;
    background: var(--pi-white);
    border: 1px solid var(--pi-border);
    border-radius: 2px;
    color: var(--pi-ink);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.8rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.btn-social:hover {
    border-color: var(--pi-steel);
    box-shadow: 0 2px 8px rgba(4, 23, 63, 0.12);
    transform: translateY(-1px);
}

/* Visible-but-inactive social buttons (provider not yet configured). */
.btn-social-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(100%);
}

.btn-social-disabled:hover {
    border-color: var(--pi-border);
    box-shadow: none;
    transform: none;
}

@media (max-width: 480px) {
    .signin-social { flex-direction: column; }
}

/* --------------------------------- Modal ---------------------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 23, 63, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-card { width: 480px; max-width: 92vw; margin: 0; }
.modal-actions { display: flex; gap: 12px; margin-top: 18px; }

/* ------------------------- Blazor error UI (default) ----------------------- */
#blazor-error-ui {
    background: var(--pi-midnight);
    color: var(--pi-white);
    bottom: 0;
    box-shadow: 0 -1px 4px rgba(0,0,0,0.3);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
