/* ================================================================
   CARGOTRIX — SHIPPING LOGIN
   Shared by the customer portal (/login) and the operations console
   (/admin/login). Both opt in through @section('shippingLogin').

   Layout model
   ------------
   body.ct-shipping-login  vertical flex frame, top bar + card centred
   .ct-auth-shell         two column grid: story panel | form panel
   .ct-auth-story         brand (top) · media band (fills the rest)
   .ct-auth-form-panel    heading · fields · actions · demo · footer

   The grid collapses to a single column below 900px, where the story
   panel stacks above the form.

   Sections
   --------
   1. Tokens and page frame
   2. Top bar (language + theme toggle)
   3. Shell grid
   4. Story panel (brand)
   5. Story media (video / still band)
   6. Form panel (heading, fields, actions)
   7. Demo accounts disclosure
   8. Footer
   9. Responsive refinements
   ================================================================ */


/* ================================================================
   1. TOKENS AND PAGE FRAME
   ================================================================ */

html:has(body.ct-shipping-login),
body.ct-shipping-login {
    height: auto !important;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

body.ct-shipping-login {
    /* Colour tokens */
    --ct-ink: #14243a;
    --ct-muted: #5a6b80;
    --ct-canvas: #eef3f9;
    --ct-surface: #ffffff;
    --ct-soft: #e7eff9;
    --ct-border: #d4dde9;
    --ct-accent: #2563eb;
    --ct-accent-hover: #1d4ed8;
    --ct-link: #1d54c3;
    --ct-danger: #d33a4e;
    --ct-on-accent: #ffffff;

    /* Metrics tokens — every panel uses the same gutter so the card,
       the top bar controls and the form columns line up exactly. */
    --ct-shell: 1080px;
    --ct-align: 36px;
    --ct-pad-y: 36px;
    --ct-radius: 16px;
    --ct-radius-sm: 12px;

    background: var(--ct-canvas);
    color: var(--ct-ink);
    margin: 0;
    padding: 16px 20px 28px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    /* `safe` keeps the top reachable when the card is taller than the
       viewport; browsers without it fall back to flex-start. */
    justify-content: safe center !important;
    box-sizing: border-box;
}

[data-theme="dark"] body.ct-shipping-login {
    --ct-ink: #e9f0f9;
    --ct-muted: #a7b8ce;
    --ct-canvas: #0d1725;
    --ct-surface: #142132;
    --ct-soft: #17283c;
    --ct-border: #3b4d65;
    --ct-accent: #2563eb;
    --ct-accent-hover: #1d4ed8;
    --ct-link: #9ac4ff;
    --ct-danger: #ff9aa8;
    --ct-on-accent: #ffffff;
}


/* ================================================================
   2. TOP BAR (LANGUAGE + THEME TOGGLE)
   ================================================================ */

.ct-shipping-login .auth-topbar {
    position: relative !important;
    inset: auto !important;
    width: 100%;
    max-width: var(--ct-shell);
    height: 48px;
    min-height: 48px;
    margin: 0 auto 14px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    border: none !important;
    z-index: 10;
}

/* The language selector is pinned to the leading edge, the theme toggle
   to the trailing edge; both line up with the card gutters below. */
.ct-shipping-login .auth-topbar > .language-selector-dropdown {
    position: absolute;
    left: var(--ct-align);
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
}

.ct-shipping-login .auth-topbar .language-selector-dropdown .dropdown-toggle {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--ct-ink);
    font-size: 14px;
    font-weight: 600;
    transition: background .15s ease, color .15s ease;
}

.ct-shipping-login .auth-topbar .language-selector-dropdown .dropdown-toggle:hover,
.ct-shipping-login .auth-topbar .language-selector-dropdown .dropdown-toggle:focus {
    background: var(--ct-surface);
    color: var(--ct-accent);
    text-decoration: none;
}

.ct-shipping-login .auth-topbar .language-selector-dropdown .dropdown-menu {
    left: 0;
    right: auto;
}

