/*
 * Company login page (layouts/company_auth): custom-domain login, forgot and
 * reset password, and the super admin preview. Brand colours come from the
 * --login-* variables, which the layout sets per company:
 *   --login-brand / --login-brand-rgb   the company colour (accents, glows, focus)
 *   --login-panel / --login-panel-dark  deeper shades for the panel and buttons
 *   --login-on-panel                    readable text on those shades
 */

.company-login {
    --login-page-bg: #f6f7fb;
    --login-card-bg: #ffffff;
    --login-text: #111827;
    --login-muted: #6b7280;
    --login-border: #e6e8ef;
    --login-input-bg: #f9fafb;
    --login-radius: 14px;
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    background: var(--login-page-bg);
    color: var(--login-text);
    font-family: "Plus Jakarta Sans", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.company-login *,
.company-login *::before,
.company-login *::after {
    box-sizing: border-box;
}

.company-login img {
    max-width: 100%;
}

.company-login h1,
.company-login h2,
.company-login .form-control,
.company-login .btn {
    font-family: inherit;
}

/* Preview ribbon */
.cl-ribbon {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 8px;
    padding: 9px 16px;
    background: #fff7e0;
    border-bottom: 1px solid #f1d58a;
    color: #5c4300;
    font-size: 0.8125rem;
    line-height: 1.4;
    text-align: center;
}

.cl-ribbon i {
    font-size: 1.05rem;
}

.cl-ribbon strong {
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(92, 67, 0, 0.08);
    font-weight: 600;
}

/* Page: brand panel and form column */
.cl-shell {
    display: grid;
    grid-template-columns: minmax(0, 46fr) minmax(0, 54fr);
    min-height: 100vh;
    min-height: 100dvh;
}

.cl-preview .cl-shell {
    min-height: calc(100vh - 40px);
}

/* Brand panel */
.cl-brand {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding: 40px clamp(32px, 4vw, 64px);
    color: var(--login-on-panel);
    background: linear-gradient(155deg, var(--login-panel) 0%, var(--login-panel-dark) 100%);
}

.cl-brand-art {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.cl-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(10px);
}

.cl-glow-a {
    width: 560px;
    height: 560px;
    top: -220px;
    inset-inline-end: -180px;
    background: radial-gradient(circle, rgba(var(--login-brand-rgb), 0.85) 0%, rgba(var(--login-brand-rgb), 0) 68%);
    opacity: 0.75;
}

.cl-glow-b {
    width: 480px;
    height: 480px;
    bottom: -240px;
    inset-inline-start: -160px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 70%);
}

.cl-ring {
    position: absolute;
    width: 640px;
    height: 640px;
    top: 50%;
    inset-inline-end: -360px;
    transform: translateY(-50%);
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 70px rgba(255, 255, 255, 0.025), 0 0 0 140px rgba(255, 255, 255, 0.02);
}

.cl-dots {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1.2px);
    background-size: 20px 20px;
    -webkit-mask-image: radial-gradient(ellipse at 20% 30%, #000 0%, transparent 60%);
    mask-image: radial-gradient(ellipse at 20% 30%, #000 0%, transparent 60%);
}

.cl-brand-head {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.cl-logo {
    position: relative;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    height: 64px;
    padding: 8px 12px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18), 0 0 0 4px rgba(255, 255, 255, 0.12);
}

.cl-logo img {
    display: block;
    max-height: 48px;
    max-width: 160px;
    width: auto;
    object-fit: contain;
}

.cl-logo-initials {
    display: none;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--login-panel);
}

.cl-logo-fallback .cl-logo-initials {
    display: block;
}

