/* ═══════════════════════════════════════════
   CALCULATOR WIZARD — Guided UX Flow v2
   States: wizard | entry | results | advanced
   ═══════════════════════════════════════════ */

/* ═══ STATE: ENTRY MODE ═══
   Simplified view: just metric cards + entry bar */
body.wz-state-entry .hero,
body.wz-state-entry .controls-row,
body.wz-state-entry .advanced-toggle,
body.wz-state-entry .company-tabs-bar,
body.wz-state-entry .compare-view,
body.wz-state-entry .dashboard-side,
body.wz-state-entry .insights-section,
body.wz-state-entry .notes-section,
body.wz-state-entry .disclaimer-section { display: none !important; }
body.wz-state-entry #progress-card { display: none !important; }

body.wz-state-entry .input-card {
    border: none; background: none; padding: 0;
}
body.wz-state-entry #company-name {
    pointer-events: none; opacity: 0.6;
    font-size: 20px; font-weight: 700; text-align: center;
    border: none; background: none; padding: 8px;
}
body.wz-state-entry .dashboard {
    display: block !important; /* single column */
    grid-template-columns: unset !important;
}
body.wz-state-entry { padding-bottom: 80px; }

/* ═══ STATE: RESULTS MODE ═══
   Clean read-only view: score, category, metrics (no inputs), insights */
body.wz-state-results .hero { display: none !important; }
body.wz-state-results .controls-row { display: none !important; }
body.wz-state-results .advanced-toggle { display: none !important; }
body.wz-state-results .company-tabs-bar { display: none !important; }
body.wz-state-results .compare-view { display: none !important; }
body.wz-state-results .custom-threshold { display: none !important; }
body.wz-state-results #cat-custom { display: none !important; }
body.wz-state-results #progress-card { display: none !important; }

/* Company name: read-only, prominent */
body.wz-state-results .input-card {
    border: none; background: none; padding: 0; margin-bottom: 0;
}
body.wz-state-results #company-name {
    pointer-events: none;
    font-size: 24px; font-weight: 800; text-align: center;
    border: none; background: none; padding: 12px 8px;
    color: var(--text);
}
body.wz-state-results .ai-autofill-wrapper {
    justify-content: center;
}
body.wz-state-results .ai-autofill-btn { display: none; }

/* Metric inputs: hidden. Show only bar + status */
body.wz-state-results .metric-input-area { display: none !important; }
body.wz-state-results .metric-desc { display: none !important; }
body.wz-state-results .delete-metric-btn { display: none !important; }
body.wz-state-results .optional-metrics-section { display: none !important; }
body.wz-state-results #add-custom-btn { display: none !important; }

