/* Chat Widget Styles - Salma AI - Premium Design */

:root {
    --chat-primary: #0a0a0a;
    --chat-secondary: #1a1a1a;
    --chat-gold: #d4af37;
    --chat-gold-dark: #b8962e;
    --chat-white: #ffffff;
    --chat-silver: #a0a0a0;
    --chat-bg: #f8f8f8;
}

/* Boton flotante */
.chat-widget-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-gold) 0%, var(--chat-gold-dark) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.4);
    z-index: 10000;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: visible;
    padding: 3px;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(212, 175, 55, 0.5);
}

.chat-widget-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.chat-widget-button .notification-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #10b981;
    color: white;
    font-size: 12px;
    font-weight: bold;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
    border: 3px solid var(--chat-primary);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.5);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Contenedor del chat */
.chat-widget-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: var(--chat-primary);
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.chat-widget-container.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header del chat */
.chat-widget-header {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-secondary) 100%);
    color: var(--chat-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.chat-widget-header .avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid var(--chat-gold);
    object-fit: cover;
}

.chat-widget-header .info {
    flex: 1;
}

.chat-widget-header .name {
    font-weight: 500;
    font-size: 15px;
    margin: 0;
    color: var(--chat-white);
}

.chat-widget-header .status {
    font-size: 12px;
    color: var(--chat-silver);
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-widget-header .status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-widget-header .close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--chat-silver);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-widget-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--chat-white);
}

/* Area de mensajes */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--chat-secondary);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.bot {
    background: rgba(255, 255, 255, 0.08);
    color: var(--chat-white);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-message.user {
    background: linear-gradient(135deg, var(--chat-gold) 0%, var(--chat-gold-dark) 100%);
    color: var(--chat-primary);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

.chat-message.bot strong {
    color: var(--chat-gold);
}

.chat-message.bot a {
    color: var(--chat-gold);
    text-decoration: none;
}

.chat-message.bot a:hover {
    text-decoration: underline;
}

/* Indicador de escritura */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--chat-gold);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Input del chat */
.chat-widget-input {
    padding: 12px 16px;
    background: var(--chat-primary);
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    display: flex;
    gap: 10px;
}

.chat-widget-input input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--chat-secondary);
    color: var(--chat-white);
}

.chat-widget-input input::placeholder {
    color: var(--chat-silver);
}

.chat-widget-input input:focus {
    border-color: var(--chat-gold);
}

.chat-widget-input button {
    width: 40px;
    height: 40px;
    border: none;
    background: linear-gradient(135deg, var(--chat-gold) 0%, var(--chat-gold-dark) 100%);
    color: var(--chat-primary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.chat-widget-input button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.chat-widget-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Scrollbar personalizado */
.chat-widget-messages::-webkit-scrollbar {
    width: 5px;
}

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

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive - Movil */
@media (max-width: 480px) {
    .chat-widget-container {
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        border: none;
        transform: none !important;
    }

    .chat-widget-container.open {
        transform: none !important;
    }

    .chat-widget-button {
        bottom: 15px;
        right: 15px;
        width: 55px;
        height: 55px;
    }

    .chat-widget-header {
        padding: 14px 16px;
        padding-top: max(14px, env(safe-area-inset-top));
        flex-shrink: 0;
    }

    .chat-widget-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .chat-widget-input {
        flex-shrink: 0;
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        background: var(--chat-primary);
    }

    .chat-widget-input input {
        font-size: 16px; /* Evita zoom en iOS */
    }

    .chat-message {
        max-width: 90%;
    }

    /* Ocultar boton cuando chat esta abierto en movil */
    .chat-widget-container.open ~ .chat-widget-button,
    #chatWidgetWrapper:has(.chat-widget-container.open) .chat-widget-button {
        display: none;
    }
}

/* Tablets */
@media (min-width: 481px) and (max-width: 768px) {
    .chat-widget-container {
        width: 340px;
        height: 480px;
    }
}