.cl-brand-id {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cl-brand-name {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.cl-brand-tag {
    margin-top: 2px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.75;
}

.cl-brand-body {
    max-width: 460px;
    margin-top: auto;
}

.cl-headline {
    margin: 0 0 28px;
    font-size: clamp(1.75rem, 2.6vw, 2.5rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: inherit;
}

.cl-points {
    display: grid;
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cl-points li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.975rem;
    font-weight: 500;
    opacity: 0.95;
}

.cl-point-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 1.1rem;
}

/* Decorative dashboard sketch, drawn at 440x200 and scaled with --cl-sc to fit the screen */
.cl-showcase {
    --cl-sc: 1;
    flex-shrink: 0;
    width: calc(440px * var(--cl-sc));
    max-width: 100%;
    height: calc(200px * var(--cl-sc));
    margin-bottom: auto;
}

.cl-showcase-inner {
    position: relative;
    width: 440px;
    height: 200px;
    transform: scale(var(--cl-sc));
    transform-origin: top left;
}

[dir="rtl"] .cl-showcase-inner {
    transform-origin: top right;
}

.cl-tile {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #111827;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.cl-tile strong {
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
}

.cl-tile small {
    display: block;
    font-size: 0.75rem;
    color: #6b7280;
}

.cl-tile-main {
    inset-inline-start: 0;
    top: 0;
    width: 270px;
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
}

.cl-tile-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cl-tile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(var(--login-brand-rgb), 0.14);
    color: var(--login-panel);
    font-size: 1.15rem;
}

.cl-tile-badge {
    margin-inline-start: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #dcfce7;
    color: #15803d;
    font-size: 0.85rem;
}

.cl-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 64px;
    margin-top: 14px;
}

.cl-bars span {
    flex: 1;
    border-radius: 6px 6px 3px 3px;
    background: linear-gradient(180deg, var(--login-brand), var(--login-panel));
}

.cl-bars .cl-bar-muted {
    background: #e5e7eb;
}

.cl-tile-side {
    inset-inline-end: 0;
    top: 44px;
    padding: 14px 16px;
}

.cl-donut {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: conic-gradient(var(--login-brand) 0 68%, #e5e7eb 68% 100%);
    -webkit-mask: radial-gradient(circle, transparent 11px, #000 12px);
    mask: radial-gradient(circle, transparent 11px, #000 12px);
}

.cl-tile-pill {
    inset-inline-start: 120px;
    bottom: 0;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.cl-tile-pill i {
    color: #15803d;
    font-size: 1.05rem;
}

/* Form column */
.cl-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 32px 24px;
    background:
        radial-gradient(900px 500px at 100% 0%, rgba(var(--login-brand-rgb), 0.07), transparent 60%),
        var(--login-page-bg);
}

.cl-main-inner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 440px;
    flex: 1;
}

.company-login .cl-card {
    width: 100%;
    margin: 0;
    background: var(--login-card-bg);
    border: 1px solid var(--login-border);
    border-radius: 20px;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 24px 48px -12px rgba(17, 24, 39, 0.12);
}

.company-login .cl-card .card-body {
    padding: 40px;
}

.company-login .cl-card h2 {
    margin-bottom: 6px !important;
    font-size: 1.75rem;
    font-weight: 800 !important;
    letter-spacing: -0.02em;
    color: var(--login-text);
}

.company-login .cl-card-sub {
    margin: 0 0 28px;
    font-size: 0.9375rem;
    color: var(--login-muted);
}

.company-login .cl-card .form-label {
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--login-text);
}

.company-login .cl-card .form-group {
    margin-bottom: 18px !important;
}

.company-login .cl-card .form-control {
    min-height: 50px;
    padding: 12px 16px 12px 46px;
    font-size: 0.9375rem;
    color: var(--login-text);
    background-color: var(--login-input-bg);
    background-repeat: no-repeat;
    background-position: 16px center;
    background-size: 18px 18px;
    border: 1px solid var(--login-border);
    border-radius: 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

[dir="rtl"] .company-login .cl-card .form-control,
.company-login[dir="rtl"] .cl-card .form-control {
    padding: 12px 46px 12px 16px;
    background-position: calc(100% - 16px) center;
}

.company-login .cl-card .form-control::placeholder {
    color: #9ca3af;
}

.company-login .cl-card .form-control:hover {
    border-color: #d1d5db;
}

.company-login .cl-card .form-control:focus {
    background-color: var(--login-card-bg);
    border-color: var(--login-brand);
    box-shadow: 0 0 0 4px rgba(var(--login-brand-rgb), 0.16);
    outline: 0;
}

.company-login .cl-card .form-control:disabled {
    cursor: not-allowed;
    opacity: 1;
    background-color: #f3f4f6;
}

.company-login .cl-card .form-control.is-invalid {
    border-color: #dc2626;
}

/* Field icons (mail / lock) as inline SVG so the markup stays shared with the main login page */
.company-login .cl-card input[type="email"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='m3 7 9 6 9-6'/%3E%3C/svg%3E");
}

.company-login .cl-card input[type="password"],
.company-login .cl-card .cl-pass-wrap input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E");
}

.company-login .cl-card .text-danger small {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.8125rem;
}

.company-login .cl-card a {
    color: var(--login-link);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}

.company-login .cl-card a:hover {
    text-decoration: underline;
}

/* "Forgot password" sits on the right, just under the password field */
.company-login .cl-card .pss-field + .form-group > .d-flex {
    justify-content: flex-end !important;
}

.company-login .cl-card .pss-field + .form-group {
    margin-top: -6px;
    margin-bottom: 22px !important;
}

.company-login .btn-primary,
.company-login .btn-primary:hover,
.company-login .btn-primary:focus,
.company-login .btn-primary:active,
.company-login .btn-primary:disabled {
    position: relative;
    min-height: 50px;
    border-radius: 12px;
    font-size: 0.9875rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    background: linear-gradient(135deg, var(--login-panel), var(--login-panel-dark)) !important;
    border: 0 !important;
    color: var(--login-on-panel) !important;
    box-shadow: 0 10px 22px -8px rgba(var(--login-brand-rgb), 0.65);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.company-login .btn-primary:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 14px 26px -8px rgba(var(--login-brand-rgb), 0.7);
}

.company-login .btn-primary:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 4px rgba(var(--login-brand-rgb), 0.3);
}