.ct-shipping-login .auth-theme-toggle {
    position: absolute;
    right: var(--ct-align);
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    min-height: 40px;
    border-radius: 10px;
    background: var(--ct-surface);
    border: 1px solid var(--ct-border);
    color: var(--ct-ink);
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.ct-shipping-login .auth-theme-toggle:hover,
.ct-shipping-login .auth-theme-toggle:focus-visible {
    background: var(--ct-soft);
    border-color: var(--ct-accent);
    color: var(--ct-accent);
    transform: translateY(-50%) rotate(15deg);
}


/* ================================================================
   3. SHELL GRID
   ================================================================ */

.ct-auth-shell {
    width: 100%;
    max-width: var(--ct-shell);
    margin: 0 auto;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.06fr);
    border: 1px solid var(--ct-border);
    border-radius: var(--ct-radius);
    overflow: hidden;
    background: var(--ct-surface);
    box-shadow: 0 20px 50px -30px rgba(15, 23, 42, .45);
}


/* ================================================================
   4. STORY PANEL (MEDIA ONLY)
   ================================================================ */

.ct-auth-story {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--ct-soft);
    border-inline-end: 1px solid var(--ct-border);
}


/* ================================================================
   5. STORY MEDIA (FULL-BLEED BAND)
   ================================================================ */

/* The band bleeds to every panel edge and fills the whole column, so the
   story panel is nothing but the moving image; the shell radius trims the
   outer corners. */
.ct-auth-story-media {
    flex: 1 1 auto;
    position: relative;
    min-height: 220px;
    overflow: hidden;
    background: var(--ct-canvas);
}

.ct-auth-video {
    position: absolute;
    inset: 0;
}

.ct-auth-video video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    background: var(--ct-canvas);
}

.ct-auth-still {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.ct-auth-still img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* `hidden` must beat the display rules above. */
.ct-auth-video [hidden] { display: none !important; }

.ct-video-fallback {
    position: absolute;
    inset: 0;
}

.ct-video-fallback img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}


/* ================================================================
   6. FORM PANEL
   ================================================================ */

.ct-auth-form-panel {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    padding: var(--ct-pad-y) var(--ct-align);
}

.ct-shipping-login .login-card {
    width: 100%;
    background: transparent;
    color: var(--ct-ink);
    border: 0;
    border-radius: 0;
    box-shadow: none !important;
}

.ct-shipping-login .login-card .card-body {
    padding: 0;
}

/* --- heading --- */

.ct-login-heading {
    margin-bottom: 22px;
}

.ct-login-heading h1 {
    font-size: clamp(22px, 2.1vw, 27px);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.6px;
    color: var(--ct-ink);
    margin: 0 0 6px;
}

.ct-login-heading p {
    color: var(--ct-muted);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

/* --- fields --- */

.ct-field {
    margin-bottom: 16px;
}

.ct-field > label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ct-ink);
    margin-bottom: 6px;
}

/* Shared wrapper for the leading icon and the password reveal button. */
.ct-input {
    position: relative;
    display: block;
}

.ct-input-icon {
    position: absolute;
    inset-inline-start: 14px;
    inset-block-start: 50%;
    transform: translateY(-50%);
    color: var(--ct-muted);
    font-size: 15px;
    line-height: 1;
    pointer-events: none;
    z-index: 2;
}

.ct-shipping-login .login-card .form-control {
    height: 46px;
    padding: 8px 14px;
    color: var(--ct-ink);
    background: var(--ct-surface);
    border: 1px solid var(--ct-border);
    border-radius: var(--ct-radius-sm);
    font-size: 15px !important;
}

.ct-shipping-login .login-card .form-control::placeholder {
    color: var(--ct-muted);
}

.ct-shipping-login .login-card .form-control:focus {
    border-color: var(--ct-accent) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ct-accent) 20%, transparent) !important;
}

.ct-shipping-login .login-card .form-control.is-invalid {
    border-color: var(--ct-danger);
    background-image: none;
}

/* Room for the leading icon and, on the password field, the reveal button. */
.ct-shipping-login .login-card .ct-input .form-control {
    padding-inline-start: 42px;
    padding-inline-end: 14px;
}

