/* ClearCoat shared login.
   Brand values copied (not linked) from Detailing: static/css/styles.css
   (--primary-color #3b82f6, --primary-dark #2563eb, --text-primary #1e293b,
   --text-secondary #64748b, --border-color #e2e8f0, --radius 8px / 12px,
   login-page gradient, danger colors) and templates/login.html (wordmark
   #0b1220, logo mark gradient #4ea6ff -> #8a5cf6). No web fonts: system stack. */

:root {
    --cc-primary: #3b82f6;
    --cc-primary-dark: #2563eb;
    --cc-ink: #0b1220;
    --cc-text: #1e293b;
    --cc-text-muted: #64748b;
    --cc-border: #e2e8f0;
    --cc-surface: #ffffff;
    --cc-danger-text: #b91c1c;
    --cc-danger-bg: #fef2f2;
    --cc-danger-border: #fecaca;
    --cc-focus-ring: #93c5fd;
    --cc-radius: 8px;
    --cc-radius-lg: 12px;
    --cc-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

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

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--cc-font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--cc-text);
    background-color: var(--cc-primary-dark);
    background-image: linear-gradient(135deg, var(--cc-primary) 0%, var(--cc-primary-dark) 100%);
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

.login-wrap {
    width: 100%;
    max-width: 420px;
    padding: 24px 16px;
}

.login-box {
    background: var(--cc-surface);
    border-radius: var(--cc-radius-lg);
    padding: 32px 24px 24px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    transition: opacity 0.15s ease;
}

/* Hidden until the session check resolves (JS removes is-checking). */
body.is-checking .login-box {
    opacity: 0;
}

@media (min-width: 480px) {
    .login-wrap {
        padding: 40px 20px;
    }

    .login-box {
        padding: 40px;
    }
}

/* Brand */
.brand {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.cc-logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.cc-logo svg {
    display: block;
    flex: 0 0 auto;
}

.cc-wordmark {
    font-weight: 600;
    font-size: 28px;
    line-height: 1;
    letter-spacing: -0.035em;
    color: var(--cc-ink);
}

h1 {
    margin: 0 0 20px;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    color: var(--cc-ink);
}

/* Live region for errors. Stays in layout so screen readers announce changes. */
.status {
    margin-bottom: 16px;
}

.status:empty {
    margin: 0;
    padding: 0;
    border: 0;
}

.status:not(:empty) {
    background: var(--cc-danger-bg);
    color: var(--cc-danger-text);
    border: 1px solid var(--cc-danger-border);
    border-radius: var(--cc-radius);
    padding: 12px;
    font-size: 14px;
    line-height: 1.45;
}

/* Fields */
.field {
    margin-bottom: 18px;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--cc-text);
}

.label-row label {
    margin-bottom: 0;
}

input {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 12px 14px;
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius);
    font-family: inherit;
    font-size: 16px;
    color: var(--cc-text);
    background: var(--cc-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input::placeholder {
    color: #94a3b8;
}

input:focus {
    outline: none;
    border-color: var(--cc-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

input[aria-invalid="true"] {
    border-color: var(--cc-danger-text);
}

/* Email becomes a compact read-only line once the password step opens. */
.field-email.is-compact input {
    padding: 10px 14px;
    background: #f8fafc;
    color: #475569;
}

/* Password block collapses to zero height but stays in the DOM so password
   managers can fill it before it is revealed. */
.reveal {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows 0.2s ease, opacity 0.2s ease;
}

.reveal.is-open {
    grid-template-rows: 1fr;
    opacity: 1;
}

.reveal-inner {
    min-height: 0;
    overflow: hidden;
    padding: 4px 4px 0;
}

/* Links and buttons */
.link-btn {
    margin: -10px -4px;
    padding: 10px 4px;
    border: 0;
    border-radius: 4px;
    background: none;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--cc-primary-dark);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.link-btn:hover {
    color: #1e40af;
}

.link-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

a:focus-visible,
.link-btn:focus-visible,
.btn-primary:focus-visible,
.product-card:focus-visible {
    outline: 3px solid var(--cc-focus-ring);
    outline-offset: 2px;
}

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 46px;
    margin-top: 6px;
    padding: 12px 20px;
    border: 0;
    border-radius: var(--cc-radius);
    background: var(--cc-primary);
    color: #ffffff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background: var(--cc-primary-dark);
}

.btn-primary:disabled {
    opacity: 0.75;
    cursor: progress;
}

.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: cc-spin 0.7s linear infinite;
}

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

/* Product picker */
.picker-email {
    margin: -8px 0 16px;
    font-size: 14px;
    color: var(--cc-text-muted);
    text-align: center;
    overflow-wrap: anywhere;
}

.product-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.product-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 64px;
    padding: 16px;
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius-lg);
    background: var(--cc-surface);
    color: var(--cc-text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.product-card:hover {
    border-color: var(--cc-primary);
    background: #f8fbff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.12);
}

.product-card:disabled {
    opacity: 0.6;
    cursor: progress;
}

.product-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #eff6ff;
    color: var(--cc-primary-dark);
}

.product-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.product-label {
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
    overflow-wrap: anywhere;
}

.product-org {
    margin-top: 2px;
    font-size: 13px;
    color: var(--cc-text-muted);
    overflow-wrap: anywhere;
}

.product-chevron {
    display: flex;
    flex: 0 0 auto;
    color: #94a3b8;
}

.picker-signout {
    margin: 16px 0 0;
    text-align: center;
}

/* Footer links under the form */
.login-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--cc-border);
    text-align: center;
    font-size: 13px;
    color: var(--cc-text-muted);
}

.login-footer p {
    margin: 0;
}

.login-footer a {
    color: var(--cc-primary-dark);
    font-weight: 500;
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

.login-footer .forgot {
    margin-bottom: 10px;
    font-size: 14px;
}

.legal-sep {
    margin: 0 8px;
}

.copyright {
    margin-top: 10px !important;
    font-size: 12px;
}

@media (prefers-reduced-motion: reduce) {
    body.is-checking .login-box,
    .login-box,
    .reveal,
    input,
    .btn-primary,
    .product-card {
        transition: none;
    }

    .btn-spinner {
        animation-duration: 1.6s;
    }
}
