/* ==========================================
   CHATBOT WIDGET STYLES
   ========================================== */

/* Toggle Button */
.chatbot-toggle {
    position: fixed;
    bottom: var(--space-8);
    right: var(--space-8);
    z-index: var(--z-sticky);
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(0, 227, 170, 0.25);
    cursor: pointer;
    background: rgba(0, 0, 0, 0.95);
    color: #fff;
    box-shadow: 0 4px 20px rgba(0, 227, 170, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

.chatbot-toggle:hover {
    transform: scale(1.08);
    border-color: rgba(0, 227, 170, 0.5);
    box-shadow: 0 6px 28px rgba(0, 227, 170, 0.4);
}

.chatbot-toggle svg {
    width: 26px;
    height: 26px;
    transition: transform var(--transition-base);
}

/* Bot face element — animated robot icon */
.chatbot-bot-face {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-bot-face svg {
    width: 30px;
    height: 32px;
}

.chatbot-bot-face .bot-eye {
    filter: drop-shadow(0 0 3px rgba(0, 227, 170, 0.3));
}

.chatbot-bot-face .chatbot-bot-pupil {
    filter: drop-shadow(0 0 4px rgba(0, 227, 170, 0.6));
    animation: chatbot-eye-glow 2.5s ease-in-out infinite;
    transition: transform 0.08s ease-out;
}

.chatbot-bot-face .bot-antenna-tip {
    filter: drop-shadow(0 0 3px rgba(0, 227, 170, 0.5));
    animation: chatbot-eye-glow 2.5s ease-in-out infinite;
}

@keyframes chatbot-eye-glow {
    0%, 100% {
        filter: drop-shadow(0 0 3px rgba(0, 227, 170, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 8px rgba(0, 227, 170, 0.9));
    }
}

/* Icon visibility — hide chat icon (replaced by bot face) */
.chatbot-icon-chat {
    display: none;
}

/* Hide bot face when panel is open */
.chatbot-toggle[aria-expanded="true"] .chatbot-bot-face {
    display: none;
}

/* Panel-open state: brighter border */
.chatbot-toggle[aria-expanded="true"] {
    border-color: rgba(0, 227, 170, 0.4);
}

.chatbot-toggle[aria-expanded="false"] .chatbot-icon-close,
.chatbot-toggle:not([aria-expanded]) .chatbot-icon-close {
    display: none;
}

.chatbot-toggle[aria-expanded="true"] .chatbot-icon-close {
    display: block;
}

/* Shift scroll-to-top button up to avoid overlapping the chatbot toggle */
#scrollToTop {
    bottom: calc(var(--space-8) + 64px) !important;
}

/* Chat Panel */
.chatbot-panel {
    position: fixed;
    bottom: calc(var(--space-8) + 56px + var(--space-4));
    right: var(--space-8);
    z-index: var(--z-sticky);
    width: 380px;
    max-height: 520px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-2xl);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: none;
    transition: opacity var(--transition-base), transform var(--transition-base);
}

.chatbot-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Panel Header */
.chatbot-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.chatbot-header-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--color-primary-400);
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 0 6px rgba(0, 227, 170, 0.6);
    animation: chatbot-orb-glow 2.5s ease-in-out infinite;
}

.chatbot-header-dot::before,
.chatbot-header-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--color-primary-400);
    animation: chatbot-orb-pulse 2.5s ease-out infinite;
}

.chatbot-header-dot::after {
    animation-delay: 1.25s;
}

.chatbot-header-dot.is-streaming {
    animation-duration: 1s;
}

.chatbot-header-dot.is-streaming::before,
.chatbot-header-dot.is-streaming::after {
    animation-duration: 1s;
}

.chatbot-header-dot.is-streaming::after {
    animation-delay: 0.5s;
}

@keyframes chatbot-orb-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

@keyframes chatbot-orb-glow {
    0%, 100% {
        box-shadow: 0 0 6px rgba(0, 227, 170, 0.6);
    }
    50% {
        box-shadow: 0 0 12px rgba(0, 227, 170, 0.9);
    }
}

.chatbot-header-title {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0;
}