.ct-shipping-login .login-card .ct-password .form-control {
    padding-inline-end: 46px;
}

.ct-shipping-login .login-card .password-toggle {
    position: absolute;
    left: auto;
    right: auto;
    inset-inline-end: 4px;
    inset-block-start: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ct-muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    z-index: 3;
}

.ct-shipping-login .login-card .password-toggle:hover,
.ct-shipping-login .login-card .password-toggle:focus-visible {
    color: var(--ct-accent);
}

.ct-field-error {
    color: var(--ct-danger);
    font-size: 12.5px;
    margin-top: 5px;
}

/* --- options row --- */

.ct-login-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin: 0 0 20px;
    font-size: 13px;
    min-height: 32px;
}

.ct-remember {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--ct-muted);
    cursor: pointer;
    user-select: none;
}

.ct-remember input {
    width: 17px;
    height: 17px;
    accent-color: var(--ct-accent);
    cursor: pointer;
}

/* --- links (the global theme forces `a { color: ... !important }`) --- */

.ct-shipping-login a {
    color: var(--ct-link) !important;
    text-decoration: none;
}

.ct-shipping-login a:hover,
.ct-shipping-login a:focus-visible {
    color: var(--ct-accent) !important;
    text-decoration: underline;
}

/* --- primary action --- */

.ct-shipping-login .login-card .btn-primary {
    background: var(--ct-accent) !important;
    border-color: var(--ct-accent) !important;
    color: var(--ct-on-accent) !important;
    min-height: 46px;
    font-size: 15px !important;
    font-weight: 600;
    border-radius: var(--ct-radius-sm);
    box-shadow: 0 12px 24px -16px color-mix(in srgb, var(--ct-accent) 95%, transparent);
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.ct-shipping-login .login-card .btn-primary:hover,
.ct-shipping-login .login-card .btn-primary:focus {
    background: var(--ct-accent-hover) !important;
    border-color: var(--ct-accent-hover) !important;
    color: var(--ct-on-accent) !important;
    transform: translateY(-1px);
}

.ct-shipping-login .login-card .btn-primary:active {
    transform: translateY(0);
}

/* --- social login --- */

.ct-shipping-login .social-login-divider {
    color: var(--ct-muted);
}

.ct-shipping-login .social-login-divider::before,
.ct-shipping-login .social-login-divider::after {
    background: var(--ct-border);
}

.ct-shipping-login .social-btn {
    border-color: var(--ct-border) !important;
    color: var(--ct-ink) !important;
    font-weight: 600;
}

.ct-shipping-login .social-btn:hover {
    border-color: var(--ct-accent) !important;
    color: var(--ct-accent) !important;
    transform: translateY(-1px);
}

/* --- flash alerts --- */

.ct-shipping-login .alert {
    border-radius: var(--ct-radius-sm);
    font-size: 13.5px;
}

/* --- account links --- */

.ct-account-link {
    margin: 18px 0 0;
    text-align: center;
    color: var(--ct-muted);
    font-size: 13.5px;
}

.ct-account-link a {
    font-weight: 600;
}

.ct-staff-link {
    text-align: center;
    font-size: 13px;
    color: var(--ct-muted);
    margin: 6px 0 0;
}


/* ================================================================
   7. DEMO ACCOUNTS DISCLOSURE
   ================================================================ */

.ct-demo {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--ct-border);
}

.ct-demo > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    list-style: none;
    cursor: pointer;
    user-select: none;
    color: var(--ct-ink);
    font-size: 13.5px;
    font-weight: 700;
    border-radius: 6px;
}

.ct-demo > summary::-webkit-details-marker {
    display: none;
}

.ct-demo > summary:hover {
    color: var(--ct-accent);
}

.ct-demo > summary:focus-visible {
    outline: 2px solid var(--ct-accent);
    outline-offset: 3px;
}

.ct-demo > summary .ct-demo-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ct-demo > summary .bi-chevron-down {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--ct-muted);
    transition: transform .2s ease;
}

.ct-demo[open] > summary .bi-chevron-down {
    transform: rotate(180deg);
}

