/* Auth screens (login / forgot / reset), toasts, autosave indicator,
   and locked-revision banner. Uses the app's existing design tokens. */

/* ---------- auth pages (split-panel: blueprint brand left, form right) ---------- */

/* Auth screens stand alone — no app header/toolbar. */
body.signed-out .app-header { display: none; }

.auth-page {
    min-height: 100vh;
    display: flex;
    background: var(--background-color);
}

.auth-split {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Left brand panel — deep navy with a drafting-grid motif. Deliberately the
   same in both themes: it reads as the product's blueprint identity. */
.auth-hero {
    position: relative;
    flex: 1.15;
    background:
        radial-gradient(900px 600px at 20% 110%, rgba(3, 105, 161, 0.35), transparent 60%),
        linear-gradient(160deg, #0b1220, #0f172a),
        #0f172a;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    overflow: hidden;
}
.auth-hero-grid {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.16) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.16) 1px, transparent 1px),
        linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
    background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
    mask-image: radial-gradient(1200px 800px at 30% 40%, #000 30%, transparent 75%);
}
.auth-hero-inner {
    position: relative;
    padding: 56px 64px;
    max-width: 560px;
}
/* The logo artwork is dark, and the hero panel is dark in both themes —
   sit the logo on a white chip so it stays legible. */
.auth-hero-brand {
    display: inline-flex; align-items: center;
    background: #fff;
    border-radius: 10px;
    padding: 4px 10px;
    margin-bottom: 34px;
}
.auth-hero-brand img {
    height: 58px;
    width: auto;
    display: block;
}
.auth-hero h2 {
    font-size: clamp(22px, 2.2vw, 30px);
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: -0.015em;
    margin-bottom: 28px;
}
.auth-hero-points { list-style: none; display: grid; gap: 14px; }
.auth-hero-points li {
    display: flex; gap: 12px; align-items: baseline;
    font-size: 13.5px; color: #b6c2d4;
}
.auth-hero-points i { color: #38bdf8; width: 18px; text-align: center; }
.auth-hero-foot {
    margin-top: 40px;
    font-size: 12px; color: #64748b;
    text-transform: uppercase; letter-spacing: 0.14em;
}

/* Right form panel */
.auth-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}
.auth-card { width: 100%; max-width: 380px; }

.auth-brand { margin-bottom: 26px; }
.auth-brand h1 { font-size: 24px; letter-spacing: -0.02em; margin: 0 0 6px; }
.auth-brand p { color: var(--text-light); font-size: 14px; margin: 0; }

.auth-card .field { margin-top: 16px; }
.auth-card .field input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border-radius: var(--radius-sm);
}

/* password show/hide toggle */
.auth-card .input-wrap.has-pw-toggle { position: relative; }
.auth-card .input-wrap.has-pw-toggle input { padding-right: 42px; }
.pw-toggle {
    position: absolute;
    top: 50%; right: 6px;
    transform: translateY(-50%);
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent;
    color: var(--text-light);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 14px;
}
.pw-toggle:hover { color: var(--text-color); background: var(--surface-sunken); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; }

.auth-submit {
    width: 100%;
    margin-top: 22px;
    justify-content: center;
    padding: 11px 14px;
    font-size: 14px;
}

/* Brand above the form card — only shown on narrow screens where the hero
   panel (which normally carries the logo) is hidden. White chip because the
   logo artwork is dark. */
.auth-mobile-brand { display: none; }

/* Narrow screens: drop the brand panel, keep the form. */
@media (max-width: 860px) {
    .auth-hero { display: none; }
    .auth-mobile-brand {
        display: inline-flex;
        background: #fff;
        border-radius: 10px;
        padding: 8px 14px;
        margin-bottom: 22px;
    }
    .auth-mobile-brand img { height: 34px; width: auto; display: block; }
}