/* ── Inline edit mode: show inputs on results page ── */
body.wz-state-results.wz-editing .metric-input-area { display: block !important; }
body.wz-state-results.wz-editing .metric-card { padding: 14px 16px; }
/* Edit toggle button active state */
.wz-edit-toggle-btn.active {
    background: var(--primary-light, #e8f4f8);
    color: var(--primary, #2a7d9c);
    border-color: var(--primary, #2a7d9c);
}

/* Metric card compact read-only style */
body.wz-state-results .metric-card {
    padding: 12px 16px;
}
body.wz-state-results .metric-head h3 {
    font-size: 13px;
}
body.wz-state-results .metric-footer {
    margin-top: 4px;
}

/* Score panel: move to top full-width on all screens */
body.wz-state-results .dashboard {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: unset !important;
}
body.wz-state-results .dashboard-side {
    order: -1;
    width: 100%;
    max-width: 100%;
    position: static !important;
    margin-bottom: 20px;
}
body.wz-state-results .score-card {
    max-width: 600px;
    margin: 0 auto;
}
body.wz-state-results .dashboard-main {
    width: 100%;
}

/* Show insights and notes */
body.wz-state-results .insights-section,
body.wz-state-results .notes-section,
body.wz-state-results .disclaimer-section { display: block; }

/* Force insights body expanded in results (override .collapsed) */
body.wz-state-results .insights-body { display: block !important; }
body.wz-state-results .insights-toggle-btn { display: none; }

/* AI CTA button injected into insights header */
.wz-ai-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}
.wz-ai-cta-btn:hover {
    box-shadow: 0 4px 14px rgba(20,184,166,0.35);
    transform: translateY(-1px);
}

body.wz-state-results { padding-bottom: 90px; }

/* ═══ WIZARD OVERLAY ═══ */
.wz-overlay {
    min-height: calc(100vh - var(--topbar-h));
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px 60px;
    background: var(--bg);
}
.wz-container {
    width: 100%;
    max-width: 660px;
}

/* ── Progress ── */
.wz-progress {
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 36px;
}
.wz-progress-step {
    display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.wz-progress-step span {
    font-size: 10px; color: var(--text-muted); font-weight: 500;
}
.wz-progress-step.active span { color: var(--primary); font-weight: 700; }
.wz-progress-step.done span { color: var(--success); }
.wz-progress-dot {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    transition: all .3s;
}
.wz-progress-step.active .wz-progress-dot {
    border-color: var(--primary); background: var(--primary);
    color: white; box-shadow: 0 0 0 5px var(--primary-glow);
}
.wz-progress-step.done .wz-progress-dot {
    border-color: var(--success); background: var(--success); color: white;
}
.wz-progress-line {
    width: 36px; height: 2px;
    background: var(--border); margin: 0 4px; margin-bottom: 20px;
    transition: background .3s;
}
.wz-progress-line.done { background: var(--success); }

/* ── Panel ── */
.wz-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px 28px 24px;
    box-shadow: var(--shadow-lg);
}
.wz-slide-in { animation: wzSlideIn .3s ease-out; }
@keyframes wzSlideIn {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ── Step header ── */
.wz-step-header { text-align: center; margin-bottom: 20px; }
.wz-step-icon-big { font-size: 44px; margin-bottom: 10px; }
.wz-step-header h2 {
    font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 4px;
}
.wz-step-header p {
    font-size: 13px; color: var(--text-secondary); line-height: 1.6;
}

/* ── Company input ── */
.wz-input-wrap { max-width: 440px; margin: 0 auto 20px; }
.wz-company-input {
    width: 100%; padding: 15px 18px;
    font-size: 17px; font-weight: 600; font-family: var(--font);
    color: var(--text); background: var(--bg);
    border: 2px solid var(--border); border-radius: var(--radius-lg);
    text-align: center; transition: all .2s;
}
.wz-company-input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}
.wz-company-input::placeholder { color: var(--text-muted); font-weight: 400; font-size: 14px; }

/* ── Nav ── */
.wz-nav {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border);
}
.wz-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 11px 24px; border-radius: var(--radius-md);
    font-size: 14px; font-weight: 600; font-family: var(--font);
    cursor: pointer; border: none; transition: all .2s;
}
.wz-btn.primary {
    background: linear-gradient(135deg, #0d9488, #14b8a6); color: white;
}
.wz-btn.primary:hover { box-shadow: 0 4px 14px rgba(20,184,166,0.35); }
.wz-btn.primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.wz-btn.ghost {
    background: var(--bg); color: var(--text-secondary);
    border: 1px solid var(--border);
}
.wz-btn.ghost:hover { color: var(--text); border-color: var(--text-muted); }
.wz-skip-link {
    display: block; text-align: center; margin-top: 14px;
    font-size: 11px; color: var(--text-muted); background: none;
    border: none; cursor: pointer; font-family: var(--font);
}
.wz-skip-link:hover { color: var(--primary); }

/* ── Mode cards ── */
.wz-mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wz-mode-card {
    padding: 14px 12px; background: var(--bg);
    border: 2px solid var(--border); border-radius: var(--radius-lg);
    text-align: center; cursor: pointer; transition: all .2s;
}
.wz-mode-card:hover { border-color: var(--primary-light); }
.wz-mode-card.selected {
    border-color: var(--primary); background: var(--primary-bg);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.wz-mode-icon { font-size: 26px; margin-bottom: 4px; }
.wz-mode-name { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.wz-mode-desc { font-size: 10px; color: var(--text-secondary); line-height: 1.4; }

/* ── Template pills ── */
.wz-template-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.wz-tmpl-card {
    display: flex; align-items: center; gap: 6px;
    padding: 9px 14px; background: var(--bg);
    border: 2px solid var(--border); border-radius: var(--radius-pill);
    cursor: pointer; transition: all .2s;
    font-size: 12px; font-weight: 500; color: var(--text-secondary);
}
.wz-tmpl-card:hover { border-color: var(--primary-light); color: var(--text); }
.wz-tmpl-card.selected {
    border-color: var(--primary); background: var(--primary-bg);
    color: var(--primary); font-weight: 600;
}

/* ── Method cards ── */
.wz-method-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wz-method-card {
    padding: 22px 14px; background: var(--bg);
    border: 2px solid var(--border); border-radius: var(--radius-lg);
    text-align: center; cursor: pointer; transition: all .2s;
    display: flex; flex-direction: column; align-items: center;
}
.wz-method-card:hover { border-color: var(--primary-light); transform: translateY(-2px); }
.wz-method-card.selected {
    border-color: var(--primary); background: var(--primary-bg);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.wz-method-icon { font-size: 32px; margin-bottom: 8px; }
.wz-method-name { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.wz-method-desc { font-size: 10px; color: var(--text-secondary); line-height: 1.4; }

/* ═══ PROCESSING ═══ */
.wz-processing {
    position: fixed; inset: 0; background: var(--bg);
    z-index: 10000; display: flex; align-items: center; justify-content: center;
    animation: fadeIn .3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.wz-proc-content { text-align: center; max-width: 400px; padding: 40px; }
.wz-proc-spinner {
    width: 52px; height: 52px;
    border: 4px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.wz-proc-content h2 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.wz-proc-content p { font-size: 12px; color: var(--text-secondary); margin-bottom: 20px; min-height: 18px; }
.wz-proc-bar { width: 100%; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.wz-proc-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 3px; transition: width .6s ease;
}

/* ═══ ENTRY BAR (sticky bottom during data entry) ═══ */
.wz-entry-bar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}
.wz-entry-bar-inner {
    max-width: 900px; margin: 0 auto;
    padding: 12px 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.wz-entry-hint {
    font-size: 12px; color: var(--text-secondary);
}

/* ═══ ACTION BAR (sticky bottom in results) ═══ */
.wz-action-bar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.12);
    transform: translateY(100%); transition: transform .35s ease;
}
.wz-action-bar.visible { transform: translateY(0); }
.wz-action-bar-inner {
    max-width: 900px; margin: 0 auto;
    padding: 16px 24px;
    display: flex; align-items: center; gap: 16px;
}
.wz-action-label {
    font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap;
}
.wz-action-btns {
    display: flex; gap: 8px; flex-wrap: wrap; flex: 1; justify-content: flex-end;
}
.wz-action-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 18px; background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    font-size: 13px; font-weight: 600; color: var(--text-secondary);
    cursor: pointer; font-family: var(--font); transition: all .2s;
}
.wz-action-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--primary-light); }
.wz-action-btn.primary { background: var(--primary); color: white; border-color: var(--primary); }
.wz-action-btn.primary:hover { background: var(--primary-hover); }

/* ═══ STATE: ADVANCED (full calculator) ═══ */
body.wz-state-advanced .wz-ai-cta-btn { display: none !important; }

/* ── Highlight animation ── */
.wz-highlight { animation: wzPulse 1.5s ease; }
@keyframes wzPulse {
    0%, 100% { box-shadow: var(--shadow-xs); }
    50% { box-shadow: 0 0 0 8px var(--primary-glow), var(--shadow-lg); }
}

/* ═══ STAGE 1 SHORTCUTS ═══ */
.wz-shortcuts {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: wrap;
}
.wz-shortcut-btn {
    padding: 9px 18px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .2s;
}
.wz-shortcut-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

/* ═══ STAGE 3: 2-TAB LAYOUT ═══ */

/* Tab bar */
.wz-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 18px;
}
.wz-tab {
    padding: 10px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    color: var(--text-muted);
    cursor: pointer;
    transition: all .2s;
}
.wz-tab:hover { color: var(--text); }
.wz-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Tab panels */
.wz-tab-panel { display: none; }
.wz-tab-panel.active { display: block; }

/* AI option boxes */
.wz-ai-option-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 4px;
}
.wz-ai-option-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}
.wz-ai-option-hint {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 6px;
}
.wz-ai-or {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin: 10px 0;
}

