/* ═══════════════════════════════════════════════
   Chatbot Sofía - Enhanced Styles v12
   ═══════════════════════════════════════════════ */

/* Variables */
:root {
    --chat-bg: #0f172a;
    --chat-header: #1e293b;
    --chat-accent: #0ea5e9;
    --chat-accent-hover: #0284c7;
    --chat-text: #f1f5f9;
    --chat-user-bg: linear-gradient(135deg, #0ea5e9, #6366f1);
    --chat-user-text: #ffffff;
    --chat-bot-bg: #1e293b;
    --chat-border: #334155;
    --chat-success: #10b981;
    --chat-whatsapp: #25d366;
}

/* ─── Chat Launcher (Floating Button) ─── */
.chat-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--chat-accent), #6366f1);
    border-radius: 50%;
    box-shadow: 0 8px 32px rgba(14, 165, 233, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeInScale 0.5s ease-out;
}

.chat-launcher:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 40px rgba(14, 165, 233, 0.55);
}

.chat-launcher i {
    font-size: 26px;
    color: white;
    z-index: 1;
}

/* Pulsing ring effect */
.launcher-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--chat-accent);
    animation: launcherPulse 2s ease-out infinite;
}

@keyframes launcherPulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

    100% {
        transform: scale(1.7);
        opacity: 0;
    }
}

/* ─── Chat Window ─── */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 390px;
    height: 600px;
    max-height: 80vh;
    background: var(--chat-bg);
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
    bottom: 90px;
}

/* ─── Header ─── */
.chat-header {
    background: var(--chat-header);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-avatar {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--chat-accent), #6366f1);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
    position: relative;
}

.avatar-status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: var(--chat-success);
    border-radius: 50%;
    border: 2px solid var(--chat-header);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.bot-status h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: white;
    letter-spacing: 0.02em;
}

.bot-status span {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--chat-success);
    margin-top: 2px;
    font-weight: 500;
}

.bot-status span::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--chat-success);
    border-radius: 50%;
    display: inline-block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* WhatsApp Escalation Button */
.whatsapp-escalation {
    width: 36px;
    height: 36px;
    background: rgba(37, 211, 102, 0.1);
    border: 1px solid rgba(37, 211, 102, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-whatsapp);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
}

.whatsapp-escalation:hover {
    background: rgba(37, 211, 102, 0.2);
    border-color: var(--chat-whatsapp);
    transform: scale(1.08);
    box-shadow: 0 0 16px rgba(37, 211, 102, 0.2);
}

.close-chat {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-chat:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

/* ─── Messages Area ─── */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--chat-bg);
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ─── Message Bubbles ─── */
.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    position: relative;
    animation: messageSlide 0.35s ease-out;
    word-wrap: break-word;
}

.message.bot {
    align-self: flex-start;
    background: var(--chat-bot-bg);
    color: var(--chat-text);
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.message.user {
    align-self: flex-end;
    background: var(--chat-user-bg);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 12px rgba(14, 165, 233, 0.2);
}

/* ─── Quick Reply Buttons ─── */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
    animation: quickRepliesIn 0.4s ease-out;
}

@keyframes quickRepliesIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.quick-reply-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    color: #cbd5e1;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    font-family: inherit;

    /* Animation */
    opacity: 0;
    animation: fadeInUp 0.4s ease forwards;
}

/* Staggered animation delay for up to 5 buttons */
.quick-reply-btn:nth-child(1) {
    animation-delay: 0.1s;
}

.quick-reply-btn:nth-child(2) {
    animation-delay: 0.2s;
}

.quick-reply-btn:nth-child(3) {
    animation-delay: 0.3s;
}

.quick-reply-btn:nth-child(4) {
    animation-delay: 0.4s;
}

.quick-reply-btn:nth-child(5) {
    animation-delay: 0.5s;
}

.quick-reply-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.15);
}

.quick-reply-btn:active {
    transform: translateY(0) scale(0.97);
}

.qr-icon {
    font-size: 15px;
}

/* WhatsApp Quick Reply variant */
.quick-reply-btn.qr-whatsapp {
    background: rgba(37, 211, 102, 0.08);
    border-color: rgba(37, 211, 102, 0.25);
    color: var(--chat-whatsapp);
}

.quick-reply-btn.qr-whatsapp:hover {
    background: rgba(37, 211, 102, 0.18);
    border-color: var(--chat-whatsapp);
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.15);
}

/* ─── Audit Progress Indicator ─── */
.audit-progress {
    background: rgba(14, 165, 233, 0.06);
    border: 1px solid rgba(14, 165, 233, 0.12);
    border-radius: 14px;
    padding: 14px 16px;
    margin: 4px 0;
    animation: messageSlide 0.35s ease-out;
}

.progress-label {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-bottom: 12px;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid var(--chat-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    transition: all 0.3s ease;
}

.progress-step.active .step-dot {
    background: rgba(14, 165, 233, 0.15);
    border-color: var(--chat-accent);
    color: var(--chat-accent);
    box-shadow: 0 0 12px rgba(14, 165, 233, 0.25);
    animation: stepPulse 1.5s ease-in-out infinite;
}

@keyframes stepPulse {

    0%,
    100% {
        box-shadow: 0 0 12px rgba(14, 165, 233, 0.25);
    }

    50% {
        box-shadow: 0 0 20px rgba(14, 165, 233, 0.4);
    }
}

.progress-step.done .step-dot {
    background: var(--chat-success);
    border-color: var(--chat-success);
    color: white;
    font-size: 10px;
}

.step-label {
    font-size: 10px;
    color: #64748b;
    font-weight: 500;
}

.progress-step.active .step-label {
    color: var(--chat-accent);
}

.progress-step.done .step-label {
    color: var(--chat-success);
}

.progress-bar-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--chat-accent), #6366f1);
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px rgba(14, 165, 233, 0.4);
}

/* ─── Input Area ─── */
.chat-input-area {
    padding: 14px 16px;
    background: var(--chat-header);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 25px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 14px;
    color: white;
    outline: none;
    transition: all 0.25s ease;
}

.chat-input::placeholder {
    color: #64748b;
}

.chat-input:focus {
    border-color: var(--chat-accent);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--chat-accent), #6366f1);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.35);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ─── Typing Indicator ─── */
.typing-indicator {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--chat-bot-bg);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    width: fit-content;
    animation: messageSlide 0.3s ease-out;
}

.typing-avatar {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--chat-accent), #6366f1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    flex-shrink: 0;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
    display: block;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* ─── Text Formatting ─── */
.chat-list-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 6px 0;
    padding-left: 2px;
}

.chat-list-item .bullet {
    color: var(--chat-accent);
    font-weight: bold;
    flex-shrink: 0;
}

.message strong {
    font-weight: 700;
    color: var(--chat-accent);
}

.message.user strong {
    color: white;
}

.message em {
    font-style: italic;
    opacity: 0.9;
}

/* ─── Animations ─── */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Mobile Responsiveness ─── */
@media (max-width: 480px) {
    .chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chat-window.active {
        bottom: 0;
    }

    .chat-launcher {
        bottom: 15px;
        right: 15px;
        width: 54px;
        height: 54px;
    }

    .chat-launcher i {
        font-size: 22px;
    }

    .quick-replies {
        gap: 6px;
    }

    .quick-reply-btn {
        padding: 7px 12px;
        font-size: 12px;
    }

    .audit-progress {
        padding: 10px 12px;
    }

    .step-label {
        font-size: 9px;
    }

    .step-dot {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
}