/* =========================================================
   Commercial Lines Quoter — Plugin Styles
   Uses design-system CSS variables from variables.css
   Dark mode: body.dark-mode .selector pattern
   ========================================================= */

/* ── Local design token — commercial purple accent ─────── */
:root {
    --cq-purple: var(--cq-purple);
}
body.dark-mode {
    --cq-purple: #C084FC;
}

/* ── Step Progress Header ─────────────────────────────── */
/* .step-title and .progress-track/.progress-fill are
   defined in layout.css / components.css and reused here */

/* ── Form Labels ──────────────────────────────────────── */
.form-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
    display: block;
    line-height: 18px;
}

.cq-ssn-note {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-tertiary);
    text-transform: none;
    letter-spacing: 0;
}

/* ── Step Nav (inside #cq-app) ────────────────────────── */
.cq-step-nav {
    padding: 20px 20px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.cq-step-nav::-webkit-scrollbar { display: none; }

.cq-step-track {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    position: relative;
    min-width: 420px;
}
.cq-step-track::before {
    content: '';
    position: absolute;
    top: 18px;
    left: 18px;
    right: 18px;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.cq-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    position: relative;
    z-index: 1;
    flex: 1;
    background: none;
    border: none;
    height: auto;
    font-size: 14px; /* reset global [data-tooltip] bleed */
}

.cq-dot-inner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-card);
    border: 2px solid var(--border);
    color: var(--text-secondary);
    transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease, transform 0.25s var(--transition-spring);
}

.cq-dot-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
    white-space: nowrap;
    transition: color 0.2s ease;
}

/* Active step */
.cq-dot.active .cq-dot-inner {
    background: var(--apple-blue);
    border-color: var(--apple-blue);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.18);
    transform: scale(1.12);
}
.cq-dot.active .cq-dot-label {
    color: var(--apple-blue);
    font-weight: 600;
}

/* Completed steps — dots that precede the active one */
.cq-dot:has(~ .cq-dot.active) .cq-dot-inner,
.cq-dot.cq-done .cq-dot-inner {
    background: rgba(52, 199, 89, 0.12);
    border-color: var(--success);
    color: var(--success);
}
.cq-dot:has(~ .cq-dot.active) .cq-dot-label,
.cq-dot.cq-done .cq-dot-label {
    color: var(--success);
}

/* ── Step Panels ──────────────────────────────────────── */
.cq-step {
    padding: 16px 20px 0;
    animation: fadeInUp 0.22s ease;
}
.cq-step.hidden { display: none; }

@keyframes cqFadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cq-step { animation: cqFadeUp 0.2s ease; }

/* ── Welcome Card (Step 0) ────────────────────────────── */
.cq-welcome-card {
    text-align: center;
    padding: 36px 24px 28px;
    margin-bottom: 16px;
}
.cq-welcome-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 16px;
}
.cq-welcome-card h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 8px;
}
.cq-start-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    padding: 12px 28px;
    border-radius: 12px;
    margin-top: 8px;
}
.cq-features {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 18px;
}
.cq-feature-pill {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
}

/* ── Form Layout Helpers ──────────────────────────────── */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}
.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0 16px;
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin: 20px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.cq-required {
    color: var(--danger);
    margin-left: 1px;
}

/* ── Coverage Toggle Rows ─────────────────────────────── */
.cq-coverage-row {
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    margin-bottom: 10px;
    overflow: hidden;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.cq-coverage-row:hover {
    border-color: var(--apple-blue);
    box-shadow: 0 2px 8px var(--shadow);
}

/* Selected state */
.cq-coverage-row:has(.cq-cov-check:checked) {
    border-color: var(--apple-blue);
    background: rgba(0, 122, 255, 0.04);
    box-shadow: 0 2px 12px rgba(0, 122, 255, 0.12);
}

.cq-cov-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
}

.cq-cov-icon {
    font-size: 22px;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.cq-cov-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cq-cov-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.cq-cov-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Hide native checkbox */
.cq-cov-check {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Toggle track */
.cq-toggle-track {
    width: 44px;
    height: 26px;
    border-radius: 13px;
    background: var(--border);
    position: relative;
    flex-shrink: 0;
    transition: background 0.25s ease;
}
.cq-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    transition: transform 0.25s var(--transition-spring);
}

/* Toggle active state */
.cq-coverage-row:has(.cq-cov-check:checked) .cq-toggle-track {
    background: var(--apple-blue);
}
.cq-coverage-row:has(.cq-cov-check:checked) .cq-toggle-thumb {
    transform: translateX(18px);
}

/* Coverage detail panel */
.cq-coverage-detail {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-input);
}
.cq-coverage-detail.hidden { display: none; }