.ct-demo-note {
    font-size: 12px;
    line-height: 1.45;
    color: var(--ct-muted);
    margin: 6px 0 12px;
}

.ct-demo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.ct-demo-button {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    min-height: 52px;
    text-align: start;
    padding: 8px 12px;
    border: 1px solid var(--ct-border);
    border-radius: 10px;
    color: var(--ct-ink);
    background: var(--ct-surface);
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
    cursor: pointer;
}

.ct-demo-button strong {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
}

.ct-demo-button span {
    display: block;
    font-size: 11px;
    line-height: 1.3;
    color: var(--ct-muted);
    overflow-wrap: anywhere;
    margin-top: 2px;
}

.ct-demo-button:hover,
.ct-demo-button:focus-visible {
    border-color: var(--ct-accent);
    background: var(--ct-soft);
    transform: translateY(-1px);
}


/* ================================================================
   8. FOOTER
   ================================================================ */

.ct-login-footer {
    margin-top: 18px;
    font-size: 13px;
    text-align: center;
}

.ct-login-footer a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 2px 6px;
}


/* ================================================================
   9. RESPONSIVE REFINEMENTS
   ================================================================ */

/* --- up to 1023px: tighter gutters, equal columns --- */
@media (max-width: 1023px) {
    body.ct-shipping-login {
        --ct-align: 28px;
        --ct-pad-y: 28px;
    }

    .ct-auth-shell {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

/* --- up to 899px: single stacked column --- */
@media (max-width: 899px) {
    .ct-auth-shell {
        grid-template-columns: minmax(0, 1fr);
        max-width: 560px;
    }

    /* Keep the top bar controls aligned with the narrower stacked card. */
    .ct-shipping-login .auth-topbar {
        max-width: 560px;
    }

    .ct-auth-story {
        border-inline-end: 0;
        border-bottom: 1px solid var(--ct-border);
    }

    /* Stacked, the story panel is only as tall as its content, so the band
       needs an explicit height instead of filling the column. */
    .ct-auth-story-media {
        flex: 0 0 auto;
        height: clamp(200px, 30vh, 320px);
    }

    .ct-auth-form-panel {
        padding-top: 26px;
        padding-bottom: 28px;
    }

    .ct-demo-grid {
        grid-template-columns: 1fr;
    }
}

/* --- up to 599px: phones --- */
@media (max-width: 599px) {
    body.ct-shipping-login {
        --ct-align: 20px;
        --ct-pad-y: 22px;
        padding: 10px 12px 22px !important;
    }

    .ct-auth-shell {
        border-radius: 14px;
    }

    .ct-shipping-login .auth-topbar {
        margin-bottom: 10px;
    }

    .ct-auth-story-media {
        height: clamp(180px, 26vh, 280px);
    }

    .ct-auth-form-panel {
        padding-top: 24px;
        padding-bottom: 24px;
    }

    .ct-login-heading {
        margin-bottom: 18px;
    }

    .ct-login-heading h1 {
        font-size: 22px;
    }

    /* 16px stops iOS Safari from zooming the viewport on focus. */
    .ct-shipping-login .login-card .form-control {
        font-size: 16px !important;
    }

    .ct-shipping-login .login-card .btn-primary {
        min-height: 48px;
        font-size: 16px !important;
    }
}

/* --- up to 399px: narrow phones --- */
@media (max-width: 399px) {
    body.ct-shipping-login {
        --ct-align: 16px;
        --ct-pad-y: 18px;
    }
}

/* --- short landscape viewports: keep the card above the fold --- */
@media (max-height: 680px) and (min-width: 900px) {
    body.ct-shipping-login {
        --ct-pad-y: 26px;
    }

    .ct-auth-story-media {
        min-height: 180px;
    }
}

/* --- print: no chrome, no media --- */
@media print {
    body.ct-shipping-login {
        background: #fff;
        padding: 0;
    }

    .ct-shipping-login .auth-topbar,
    .ct-auth-story-media,
    .ct-demo {
        display: none !important;
    }

    .ct-auth-shell {
        border: 0;
        box-shadow: none;
    }
}
