/* ========================================
   Workflow Stepper - 5-Phase Navigation
   Responsive, accessible, Navy+Orange theme
   ======================================== */

/* Container */
.workflow-stepper-container {
    container-type: inline-size;
    width: 100%;
    background: var(--bg-card, #fff);
    border-bottom: 1px solid var(--border-color, #E2E8F0);
    position: relative;
    z-index: 10;
}

/* ---- Desktop Stepper (nav) ---- */
.workflow-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    gap: 0;
    max-width: 800px;
    margin: 0 auto;
}

/* Phase Node */
.wf-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-md, 8px);
    transition: transform 200ms ease-in-out, opacity 200ms ease-in-out;
    position: relative;
    min-width: 80px;
    -webkit-tap-highlight-color: transparent;
}

.wf-node:hover {
    transform: scale(1.05);
}

.wf-node:focus-visible {
    outline: 2px solid var(--color-orange, #E67E22);
    outline-offset: 4px;
    border-radius: var(--radius-md, 8px);
}

/* Node Circle */
.wf-node-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover, #F1F5F9);
    border: 2px solid var(--border-color, #E2E8F0);
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.wf-node-icon {
    display: flex;
    color: var(--text-secondary, #64748B);
    transition: color 200ms ease, opacity 200ms ease;
}

.wf-node-icon svg {
    width: 18px;
    height: 18px;
}

.wf-node-check {
    display: none;
    color: #fff;
}

.wf-node-check svg {
    width: 14px;
    height: 14px;
}

.wf-node-number {
    display: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #64748B);
}

/* Labels */
.wf-node-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #64748B);
    transition: color 200ms ease, font-weight 200ms ease;
    white-space: nowrap;
}

.wf-node-label-short {
    display: none;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary, #64748B);
}

/* ---- Active State ---- */
.wf-node.active .wf-node-circle {
    background: var(--color-orange, #E67E22);
    border-color: var(--color-orange, #E67E22);
    box-shadow: 0 0 0 4px rgba(230, 126, 34, 0.2), 0 2px 8px rgba(230, 126, 34, 0.3);
    transform: scale(1.1);
}

.wf-node.active .wf-node-icon {
    color: #fff;
}

.wf-node.active .wf-node-label,
.wf-node.active .wf-node-label-short {
    color: var(--color-orange, #E67E22);
    font-weight: 700;
}

/* ---- Completed State ---- */
.wf-node.completed .wf-node-circle {
    background: var(--color-navy, #1C2E4A);
    border-color: var(--color-navy, #1C2E4A);
}

.wf-node.completed .wf-node-icon {
    display: none;
}

.wf-node.completed .wf-node-check {
    display: flex;
}

.wf-node.completed .wf-node-label,
.wf-node.completed .wf-node-label-short {
    color: var(--color-navy, #1C2E4A);
    font-weight: 600;
}

/* ---- Past State (before current, not completed) ---- */
.wf-node.past .wf-node-circle {
    background: var(--bg-hover, #F1F5F9);
    border-color: var(--color-navy-light, #2A4365);
}

.wf-node.past .wf-node-icon {
    color: var(--color-navy-light, #2A4365);
}

/* ---- Pulse Animation ---- */
.wf-node.pulse .wf-node-circle {
    animation: wf-pulse 2s ease-in-out;
}

@keyframes wf-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(230, 126, 34, 0); }
    25% { box-shadow: 0 0 0 8px rgba(230, 126, 34, 0.3); }
    50% { box-shadow: 0 0 0 4px rgba(230, 126, 34, 0.15); }
    75% { box-shadow: 0 0 0 8px rgba(230, 126, 34, 0.3); }
}

/* ---- Connector Lines ---- */
.wf-connector {
    flex: 1;
    height: 2px;
    background: var(--border-color, #E2E8F0);
    position: relative;
    min-width: 24px;
    max-width: 60px;
}

.wf-connector-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background: var(--color-navy, #1C2E4A);
    border-radius: 1px;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.wf-connector-fill.filled {
    width: 100%;
}

/* ---- Mobile Indicator ---- */
.wf-mobile-indicator {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    gap: 8px;
}

.wf-mobile-prev,
.wf-mobile-next {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-full, 9999px);
    color: var(--text-secondary, #64748B);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    transition: background 150ms ease, color 150ms ease;
    -webkit-tap-highlight-color: transparent;
}

.wf-mobile-prev:hover:not(:disabled),
.wf-mobile-next:hover:not(:disabled) {
    background: var(--bg-hover, #F1F5F9);
    color: var(--color-navy, #1C2E4A);
}

.wf-mobile-prev:disabled,
.wf-mobile-next:disabled {
    opacity: 0.3;
    cursor: default;
}

.wf-mobile-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.wf-mobile-step {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-orange, #E67E22);
    letter-spacing: 0.5px;
}

.wf-mobile-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #1E293B);
}

.wf-mobile-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.wf-mobile-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color, #E2E8F0);
    transition: all 200ms ease;
    cursor: pointer;
}

.wf-mobile-dot.active {
    background: var(--color-orange, #E67E22);
    transform: scale(1.3);
    box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.2);
}

.wf-mobile-dot.completed {
    background: var(--color-navy, #1C2E4A);
}

/* ---- Phase Panels ---- */
.phase-panel {
    display: none;
    width: 100%;
    min-height: 0;
    flex: 1;
}

.phase-panel.active {
    display: flex;
    flex-direction: column;
    animation: wf-fadeIn 250ms ease-out;
}

@keyframes wf-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Phase panels within main-content should fill space */
.main-content .phase-panel.active {
    flex: 1;
}

/* ---- Phase: Bot (Susi as main view) ---- */
.phase-bot-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding: 24px;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

.phase-bot-chat {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-card, #fff);
    border-radius: var(--radius-lg, 12px);
    border: 1px solid var(--border-color, #E2E8F0);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    min-height: 400px;
    max-height: calc(100vh - 200px);
}

.phase-bot-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #E2E8F0);
    background: linear-gradient(135deg, var(--color-navy, #1C2E4A) 0%, var(--color-navy-light, #2A4365) 100%);
    color: #fff;
}

.phase-bot-header img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
}

.phase-bot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.phase-bot-header span {
    font-size: 12px;
    opacity: 0.8;
}

.phase-bot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.phase-bot-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color, #E2E8F0);
    background: var(--bg-primary, #F8FAFC);
}

.phase-bot-input textarea {
    flex: 1;
    border: 1px solid var(--border-color, #E2E8F0);
    border-radius: var(--radius-md, 8px);
    padding: 12px var(--space-md, 16px);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    min-height: 48px;
    max-height: 160px;
    background: var(--bg-card, #fff);
}

.phase-bot-input textarea:focus {
    outline: none;
    border-color: var(--color-orange, #E67E22);
    box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.1);
}

.phase-bot-send {
    background: var(--color-orange, #E67E22);
    color: #fff;
    border: none;
    border-radius: var(--radius-md, 8px);
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease;
}

.phase-bot-send:hover {
    background: var(--color-orange-hover, #D35400);
}

/* Quick action cards within bot phase */
.phase-bot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color, #E2E8F0);
}

.phase-bot-action {
    background: var(--bg-primary, #F8FAFC);
    border: 1px solid var(--border-color, #E2E8F0);
    border-radius: var(--radius-full, 9999px);
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text-primary, #1E293B);
    cursor: pointer;
    transition: all 150ms ease;
}

.phase-bot-action:hover {
    border-color: var(--color-orange, #E67E22);
    color: var(--color-orange, #E67E22);
    background: var(--color-orange-light, rgba(230, 126, 34, 0.15));
}

/* ---- Phase: Transform (inline panel) ---- */
.phase-transform-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 24px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    gap: 20px;
}

.phase-transform-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.phase-transform-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary, #1E293B);
}

/* ---- Phase: Export ---- */
.phase-export-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 24px;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
    gap: 20px;
}

.phase-export-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary, #1E293B);
    margin-bottom: 4px;
}

.phase-export-header p {
    margin: 0;
    color: var(--text-secondary, #64748B);
    font-size: 14px;
}

.export-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.export-option-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #E2E8F0);
    border-radius: var(--radius-lg, 12px);
    padding: 20px;
    cursor: pointer;
    transition: all 200ms ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

.export-option-card:hover {
    border-color: var(--color-orange, #E67E22);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.export-option-card:active {
    transform: translateY(0);
}

.export-option-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md, 8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.export-option-icon.pdf { background: #FEE2E2; color: #DC2626; }
.export-option-icon.md { background: #E0E7FF; color: #4F46E5; }
.export-option-icon.report { background: #D1FAE5; color: #059669; }
.export-option-icon.ai { background: #FEF3C7; color: #D97706; }
.export-option-icon.copy { background: #F1F5F9; color: #475569; }

.export-option-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #1E293B);
}

.export-option-desc {
    font-size: 13px;
    color: var(--text-secondary, #64748B);
    line-height: 1.4;
}

/* ---- Prompt Preview in Export ---- */
.export-preview {
    background: var(--bg-primary, #F8FAFC);
    border: 1px solid var(--border-color, #E2E8F0);
    border-radius: var(--radius-lg, 12px);
    padding: 20px;
}

.export-preview-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #94A3B8);
    margin-bottom: 8px;
}

.export-preview-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text-primary, #1E293B);
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.6;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Tablet: icons + short labels */
@container (max-width: 700px) {
    .workflow-stepper {
        padding: 10px 16px;
    }

    .wf-node {
        min-width: 60px;
        padding: 4px 4px;
    }

    .wf-node-label {
        display: none;
    }

    .wf-node-label-short {
        display: block;
    }

    .wf-node-circle {
        width: 38px;
        height: 38px;
    }

    .wf-node-icon svg {
        width: 16px;
        height: 16px;
    }

    .wf-connector {
        min-width: 16px;
    }
}

/* Mobile: hide desktop stepper, show compact indicator */
@media (max-width: 599px) {
    .workflow-stepper {
        display: none;
    }

    .wf-mobile-indicator {
        display: flex;
    }

    .phase-bot-content,
    .phase-transform-content,
    .phase-export-content {
        padding: 16px;
    }

    .export-options-grid {
        grid-template-columns: 1fr;
    }

    .phase-bot-chat {
        max-height: calc(100vh - 160px);
        min-height: 300px;
    }
}

/* Large desktop: more spacing */
@media (min-width: 1200px) {
    .workflow-stepper {
        max-width: 900px;
        padding: 14px 32px;
    }

    .wf-node {
        min-width: 100px;
    }

    .wf-connector {
        max-width: 80px;
    }
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    .wf-node,
    .wf-node-circle,
    .wf-connector-fill,
    .wf-node-label,
    .wf-mobile-dot,
    .phase-panel.active,
    .export-option-card {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