.company-login .btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.company-login .btn-primary.cl-busy {
    color: transparent !important;
}

.company-login .btn-primary.cl-busy::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border-radius: 50%;
    border: 2px solid var(--login-on-panel);
    border-right-color: transparent;
    animation: cl-spin 0.7s linear infinite;
}

@keyframes cl-spin {
    to {
        transform: rotate(360deg);
    }
}

.company-login .cl-card .alert {
    border-radius: 12px;
    font-size: 0.875rem;
}

/* "Back to Login" line on the forgot password card */
.company-login .cl-card .d-grid p {
    margin: 20px 0 0 !important;
    font-size: 0.875rem;
    color: var(--login-muted);
}

/* Password show/hide toggle (added by the layout script) */
.cl-pass-wrap {
    position: relative;
    display: block;
}

.cl-pass-wrap .form-control {
    padding-inline-end: 50px !important;
}

.cl-pass-toggle {
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-end: 4px;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--login-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.cl-pass-toggle:hover:not(:disabled) {
    color: var(--login-text);
}

.cl-pass-toggle:focus-visible {
    outline: 2px solid rgba(var(--login-brand-rgb), 0.5);
    outline-offset: -4px;
}

.cl-pass-toggle:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Footer */
.cl-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    width: 100%;
    max-width: 560px;
    margin-top: 32px;
    padding-top: 18px;
    border-top: 1px solid var(--login-border);
    font-size: 0.8125rem;
    color: var(--login-muted);
}

.cl-footer p {
    margin: 0;
}

.cl-powered {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px 5px 10px;
    border-radius: 999px;
    background: var(--login-card-bg);
    border: 1px solid var(--login-border);
    white-space: nowrap;
}

.cl-powered img {
    height: 16px;
    width: auto;
}

.cl-powered strong {
    color: var(--login-text);
    font-weight: 700;
    letter-spacing: 0.01em;
}

/* Dark layout */
.company-login.cl-dark {
    --login-page-bg: #0f1115;
    --login-card-bg: #171a21;
    --login-text: #e5e7eb;
    --login-muted: #9ca3af;
    --login-border: #2a2f3a;
    --login-input-bg: #1d212a;
}

.company-login.cl-dark .cl-card .form-control:disabled {
    background-color: #20242c;
}

.company-login.cl-dark .cl-card a {
    color: #c7cbff;
}

/*
 * Two-column layout on shorter or narrower screens: the panel never clips.
 * The dashboard sketch needs width and height, the feature points need height.
 */
