/* ESTRELLA WIDGET STYLES */
/* Premium, Elegant, Glassmorphism */

:root {
    --estrella-gold: #D4AF37;
    --estrella-gold-light: #F3E5AB;
    --estrella-dark: #0A1118;
    --estrella-dark-glass: rgba(10, 17, 24, 0.85);
    --estrella-border: rgba(212, 175, 55, 0.3);
    --estrella-text: #E0E0E0;
    --estrella-white: #FFFFFF;
}

#estrella-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Outfit', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Floating Action Button */
.estrella-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--estrella-gold), #aa8822);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 20px rgba(212, 175, 55, 0.4);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.estrella-fab::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.estrella-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), 0 0 30px rgba(212, 175, 55, 0.6);
}

.estrella-fab:hover::before {
    opacity: 1;
}

.estrella-fab svg {
    width: 32px;
    height: 32px;
    color: #fff;
    stroke: #fff;
    fill: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: absolute;
}

.estrella-fab .chat-icon {
    transform: scale(1) rotate(0deg);
    opacity: 1;
}

.estrella-fab.open .chat-icon {
    transform: scale(0) rotate(-90deg);
    opacity: 0;
}

.estrella-fab .close-icon {
    transform: scale(0) rotate(90deg);
    opacity: 0;
    stroke-width: 2.5;
}

.estrella-fab.open .close-icon {
    transform: scale(1) rotate(0deg);
    opacity: 1;
}

/* Proactive Tooltip */
.estrella-proactive-tooltip {
    position: absolute;
    bottom: 12px;
    right: 80px;
    /* Positioned to the left of the FAB */
    background: linear-gradient(145deg, rgba(30, 40, 50, 0.95), rgba(15, 25, 35, 0.95));
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 16px;
    border-bottom-right-radius: 4px;
    padding: 12px 16px;
    color: var(--estrella-white);
    font-size: 0.9rem;
    line-height: 1.4;
    width: 240px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), 0 0 15px rgba(212, 175, 55, 0.15);
    backdrop-filter: blur(12px);
    pointer-events: none;
    opacity: 0;
    transform: translateX(20px) scale(0.95);
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.estrella-proactive-tooltip.active {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

.estrella-proactive-tooltip.hidden {
    display: none;
}

.estrella-proactive-text {
    font-weight: 300;
    margin: 0;
}

.estrella-proactive-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: var(--estrella-dark);
    border: 1px solid var(--estrella-border);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--estrella-white);
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
}

.estrella-proactive-close:hover {
    background: rgba(212, 175, 55, 0.3);
    color: var(--estrella-gold);
}

/* Panel */
.estrella-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--estrella-dark-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--estrella-border);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(212, 175, 55, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

.estrella-panel.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.estrella-header {
    padding: 20px;
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.1) 0%, transparent 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.estrella-agent-info {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.estrella-avatar {
    width: 72px;
    height: 72px;
    background: transparent;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.estrella-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.estrella-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background-color: #4CAF50;
    border: 2px solid var(--estrella-dark);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.estrella-titles {
    display: flex;
    flex-direction: column;
    margin-bottom: 6px;
}

.estrella-name {
    color: var(--estrella-white);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 1px;
}

.estrella-subtitle {
    color: var(--estrella-gold);
    font-size: 0.8rem;
    font-weight: 400;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.estrella-close-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: color 0.2s ease, background 0.2s ease;
    border-radius: 50%;
}

.estrella-close-btn:hover {
    color: var(--estrella-white);
    background: rgba(255, 255, 255, 0.1);
}

/* Body */
.estrella-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.estrella-body::-webkit-scrollbar {
    width: 6px;
}

.estrella-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.estrella-body::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
}

/* Messages */
.estrella-message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(15px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-weight: 300;
    letter-spacing: 0.2px;
    white-space: pre-wrap;
}

.estrella-message.welcome-message {
    white-space: normal;
}

@keyframes slideUpFade {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.estrella-message.bot {
    align-self: flex-start;
    background: linear-gradient(145deg, rgba(30, 40, 50, 0.9), rgba(15, 25, 35, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--estrella-text);
    border-bottom-left-radius: 4px;
    box-shadow: 2px 4px 15px rgba(0, 0, 0, 0.3);
}

.estrella-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.25), rgba(170, 136, 34, 0.15));
    border: 1px solid var(--estrella-border);
    color: var(--estrella-white);
    border-bottom-right-radius: 4px;
    box-shadow: -2px 4px 15px rgba(0, 0, 0, 0.3);
    font-weight: 400;
}

/* Typing Indicator */
.estrella-typing {
    display: none;
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    gap: 4px;
    align-items: center;
}

.estrella-typing.active {
    display: flex;
}

.estrella-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--estrella-gold);
    border-radius: 50%;
    animation: estrellaTyping 1.4s infinite ease-in-out both;
}