/* ── Y/N Pill Buttons ─────────────────────────────────── */
.cq-yn-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.cq-yn-row:last-of-type { border-bottom: none; }

.cq-yn-question {
    font-size: 14px;
    color: var(--text);
    flex: 1;
}

.cq-radio-group {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.cq-yn-btn {
    cursor: pointer;
}
.cq-yn-btn input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.cq-yn-btn span {
    display: block;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
    user-select: none;
}
.cq-yn-btn:has(input:checked) span {
    background: var(--apple-blue);
    color: #fff;
    border-color: var(--apple-blue);
}

/* Subcontractor detail expansion */
#cq-sub-detail.hidden { display: none; }
.cq-sub-detail-inner {
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
}

/* ── Review Card (Step 6) ─────────────────────────────── */
.cq-review-card { padding: 24px; }
.cq-review-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.cq-review-icon { font-size: 40px; line-height: 1; }
.cq-review-header h2 { margin: 0 0 4px; font-size: 20px; }

/* Summary sections (rendered by JS) */
.cq-summary-section {
    margin-bottom: 20px;
}
.cq-summary-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}
.cq-summary-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 0;
    font-size: 14px;
}
.cq-summary-label {
    color: var(--text-secondary);
    min-width: 160px;
    flex-shrink: 0;
    font-size: 13px;
}
.cq-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 122, 255, 0.1);
    color: var(--apple-blue);
    border: 1px solid rgba(0, 122, 255, 0.2);
    border-radius: 6px;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 500;
    margin: 2px 3px 2px 0;
}

/* ── Export Buttons (Step 6) ──────────────────────────── */
.cq-export-group {
    display: flex;
    gap: 10px;
    padding: 16px 20px 20px;
    flex-wrap: wrap;
}
.cq-export-group.hidden { display: none; }
.cq-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 10px;
}

/* ── Recent Quote Items (rendered by JS) ──────────────── */
.cq-quote-count {
    font-size: 12px;
    color: var(--text-tertiary);
    margin: 0 0 8px;
}
.cq-recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    transition: border-color 0.18s ease, background 0.18s ease;
}
.cq-recent-item:hover {
    border-color: var(--apple-blue);
    background: var(--bg-card);
}
.cq-recent-info {
    flex: 1;
    min-width: 0;
}
.cq-recent-info strong {
    display: block;
    font-size: 14px;
    color: var(--text);
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cq-cov-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}
.cq-cov-pill {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    white-space: nowrap;
}
.cq-recent-date {
    font-size: 11px;
    color: var(--text-tertiary);
}
.cq-recent-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.cq-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0;
}
.cq-delete-btn:hover {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
}

/* ── Step Footer ──────────────────────────────────────── */
.cq-step-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
    gap: 12px;
}
/* Desktop polish — match personal lines footer feel */
@media (min-width: 960px) {
    #commercialQuoterTool footer {
        border-radius: 16px 16px 0 0;
        padding: 12px 32px calc(12px + env(safe-area-inset-bottom));
        justify-content: space-between;
        align-items: center;
    }
}
.cq-step-counter {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    letter-spacing: 0.03em;
}

/* ── Dark Mode ────────────────────────────────────────── */
body.dark-mode .cq-dot-inner {
    background: #2C2C2E;
}
body.dark-mode .cq-coverage-row {
    background: #1C1C1E;
}
body.dark-mode .cq-coverage-row:has(.cq-cov-check:checked) {
    background: rgba(10, 132, 255, 0.08);
}
body.dark-mode .cq-toggle-track {
    background: #3A3A3C;
}
body.dark-mode .cq-toggle-thumb {
    background: #E5E5EA;
}
body.dark-mode .cq-yn-btn span {
    background: #2C2C2E;
    border-color: #38383A;
}
body.dark-mode .cq-feature-pill {
    background: #2C2C2E;
    border-color: #38383A;
}
body.dark-mode .cq-recent-item {
    background: #2C2C2E;
    border-color: #38383A;
}
body.dark-mode .cq-recent-item:hover {
    background: #1C1C1E;
    border-color: var(--apple-blue);
}
body.dark-mode .cq-cov-pill {
    background: #1C1C1E;
    border-color: #38383A;
}
body.dark-mode .cq-delete-btn:hover {
    background: rgba(255, 69, 58, 0.15);
}
body.dark-mode .cq-coverage-detail {
    background: #2C2C2E;
}
body.dark-mode .cq-sub-detail-inner {
    background: #2C2C2E;
    border-color: #38383A;
}