@media (min-width: 992px) {
    .cl-brand {
        position: sticky;
        top: 0;
        height: 100vh;
        height: 100dvh;
    }

    .cl-preview .cl-brand {
        top: 40px;
        height: calc(100vh - 40px);
        height: calc(100dvh - 40px);
    }
}

@media (min-width: 992px) and (max-width: 1199.98px), (min-width: 992px) and (max-height: 859.98px) {
    .cl-showcase {
        --cl-sc: 0.85;
    }
}

@media (min-width: 992px) and (max-height: 719.98px) {
    .cl-showcase {
        --cl-sc: 0.72;
    }
}

@media (min-width: 992px) and (max-height: 599.98px) {
    .cl-showcase {
        --cl-sc: 0.62;
    }
}

@media (min-width: 992px) and (max-height: 679.98px) {
    .cl-brand {
        gap: 24px;
        padding-top: 28px;
        padding-bottom: 28px;
    }

    .cl-headline {
        margin-bottom: 18px;
        font-size: clamp(1.5rem, 2.2vw, 2rem);
    }

    .cl-points {
        gap: 10px;
    }

    .cl-point-icon {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }

    .cl-main {
        padding-top: 28px;
    }

    .company-login .cl-card .card-body {
        padding: 28px 32px;
    }

    .company-login .cl-card-sub {
        margin-bottom: 20px;
    }

    .cl-footer {
        margin-top: 20px;
    }
}

@media (min-width: 992px) and (max-height: 539.98px) {
    .cl-points {
        display: none;
    }

    .cl-brand-body {
        margin: auto 0;
    }

    .company-login .cl-card .form-group {
        margin-bottom: 12px !important;
    }
}

/* Large monitors: keep the panel copy from stretching */
@media (min-width: 1600px) {
    .cl-brand {
        padding-inline: 88px;
    }

    .cl-headline {
        font-size: 2.75rem;
    }
}

/* Tablets and phones: one column, brand header on top, card overlapping it */
@media (max-width: 991.98px) {
    .cl-shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 1fr;
    }

    .cl-brand {
        gap: 20px;
        padding: 28px 24px 104px;
    }

    .cl-ring {
        width: 420px;
        height: 420px;
        top: -120px;
        inset-inline-end: -200px;
        transform: none;
    }

    .cl-glow-a {
        width: 380px;
        height: 380px;
        top: -180px;
    }

    .cl-brand-body {
        margin: 0;
        max-width: 560px;
    }

    .cl-headline {
        margin: 0;
        font-size: clamp(1.375rem, 4.5vw, 1.875rem);
    }

    .cl-points {
        display: none;
    }

    .cl-showcase {
        --cl-sc: 0.9;
        margin: 4px 0 0;
    }

    .cl-main {
        padding: 0 24px 20px;
        background: var(--login-page-bg);
    }

    .cl-main-inner {
        flex: 0 0 auto;
        max-width: 480px;
        margin-top: -64px;
    }

    .cl-footer {
        justify-content: center;
        max-width: 480px;
        margin-top: 28px;
        text-align: center;
    }
}

@media (max-width: 575.98px) {
    .cl-brand {
        padding: 20px 16px 80px;
    }

    .cl-showcase {
        --cl-sc: 0.74;
    }

    .cl-logo {
        min-width: 52px;
        height: 52px;
        padding: 6px 10px;
        border-radius: 14px;
    }

    .cl-logo img {
        max-height: 38px;
        max-width: 120px;
    }

    .cl-brand-name {
        font-size: 1rem;
    }

    .cl-main {
        padding: 0 16px 16px;
    }

    .company-login .cl-card {
        border-radius: 18px;
    }

    .company-login .cl-card .card-body {
        padding: 28px 20px;
    }

    .company-login .cl-card h2 {
        font-size: 1.5rem;
    }

    .company-login .cl-card-sub {
        margin-bottom: 22px;
    }

    .cl-footer {
        flex-direction: column;
        justify-content: center;
        text-align: center;
    }
}

/* Narrow phones (320-379px): the sketch must fit inside 16px gutters */
@media (max-width: 379.98px) {
    .cl-showcase {
        --cl-sc: 0.64;
    }
}

@media (prefers-reduced-motion: reduce) {
    .company-login * {
        transition: none !important;
        animation-duration: 0.01ms !important;
    }
}