.estrella-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.estrella-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes estrellaTyping {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Quick Actions */
.estrella-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
    animation: slideUpFade 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.1s;
    opacity: 0;
}

.estrella-quick-action-btn {
    background: rgba(10, 17, 24, 0.6);
    border: 1px solid rgba(212, 175, 55, 0.5);
    color: var(--estrella-gold-light);
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.estrella-quick-action-btn:hover {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.3), rgba(170, 136, 34, 0.1));
    color: var(--estrella-white);
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(212, 175, 55, 0.2);
    border-color: var(--estrella-gold);
}

/* Footer (Input) */
.estrella-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 10px;
}

.estrella-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 0 16px;
    transition: border-color 0.3s ease, background 0.3s ease;
}

.estrella-input-wrapper:focus-within {
    border-color: var(--estrella-gold);
    background: rgba(255, 255, 255, 0.08);
}

.estrella-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--estrella-white);
    font-size: 0.95rem;
    font-family: inherit;
    padding: 12px 0;
    outline: none;
}

.estrella-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.estrella-send-btn {
    background: var(--estrella-gold);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: #111;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.estrella-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.estrella-send-btn:active {
    transform: scale(0.95);
}

/* Responsive */
@media (max-width: 768px) {
    #estrella-widget-container {
        bottom: 20px;
        right: 20px;
    }

    .estrella-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 88vh;
        /* Taller on mobile for app-like scale */
        max-height: 88vh;
        border-radius: 24px 24px 0 0;
        border: none;
        border-top: 1px solid var(--estrella-border);
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
    }

    .estrella-panel.active {
        transform: translateY(0);
        opacity: 1;
    }

    .estrella-header {
        padding: 16px;
    }

    .estrella-body {
        padding: 16px;
    }

    .estrella-footer {
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        /* iOS safe area */
    }
}

/* --- Estrella Flyer Modal --- */
.estrella-flyer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.estrella-flyer-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.estrella-flyer-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.estrella-flyer-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 10;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.estrella-flyer-modal.active .estrella-flyer-modal-content {
    transform: scale(1);
}

.estrella-flyer-close {
    position: absolute;
    top: -40px;
    right: -10px;
    background: transparent;
    border: none;
    color: var(--estrella-white);
    cursor: pointer;
    padding: 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.estrella-flyer-close:hover {
    opacity: 1;
}

.estrella-flyer-img-container {
    max-height: calc(90vh - 80px);
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

#estrella-flyer-modal-img {
    max-width: 100%;
    max-height: calc(90vh - 80px);
    object-fit: contain;
    display: block;
}

.estrella-flyer-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.estrella-flyer-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.5);
    color: var(--estrella-gold);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.estrella-flyer-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--estrella-gold);
    color: #fff;
}

.estrella-flyer-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 6px;
    text-align: center;
    pointer-events: none;
    animation: fadeIn 0.5s ease 1s both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media screen and (max-width: 480px) {
    .estrella-flyer-close {
        top: -45px;
        right: 0;
    }

    .estrella-flyer-actions {
        width: 100%;
    }

    .estrella-flyer-btn {
        flex: 1;
        justify-content: center;
        font-size: 0.85rem;
        padding: 8px 12px;
    }
}