.auth-links { margin-top: 16px; text-align: center; font-size: 13px; }
.auth-links a { color: var(--accent-color); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

.auth-error, .auth-alert, .auth-info {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex; gap: 8px; align-items: flex-start;
}
.auth-error { background: #fef2f2; color: var(--danger-color); border: 1px solid #fecaca; }
.auth-alert { background: #fffbeb; color: var(--warning-color); border: 1px solid #fde68a; }
.auth-info  { background: #f0fdf4; color: var(--success-color); border: 1px solid #bbf7d0; }

body.signed-out .top-nav,
body.signed-out #btn-sign-out { display: none; }

/* ---------- toasts ---------- */

.toast-host {
    position: fixed;
    bottom: 18px; right: 18px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 1000;
}
.toast {
    display: flex; align-items: center; gap: 9px;
    background: var(--primary-color); color: #fff;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 13px;
    max-width: 360px;
    cursor: pointer;
    animation: toast-in var(--duration-normal) var(--ease-out);
}
.toast-error { background: var(--danger-color); }
.toast-success { background: var(--success-color); }
.toast-out { opacity: 0; transform: translateY(6px); transition: all 200ms; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- autosave indicator (editor topbar) ---------- */

.save-status {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-light);
    padding: 3px 8px;
    border-radius: 99px;
    white-space: nowrap;
}
.save-status i { font-size: 11px; }
.save-status[data-state="saved"]   { color: var(--success-color); }
.save-status[data-state="offline"] { color: var(--warning-color); background: #fffbeb; }
.save-status[data-state="conflict"]{ color: var(--danger-color); background: #fef2f2; }

/* ---------- locked / read-only revision ---------- */

.readonly-banner {
    display: flex; align-items: center; gap: 10px;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    color: var(--warning-color);
    padding: 8px 16px;
    font-size: 13px;
}
.readonly-banner .btn { margin-left: auto; }

.spec-panel.readonly { position: relative; }
.spec-panel.readonly .spec-form { opacity: 0.55; pointer-events: none; }

/* revision picker in the editor topbar */
.rev-switch { display: inline-flex; align-items: center; gap: 6px; }
.rev-switch select { font-size: 12px; max-width: 190px; }

/* finalized badge on project cards / revision rows */
.finalized-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10.5px; font-weight: 600;
    color: var(--success-color);
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 99px;
    padding: 1px 8px;
    text-transform: uppercase; letter-spacing: 0.04em;
}

/* ---------- project list filter bar ---------- */

.project-filters {
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.project-filters .search-wrap {
    position: relative;
    flex: 1 1 220px; max-width: 320px;
}
.project-filters .search-wrap i {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--text-light); font-size: 12px;
}
.project-filters .search-wrap input {
    width: 100%;
    padding: 7px 10px 7px 30px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--card-bg);
    color: var(--text-color);
}
.filter-chip {
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-light);
    border-radius: 99px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
}
.filter-chip.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* company picker cards (new-project form) */
.company-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
    max-width: 620px;
}
.company-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    font-family: var(--font-sans);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--duration-fast) ease, background var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}
.company-card:hover { border-color: var(--primary-color); }
.company-card.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.company-card-mark {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface-sunken);
    color: var(--text-color);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.company-card.active .company-card-mark { background: var(--primary-color); color: #fff; }
.company-card-name {
    flex: 1;
    min-width: 0;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.company-card-check {
    font-size: 14px;
    color: var(--primary-color);
    opacity: 0;
    transition: opacity var(--duration-fast) ease;
}
.company-card.active .company-card-check { opacity: 1; }

/* company selector row (settings + filters) */
.company-picker-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px; padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}
.company-picker-row select { min-width: 200px; }

/* ---------- dark theme ---------- */

:root[data-theme="dark"] .auth-error { background: #2a1414; border-color: #7f1d1d; }
:root[data-theme="dark"] .auth-alert { background: #2a2210; border-color: #78500f; }
:root[data-theme="dark"] .auth-info  { background: #0f2a1a; border-color: #14532d; }
:root[data-theme="dark"] .save-status[data-state="offline"]  { background: #2a2210; }
:root[data-theme="dark"] .save-status[data-state="conflict"] { background: #2a1414; }
:root[data-theme="dark"] .readonly-banner { background: #2a2210; border-bottom-color: #78500f; }
:root[data-theme="dark"] .finalized-badge { background: #0f2a1a; border-color: #14532d; }
