/* ========================================
   Chatbot Styles – Portfolio Antonio Saldaña
   Premium glassmorphism widget
   ======================================== */

/* ── Toggle Button ── */
.chatbot-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 4px 20px rgba(99, 102, 241, 0.45),
        0 0 40px rgba(139, 92, 246, 0.15);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
    overflow: visible;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow:
        0 6px 28px rgba(99, 102, 241, 0.55),
        0 0 50px rgba(139, 92, 246, 0.2);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

/* Icon transitions */
.chatbot-toggle-icon {
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chatbot-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.chatbot-toggle.active .chatbot-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.chatbot-toggle.active .chatbot-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Pulse animation */
.chatbot-toggle-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    opacity: 0;
    animation: chatbot-pulse 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    pointer-events: none;
}

.chatbot-toggle.active .chatbot-toggle-pulse {
    animation: none;
    opacity: 0;
}

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

/* ── Chat Panel ── */
.chatbot-panel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 400px;
    max-height: 560px;
    border-radius: 20px;
    background: rgba(15, 15, 35, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(99, 102, 241, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.35s;
}

.chatbot-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ── Header ── */
.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.1));
    border-bottom: 1px solid rgba(99, 102, 241, 0.15);
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    position: relative;
    flex-shrink: 0;
}

.chatbot-status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid rgba(15, 15, 35, 0.92);
}

.chatbot-title {
    color: #f1f5f9;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    font-family: 'Inter', sans-serif;
}

.chatbot-subtitle {
    color: rgba(148, 163, 184, 0.8);
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
}

.chatbot-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(148, 163, 184, 0.8);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #f1f5f9;
}

/* ── Messages Area ── */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 250px;
    max-height: 340px;
    scroll-behavior: smooth;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 2px;
}

/* ── Message Bubbles ── */
.chatbot-message {
    display: flex;
    gap: 8px;
    animation: chatbot-msg-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes chatbot-msg-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message-user {
    justify-content: flex-end;
}

.chatbot-message-user .chatbot-bubble {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
    max-width: 80%;
}

.chatbot-message-bot .chatbot-bubble {
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 16px 16px 16px 4px;
    max-width: 85%;
}

.chatbot-bubble {
    padding: 10px 14px;
    font-size: 0.85rem;
    line-height: 1.55;
    font-family: 'Inter', sans-serif;
    word-wrap: break-word;
}

.chatbot-bubble strong {
    color: #a78bfa;
}

.chatbot-message-user .chatbot-bubble strong {
    color: #e2e8f0;
}

.chatbot-bubble a {
    color: #818cf8;
    text-decoration: underline;
    text-decoration-color: rgba(129, 140, 248, 0.3);
    transition: text-decoration-color 0.2s;
}

.chatbot-bubble a:hover {
    text-decoration-color: #818cf8;
}

.chatbot-bot-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #fff;
    margin-top: 2px;
}

/* ── Typing Indicator ── */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 18px !important;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #8b5cf6;
    opacity: 0.5;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Suggestions ── */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px;
    padding-bottom: 8px;
}

.chatbot-chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    background: rgba(99, 102, 241, 0.08);
    color: #a5b4fc;
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.chatbot-chip:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.5);
    color: #c7d2fe;
    transform: translateY(-1px);
}

/* ── Input Area ── */
.chatbot-input-area {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    gap: 8px;
    border-top: 1px solid rgba(99, 102, 241, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

.chatbot-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    background: rgba(255, 255, 255, 0.04);
    color: #e2e8f0;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.25s, background 0.25s;
}

.chatbot-input::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

.chatbot-input:focus {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(255, 255, 255, 0.06);
}

.chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.chatbot-send:active {
    transform: scale(0.95);
}

/* ── Light Theme ── */
[data-theme="light"] .chatbot-panel {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(99, 102, 241, 0.15);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.12),
        0 0 30px rgba(99, 102, 241, 0.06);
}

[data-theme="light"] .chatbot-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.05));
    border-bottom-color: rgba(99, 102, 241, 0.1);
}

[data-theme="light"] .chatbot-title {
    color: #1e293b;
}

[data-theme="light"] .chatbot-subtitle {
    color: #64748b;
}

[data-theme="light"] .chatbot-close {
    background: rgba(0, 0, 0, 0.04);
    color: #64748b;
}

[data-theme="light"] .chatbot-close:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #1e293b;
}

[data-theme="light"] .chatbot-status-dot {
    border-color: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .chatbot-message-bot .chatbot-bubble {
    background: rgba(99, 102, 241, 0.06);
    color: #334155;
    border-color: rgba(99, 102, 241, 0.1);
}

[data-theme="light"] .chatbot-bubble strong {
    color: #6366f1;
}

[data-theme="light"] .chatbot-message-user .chatbot-bubble strong {
    color: #e2e8f0;
}

[data-theme="light"] .chatbot-bubble a {
    color: #6366f1;
}

[data-theme="light"] .chatbot-input {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(99, 102, 241, 0.15);
    color: #1e293b;
}

[data-theme="light"] .chatbot-input::placeholder {
    color: #94a3b8;
}

[data-theme="light"] .chatbot-input:focus {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(99, 102, 241, 0.35);
}

[data-theme="light"] .chatbot-input-area {
    border-top-color: rgba(99, 102, 241, 0.08);
    background: rgba(0, 0, 0, 0.01);
}

[data-theme="light"] .chatbot-chip {
    background: rgba(99, 102, 241, 0.06);
    color: #6366f1;
    border-color: rgba(99, 102, 241, 0.2);
}

[data-theme="light"] .chatbot-chip:hover {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
    border-color: rgba(99, 102, 241, 0.4);
}

[data-theme="light"] .chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .chatbot-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
    }

    .chatbot-panel.active {
        transform: translateY(0);
    }

    .chatbot-messages {
        max-height: calc(100vh - 200px);
        max-height: calc(100dvh - 200px);
    }

    .chatbot-toggle {
        bottom: 20px;
        right: 20px;
        width: 54px;
        height: 54px;
        font-size: 1.2rem;
    }
}

@media (max-width: 400px) {
    .chatbot-bubble {
        font-size: 0.82rem;
    }

    .chatbot-chip {
        font-size: 0.72rem;
        padding: 5px 11px;
    }
}
