/*
 * Shared Components (PHASE 2.3)
 * Depends on: tokens.css
 *
 * Class-only selectors. No element resets, no body styles.
 * Safe to load alongside legacy CSS during migration.
 */

/* ─── Typography helpers ─────────────────────────── */
.an-tiny {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--subtle);
    font-family: var(--font-mono);
}

.an-copy {
    line-height: 1.65;
    color: color-mix(in oklab, var(--fg) 84%, var(--muted));
    max-width: 68ch;
}

.an-quote {
    border-left: 3px solid var(--red);
    padding-left: 16px;
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 1.7vw, 1.55rem);
    line-height: 1.15;
}

/* ─── Layout helpers ─────────────────────────── */
.an-line {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 12px;
}

.an-row,
.an-action-row,
.an-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.an-stack { display: grid; gap: 10px; }
.an-stack-lg { display: grid; gap: 16px; }

.an-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 600px) {
    .an-field-grid { grid-template-columns: 1fr; }
}

/* ─── Cards ─────────────────────────── */
.an-card,
.an-soft-card,
.an-danger-card,
.an-warn-card {
    border-radius: var(--radius-md);
    padding: 16px;
    display: grid;
    gap: 10px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--surface) 90%, white);
}

.an-soft-card {
    background: linear-gradient(180deg,
        color-mix(in oklab, var(--navy-soft) 55%, white),
        color-mix(in oklab, var(--surface) 92%, white));
    border-color: color-mix(in oklab, var(--navy) 12%, var(--border));
}

.an-danger-card {
    background: linear-gradient(180deg,
        color-mix(in oklab, var(--danger-soft) 60%, white),
        color-mix(in oklab, var(--surface) 92%, white));
    border-color: color-mix(in oklab, var(--danger) 18%, var(--border));
}

.an-warn-card {
    background: linear-gradient(180deg,
        color-mix(in oklab, var(--warn-soft) 60%, white),
        color-mix(in oklab, var(--surface) 92%, white));
    border-color: color-mix(in oklab, var(--warn) 18%, var(--border));
}

/* ─── Buttons ─────────────────────────── */
.an-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    line-height: 1;
    min-height: 44px;
    touch-action: manipulation;
    transition: transform 0.06s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.an-btn:hover { box-shadow: var(--shadow-sm); }
.an-btn:active { transform: translateY(1px); }
.an-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.an-btn--primary {
    background: var(--navy);
    color: white;
    border-color: transparent;
}

.an-btn--soft {
    background: var(--navy-soft);
    color: var(--navy);
    border-color: color-mix(in oklab, var(--navy) 18%, var(--border));
}

.an-btn--danger {
    background: var(--red);
    color: white;
    border-color: transparent;
}

.an-btn--ghost {
    background: transparent;
}

.an-btn--full { width: 100%; }

/* Icon button (compact, square-ish) */
.an-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
}

.an-icon-btn:hover { background: var(--surface-soft); }
.an-icon-btn--primary { background: var(--navy); color: white; border-color: transparent; }

/* ─── Chips & pills ─────────────────────────── */
.an-chip,
.an-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1;
}

.an-pill { padding: 4px 10px; font-size: 0.74rem; }

/* ─── Form fields ─────────────────────────── */
.an-field,
.an-select,
.an-textarea,
.an-search {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--fg);
    font: inherit;
    line-height: 1.4;
    min-height: 44px;
    box-sizing: border-box;
}

.an-field:focus,
.an-select:focus,
.an-textarea:focus,
.an-search:focus {
    outline: 2px solid color-mix(in oklab, var(--navy) 40%, transparent);
    outline-offset: 1px;
    border-color: color-mix(in oklab, var(--navy) 30%, var(--border));
}

.an-textarea {
    resize: vertical;
    min-height: 88px;
    font-family: inherit;
}

.an-field-label {
    display: block;
    font-size: 0.86rem;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 500;
}

/* ─── Status badge ─────────────────────────── */
.an-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    line-height: 1;
    border: 1px solid transparent;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.an-badge--pending   { background: var(--warn-soft);   color: var(--warn);   }
.an-badge--survey    { background: var(--navy-soft);   color: var(--navy);   }
.an-badge--installed { background: color-mix(in oklab, var(--ok-soft) 50%, white); color: var(--ok); }
.an-badge--active    { background: var(--ok-soft);     color: var(--ok);     }
.an-badge--rejected,
.an-badge--revision  { background: var(--danger-soft); color: var(--danger); }

/* ─── Logo box ─────────────────────────── */
.an-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: white;
    background: linear-gradient(135deg, var(--navy),
        color-mix(in oklab, var(--navy) 78%, black));
    position: relative;
    box-shadow: 0 8px 18px color-mix(in oklab, var(--navy) 28%, transparent);
    flex-shrink: 0;
}

.an-logo::after {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    top: 7px;
    right: 6px;
    background: var(--red);
    box-shadow: 0 0 0 2px color-mix(in oklab, var(--surface) 96%, white);
}

.an-logo--sm { width: 34px; height: 34px; border-radius: 10px; font-size: 0.9rem; }
.an-logo--lg { width: 64px; height: 64px; border-radius: 20px; font-size: 1.3rem; }

/* ─── Modal ─────────────────────────── */
.an-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: color-mix(in oklab, oklch(15% 0.02 60) 78%, transparent);
    display: grid;
    place-items: center;
    padding: 18px;
    overflow-y: auto;
}

.an-modal-card {
    background: var(--surface);
    border-radius: 20px;
    border: 1px solid var(--border);
    padding: 18px;
    display: grid;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    width: min(560px, 100%);
    max-height: 90vh;
    overflow-y: auto;
}

/* ─── Switch toggle ─────────────────────────── */
.an-switch {
    width: 46px;
    height: 28px;
    border-radius: 999px;
    background: var(--surface-strong);
    position: relative;
    border: 1px solid var(--border);
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.an-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: white;
    box-shadow: var(--shadow-sm);
    transition: left 0.15s ease, background 0.15s ease;
}

.an-switch.is-on {
    background: var(--navy-soft);
    border-color: color-mix(in oklab, var(--navy) 18%, var(--border));
}

.an-switch.is-on::after {
    left: 21px;
    background: var(--navy);
}

/* ─── Step band (multi-step indicator) ─────────────────────────── */
.an-step-band {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 6px;
}

.an-step-chip {
    text-align: center;
    padding: 9px 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--subtle);
    font-size: 0.76rem;
    line-height: 1.2;
}

.an-step-chip.is-current {
    background: var(--navy-soft);
    color: var(--navy);
    border-color: color-mix(in oklab, var(--navy) 14%, var(--border));
}

.an-step-chip.is-done {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: color-mix(in oklab, var(--ok) 14%, var(--border));
}
