/* ============================================
   URBot Onboarding Wizard — Personal Shopper
   Dark theme matching builder aesthetic
   ============================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg-primary, #0a0a1a);
    color: var(--text-primary, #e2e8f0);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---- Header ---- */
.ob-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: rgba(15, 15, 35, 0.95);
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    position: sticky;
    top: 0;
    z-index: 200;
}
.ob-logo {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    letter-spacing: 0.05em;
}
.ob-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    flex: 1;
}
.ob-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ob-nav-link {
    color: var(--text-muted, #94a3b8);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}
.ob-nav-link:hover { color: #fff; }
.ob-login-btn {
    color: #c4b5fd;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 5px 14px;
    border: 1px solid rgba(196, 181, 253, 0.3);
    border-radius: 16px;
}
.ob-login-btn:hover {
    background: rgba(196, 181, 253, 0.1);
}

/* ---- Main Container ---- */
.onboarding-container {
    display: flex;
    height: calc(100vh - 49px - 52px); /* header + progress bar */
    overflow: hidden;
    transition: background-color 0.8s ease;
}

/* ---- Left Panel: Chat ---- */
.onboarding-chat {
    width: 40%;
    min-width: 340px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary, rgba(15, 15, 40, 0.85));
    border-right: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

/* Salesman header */
.salesman-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
    background: rgba(10, 10, 30, 0.6);
}
.salesman-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--accent-primary, #10b981);
    background: rgba(16, 185, 129, 0.1);
    object-fit: cover;
}
.salesman-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.salesman-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary, #fff);
}
.salesman-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary, #10b981);
    box-shadow: 0 0 6px var(--accent-glow, rgba(16, 185, 129, 0.5));
    animation: statusPulse 2s ease-in-out infinite;
}
@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