/* How-to instructions */
.wz-ai-howto {
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 12px;
}
.wz-ai-howto-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 6px;
}
.wz-ai-howto-list {
    margin: 0;
    padding-right: 18px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.9;
}

/* Prompt textarea (readonly) */
.wz-prompt-textarea {
    width: 100%;
    min-height: 120px;
    max-height: 200px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    direction: ltr;
    text-align: left;
    overflow-y: auto;
    box-sizing: border-box;
}
.wz-prompt-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 14px;
}
.wz-prompt-action-btn {
    flex: 1;
    justify-content: center;
    font-size: 12px !important;
    padding: 8px 10px !important;
}

/* Paste divider */
.wz-paste-divider {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin: 4px 0 10px;
}

/* Paste textarea */
.wz-paste-textarea {
    width: 100%;
    min-height: 90px;
    max-height: 180px;
    resize: vertical;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    direction: ltr;
    text-align: left;
    box-sizing: border-box;
    transition: border-color .2s;
}
.wz-paste-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.wz-paste-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.wz-paste-action-btn {
    flex: 1;
    justify-content: center;
    font-size: 13px !important;
    padding: 10px 12px !important;
}
.wz-ai-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Success feedback */
.wz-ai-success {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    margin-top: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #10b981;
}
.wz-ai-success-icon { font-size: 18px; }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 640px) {
    .wz-overlay { padding: 20px 12px 40px; }
    .wz-panel { padding: 22px 16px 18px; }
    .wz-step-header h2 { font-size: 17px; }
    .wz-company-input { font-size: 15px; }
    .wz-mode-grid { grid-template-columns: 1fr; }
    .wz-method-grid { grid-template-columns: 1fr; }
    .wz-progress-step span { display: none; }
    .wz-progress-dot { width: 26px; height: 26px; font-size: 10px; }
    .wz-progress-line { width: 18px; margin-bottom: 2px; }
    .wz-action-bar-inner { flex-direction: column; gap: 8px; }
    .wz-action-label { display: none; }
    .wz-action-btns { justify-content: center; }
    .wz-entry-bar-inner { flex-direction: column; text-align: center; }
    .wz-shortcuts { flex-direction: column; }
    .wz-prompt-actions, .wz-paste-actions { flex-direction: column; }
}