.chatbot-header-subtitle {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.chatbot-header-beta {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--color-primary-400);
    background: rgba(0, 227, 170, 0.1);
    border: 1px solid var(--border-subtle);
    padding: 0.1em 0.5em;
    border-radius: var(--radius-full);
    margin-left: auto;
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-height: 0;
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: var(--radius-full);
}

/* Message Bubbles */
.chatbot-msg {
    max-width: 85%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-xl);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chatbot-msg a {
    color: var(--color-primary-400);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chatbot-msg a:hover {
    color: var(--color-primary-300);
}

.chatbot-msg code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: rgba(0, 227, 170, 0.1);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
}

.chatbot-msg-user {
    align-self: flex-end;
    background: rgba(0, 227, 170, 0.15);
    border: 1px solid var(--border-subtle);
}

.chatbot-msg-assistant {
    align-self: flex-start;
    background: var(--bg-tertiary);
}

/* Typing Indicator */
.chatbot-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border-radius: var(--radius-xl);
}

.chatbot-typing span {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--text-tertiary);
    animation: chatbot-bounce 1.4s infinite ease-in-out both;
}

.chatbot-typing span:nth-child(1) { animation-delay: 0s; }
.chatbot-typing span:nth-child(2) { animation-delay: 0.16s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes chatbot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.chatbot-input-area {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.chatbot-footer {
    text-align: center;
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    padding: var(--space-1) var(--space-4);
    flex-shrink: 0;
}

.chatbot-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.chatbot-footer a:hover {
    color: var(--text-primary);
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
    min-height: 38px;
    resize: none;
}

.chatbot-input::placeholder {
    color: var(--text-muted);
}

.chatbot-input:focus {
    border-color: var(--color-primary-500);
}

.chatbot-send {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-lg);
    border: none;
    background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-600));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity var(--transition-fast);
}

.chatbot-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chatbot-send svg {
    width: 16px;
    height: 16px;
}

/* Resume Screen */
.chatbot-resume-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: var(--space-6) var(--space-5);
    gap: var(--space-4);
}

.chatbot-resume-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: rgba(0, 227, 170, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary-400);
}

.chatbot-resume-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0;
    text-align: center;
}

.chatbot-resume-btn {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: opacity var(--transition-fast), background var(--transition-fast);
    border: none;
}

.chatbot-resume-btn-continue {
    background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-600));
    color: #fff;
}

.chatbot-resume-btn-continue:hover {
    opacity: 0.9;
}

.chatbot-resume-btn-continue:active {
    opacity: 0.8;
}

.chatbot-resume-btn-new {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.chatbot-resume-btn-new:hover {
    background: var(--bg-tertiary);
}

.chatbot-resume-btn-new:active {
    background: var(--bg-primary);
}

/* Quick Action Chips */
.chatbot-chips {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: 0 var(--space-4) var(--space-3);
}

.chatbot-chip {
    background: transparent;
    border: 1px solid var(--color-primary-400);
    color: var(--color-primary-400);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
    text-align: center;
}

.chatbot-chip:hover {
    background: var(--color-primary-400);
    color: #fff;
    box-shadow: 0 0 10px rgba(0, 227, 170, 0.35);
}

[data-theme="light"] .chatbot-chip {
    color: var(--color-primary-700);
    border-color: var(--color-primary-700);
}

[data-theme="light"] .chatbot-chip:hover {
    background: var(--color-primary-700);
    color: #fff;
}

/* Responsive */
@media (max-width: 768px) {
    .chatbot-panel {
        width: calc(100vw - 2rem);
        max-height: 60vh;
        right: 1rem;
        bottom: calc(var(--space-8) + 56px + var(--space-3));
    }
}

@media (max-width: 480px) {
    .chatbot-toggle {
        width: 50px;
        height: 50px;
    }

    .chatbot-toggle svg {
        width: 22px;
        height: 22px;
    }

    .chatbot-bot-face svg {
        width: 26px;
        height: 28px;
    }

    .chatbot-panel {
        width: calc(100vw - 1rem);
        right: 0.5rem;
        bottom: calc(var(--space-8) + 50px + var(--space-3));
    }

    #scrollToTop {
        bottom: calc(var(--space-4) + 58px) !important;
    }
}