/* Chat bubbles */
.chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: bubbleFadeIn 0.3s ease-out;
    word-wrap: break-word;
}
@keyframes bubbleFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-bubble.salesman {
    align-self: flex-start;
    background: var(--bg-card, rgba(20, 20, 50, 0.85));
    color: var(--text-secondary, #e2e8f0);
    border-bottom-left-radius: 4px;
    border-left: 3px solid var(--accent-primary, #10b981);
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--accent-primary, #10b981);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
    background: var(--bg-card, rgba(20, 20, 50, 0.85));
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    border-left: 3px solid var(--accent-primary, #10b981);
}
.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted, #94a3b8);
    animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Chat input area */
.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
    background: rgba(10, 10, 30, 0.4);
    min-height: 80px;
}

/* Option buttons */
.chat-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.chat-option-btn {
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary, #e2e8f0);
    background: var(--bg-card, rgba(20, 20, 50, 0.85));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    text-transform: capitalize;
    line-height: 1.3;
}
.chat-option-btn:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--accent-primary, #10b981);
    color: var(--text-primary, #fff);
    box-shadow: 0 0 12px var(--accent-glow, rgba(16, 185, 129, 0.2));
    transform: translateY(-1px);
}
.chat-option-btn.selected {
    background: var(--accent-primary, #10b981);
    color: #fff;
    border-color: var(--accent-primary, #10b981);
}
.chat-option-btn.selected::after {
    content: ' \2713';
}

/* Multi-select info text */
.chat-multi-hint {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    text-align: center;
    margin-bottom: 8px;
}
.chat-multi-submit {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: var(--accent-primary, #10b981);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.chat-multi-submit:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}
.chat-multi-submit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ---- Right Panel: Preview ---- */
.onboarding-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px;
    background: var(--gradient-hero, linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 40%, #0a1a2e 100%));
    transition: background 0.8s ease, color 0.5s ease;
    position: relative;
}

.preview-theme-morph {
    flex: 1;
    transition: background-color 0.8s ease, color 0.5s ease;
}

.preview-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin-bottom: 4px;
}
.preview-subtitle {
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 20px;
}

/* Bot card grid */
.preview-bots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.preview-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted, #94a3b8);
}
.preview-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}
.preview-empty p {
    font-size: 14px;
    max-width: 280px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Individual bot reveal card */
.bot-reveal-card {
    background: var(--bg-card, rgba(15, 15, 40, 0.85));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    animation: botReveal 0.5s ease-out both;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.bot-reveal-card:hover {
    border-color: var(--accent-primary, #10b981);
    box-shadow: 0 4px 20px var(--accent-glow, rgba(16, 185, 129, 0.2));
    transform: translateY(-2px);
}
.bot-reveal-card:nth-child(1) { animation-delay: 0s; }
.bot-reveal-card:nth-child(2) { animation-delay: 0.1s; }
.bot-reveal-card:nth-child(3) { animation-delay: 0.2s; }
.bot-reveal-card:nth-child(4) { animation-delay: 0.15s; }
.bot-reveal-card:nth-child(5) { animation-delay: 0.25s; }
.bot-reveal-card:nth-child(6) { animation-delay: 0.3s; }

@keyframes botReveal {
    from {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.bot-reveal-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin: 0 auto 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--border-color, rgba(255, 255, 255, 0.1));
    object-fit: cover;
}
.bot-reveal-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin-bottom: 4px;
    text-transform: capitalize;
}
.bot-reveal-score {
    font-size: 20px;
    font-weight: 800;
    color: var(--accent-primary, #10b981);
    margin-bottom: 4px;
}
.bot-reveal-reason {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    line-height: 1.35;
}
.bot-reveal-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: var(--accent-primary, #10b981);
    padding: 2px 6px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Theme label at bottom of preview */
.preview-theme-label {
    position: absolute;
    bottom: 16px;
    left: 24px;
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: opacity 0.5s ease;
}

/* Completion panel */
.preview-complete {
    text-align: center;
    padding: 40px 20px;
}
.complete-heading {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary, #fff);
    margin-bottom: 8px;
    animation: completePulse 2s ease-in-out infinite;
}
@keyframes completePulse {
    0%, 100% { text-shadow: 0 0 0 transparent; }
    50% { text-shadow: 0 0 20px var(--accent-glow, rgba(16, 185, 129, 0.4)); }
}
.complete-subheading {
    font-size: 15px;
    color: var(--text-secondary, #e2e8f0);
    margin-bottom: 24px;
}
.complete-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.complete-btn {
    display: inline-block;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s ease;
}
.complete-btn-primary {
    background: var(--accent-primary, #10b981);
    color: #fff;
}
.complete-btn-primary:hover {
    filter: brightness(1.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--accent-glow, rgba(16, 185, 129, 0.4));
}
.complete-btn-secondary {
    background: transparent;
    color: var(--text-secondary, #e2e8f0);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}
.complete-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-muted, #94a3b8);
}

/* ---- Bottom Progress Bar ---- */
.onboarding-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 12px 20px;
    background: rgba(15, 15, 35, 0.95);
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    height: 52px;
}
.progress-step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    opacity: 0.4;
    transition: opacity 0.4s ease;
}
.progress-step.active {
    opacity: 1;
}
.progress-step.completed {
    opacity: 0.8;
}
.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted, #94a3b8);
    border: 2px solid var(--text-muted, #94a3b8);
    transition: all 0.3s ease;
}
.progress-step.active .progress-dot {
    background: var(--accent-primary, #10b981);
    border-color: var(--accent-primary, #10b981);
    box-shadow: 0 0 8px var(--accent-glow, rgba(16, 185, 129, 0.4));
}
.progress-step.completed .progress-dot {
    background: var(--accent-primary, #10b981);
    border-color: var(--accent-primary, #10b981);
}
.progress-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.progress-step.active .progress-label {
    color: var(--text-primary, #fff);
}
.progress-connector {
    width: 40px;
    height: 2px;
    background: var(--border-color, rgba(255, 255, 255, 0.1));
    transition: background 0.4s ease;
}
.progress-connector.filled {
    background: var(--accent-primary, #10b981);
}

/* ---- Responsive: Stack on mobile ---- */
@media (max-width: 768px) {
    .onboarding-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 49px - 52px);
    }
    .onboarding-chat {
        width: 100%;
        min-width: unset;
        min-height: 55vh;
        max-height: 60vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    }
    .onboarding-preview {
        min-height: 40vh;
    }
    .chat-options {
        grid-template-columns: 1fr;
    }
    .preview-bots {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }
    .ob-title {
        display: none;
    }
    .progress-label {
        display: none;
    }
    .progress-connector {
        width: 24px;
    }
    .complete-actions {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .salesman-header {
        padding: 12px 16px;
    }
    .salesman-avatar {
        width: 40px;
        height: 40px;
    }
    .chat-messages {
        padding: 14px;
    }
    .chat-input-area {
        padding: 12px 14px;
    }
    .chat-bubble {
        max-width: 92%;
        font-size: 13px;
    }
    .preview-bots {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ---- Theme transition support ---- */
html.theme-transitioning .onboarding-preview,
html.theme-transitioning .onboarding-chat,
html.theme-transitioning .ob-header,
html.theme-transitioning .onboarding-progress,
html.theme-transitioning .chat-bubble,
html.theme-transitioning .chat-option-btn,
html.theme-transitioning .bot-reveal-card {
    transition:
        background-color 0.6s ease,
        color 0.4s ease,
        border-color 0.5s ease,
        box-shadow 0.5s ease !important;
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .chat-bubble,
    .bot-reveal-card,
    .typing-dot,
    .status-dot,
    .complete-heading {
        animation: none !important;
    }
    .chat-option-btn:hover,
    .bot-reveal-card:hover,
    .complete-btn:hover {
        transform: none !important;
    }
}
