/**
 * ESN AI Chatbot - Premium Styling
 * Glassmorphism design with ESN brand colors
 */

/* ========== CHATBOT CONTAINER ========== */
.esn-chatbot {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ========== FLOATING BUBBLE ========== */
.esn-chat-bubble {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #d4a439 0%, #c4933a 50%, #b8860b 100%);
    box-shadow:
        0 4px 20px rgba(212, 164, 57, 0.4),
        0 8px 32px rgba(0, 0, 0, 0.2);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.esn-chat-bubble::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    border-radius: 50%;
}

.esn-chat-bubble:hover {
    transform: scale(1.1);
    box-shadow:
        0 6px 28px rgba(212, 164, 57, 0.5),
        0 12px 40px rgba(0, 0, 0, 0.25);
}

.esn-chat-bubble svg {
    width: 28px;
    height: 28px;
    color: #0A1633;
    transition: all 0.3s ease;
}

.esn-chat-bubble .close-icon {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.esn-chatbot.open .esn-chat-bubble .chat-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.esn-chatbot.open .esn-chat-bubble .close-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Pulse animation */
@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.esn-chat-bubble::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(212, 164, 57, 0.6);
    animation: pulse-ring 2s ease-out infinite;
}

.esn-chatbot.open .esn-chat-bubble::after {
    animation: none;
    opacity: 0;
}

/* ========== CHAT WINDOW ========== */
.esn-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px !important;
    min-width: 380px !important;
    max-width: 90vw !important;
    height: 520px;
    background: rgba(10, 22, 51, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid rgba(212, 164, 57, 0.2);
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    display: flex;
    flex-direction: column !important;
    overflow: hidden;
    /* Reset inheritance issues */
    white-space: normal !important;
    word-wrap: break-word !important;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.esn-chatbot.open .esn-chat-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ========== HEADER ========== */
.esn-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(212, 164, 57, 0.15) 0%, rgba(10, 22, 51, 0.9) 100%);
    border-bottom: 1px solid rgba(212, 164, 57, 0.2);
}

.esn-chat-header-info {
    display: flex;
    flex-direction: row;
    /* Explicitly set to row */
    align-items: center;
    gap: 12px;
}

.esn-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #d4a439 0%, #b8860b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.esn-chat-avatar svg {
    width: 24px;
    height: 24px;
    color: #0A1633;
}

.esn-chat-title {
    display: flex;
    flex-direction: column;
}

.esn-chat-name {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.esn-chat-status {
    font-size: 0.75rem;
    color: #4ade80;
    display: flex;
    align-items: center;
    gap: 4px;
}

.esn-chat-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.esn-chat-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.esn-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.esn-chat-close svg {
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.7);
}

/* ========== MESSAGES AREA ========== */
.esn-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.esn-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.esn-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(212, 164, 57, 0.3);
    border-radius: 3px;
}

.esn-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 164, 57, 0.5);
}

/* ========== MESSAGES ========== */
.esn-message {
    display: flex;
    animation: message-in 0.3s ease-out;
}

@keyframes message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.esn-message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Bot messages */
.esn-message-bot {
    justify-content: flex-start;
}

.esn-message-bot .esn-message-content {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-bottom-left-radius: 4px;
}

/* User messages */
.esn-message-user {
    justify-content: flex-end;
}

.esn-message-user .esn-message-content {
    background: linear-gradient(135deg, #d4a439 0%, #b8860b 100%);
    color: #0A1633;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

/* Typing indicator */
.esn-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.esn-typing-dots span {
    width: 8px;
    height: 8px;
    background: rgba(212, 164, 57, 0.6);
    border-radius: 50%;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.esn-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.esn-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* ========== INPUT AREA ========== */
.esn-chat-input-area {
    display: flex;
    flex-direction: row;
    /* Explicitly set to row */
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(212, 164, 57, 0.1);
}

.esn-chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid rgba(212, 164, 57, 0.2);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.esn-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.esn-chat-input:focus {
    border-color: rgba(212, 164, 57, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.esn-chat-send {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #d4a439 0%, #b8860b 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.esn-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(212, 164, 57, 0.4);
}

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

.esn-chat-send svg {
    width: 20px;
    height: 20px;
    color: #0A1633;
    margin-left: 2px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
    .esn-chatbot {
        bottom: 16px;
        right: 16px;
    }

    .esn-chat-bubble {
        width: 56px;
        height: 56px;
    }

    .esn-chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        max-height: 500px;
        right: -8px;
        bottom: 72px;
    }

    .esn-chat-input-area {
        padding: 12px 16px;
    }

    .esn-chat-input {
        padding: 12px 14px;
    }

    .esn-chat-send {
        width: 44px;
        height: 44px;
    }
}

/* ========== DARK MODE ENHANCEMENTS ========== */
@media (prefers-color-scheme: dark) {
    .esn-chat-window {
        background: rgba(10, 22, 51, 0.98);
    }
}

/* ========== OPTIONS CHIPS ========== */
.esn-chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 8px;
    animation: message-in 0.3s ease-out;
}

.esn-chat-option-btn {
    background: rgba(212, 164, 57, 0.1);
    border: 1px solid rgba(212, 164, 57, 0.3);
    color: #ffffff;
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.esn-chat-option-btn:hover {
    background: rgba(212, 164, 57, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.esn-chat-option-btn:active {
    transform: translateY(0);
}