/* ── Investigate Button ───────────────────────────────── */
.cq-investigate-btn {
    margin-top: 8px;
    font-size: 13px;
    padding: 7px 14px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.cq-intel-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--apple-blue);
    border-radius: 50%;
    animation: cqSpin 0.6s linear infinite;
}
@keyframes cqSpin { to { transform: rotate(360deg); } }

/* ── Intel Sidebar Card ──────────────────────────────── */
.cq-intel-card {
    border: 1.5px solid rgba(168, 85, 247, 0.25);
    background: linear-gradient(135deg, var(--bg-card), rgba(168, 85, 247, 0.03));
}
.cq-intel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.cq-intel-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}
.cq-intel-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.cq-intel-pill {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1.5px solid;
    background: transparent;
    white-space: nowrap;
}
.cq-intel-summary,
.cq-intel-gl,
.cq-intel-risk,
.cq-intel-flags,
.cq-intel-osha {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 10px;
    color: var(--text-secondary);
}
.cq-intel-summary { margin-bottom: 14px; }
.cq-intel-gl strong,
.cq-intel-risk strong,
.cq-intel-flags strong,
.cq-intel-osha strong {
    color: var(--text);
    font-size: 12px;
}
.cq-intel-flags { color: var(--danger); }

/* ── AI Coverage Banner ──────────────────────────────── */
#cq-ai-coverage-banner {
    margin-bottom: 0;
}
.cq-cov-banner-inner {
    background: linear-gradient(135deg, var(--bg-card), rgba(168, 85, 247, 0.05));
    border: 1.5px solid rgba(168, 85, 247, 0.25);
    border-radius: 14px;
    padding: 14px 18px;
    margin-bottom: 12px;
}
.cq-cov-banner-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--cq-purple);
    margin-bottom: 10px;
}
.cq-cov-banner-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.cq-cov-pill {
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid rgba(168, 85, 247, 0.3);
    background: rgba(168, 85, 247, 0.08);
    color: var(--cq-purple);
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.cq-cov-pill:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: var(--cq-purple);
}

/* ── Dark Mode — Intel ───────────────────────────────── */
body.dark-mode .cq-intel-card {
    background: linear-gradient(135deg, #1C1C1E, rgba(168, 85, 247, 0.05));
}
body.dark-mode .cq-cov-banner-inner {
    background: linear-gradient(135deg, #1C1C1E, rgba(168, 85, 247, 0.06));
}
body.dark-mode .cq-cov-pill {
    background: rgba(168, 85, 247, 0.12);
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 600px) {
    .form-grid-2,
    .form-grid-3 { grid-template-columns: 1fr; gap: 0; }

    .cq-step-track { min-width: 360px; }
    .cq-dot-inner { width: 30px; height: 30px; font-size: 12px; }
    .cq-dot-label { display: none; }
    .cq-step-track::before { top: 15px; left: 15px; right: 15px; }

    .cq-cov-label { gap: 10px; padding: 12px; }
    .cq-cov-icon { font-size: 18px; width: 26px; }
    .cq-cov-name { font-size: 13px; }
    .cq-cov-sub { display: none; }

    .cq-yn-row { flex-direction: column; align-items: flex-start; gap: 8px; }

    .cq-export-group { flex-direction: column; }
    .cq-export-btn { width: 100%; justify-content: center; }

    .cq-welcome-card { padding: 24px 16px; }
    .cq-welcome-icon { font-size: 36px; }

    .cq-step-footer { padding: 12px 16px 20px; }
}

@media (max-width: 380px) {
    .cq-dot-inner { width: 26px; height: 26px; font-size: 11px; }
    .cq-step-track::before { top: 13px; left: 13px; right: 13px; }
}