/* Chat flotante profesional FotoArt */
.fotoart-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10001;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: transparent;
}

/* Botón flotante */
.fotoart-chat-button {
    width: 60px;
    height: 60px;
    background: #FF8C42;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 140, 66, 0.4);
    transition: all 0.3s ease;
    color: #fff;
    position: relative;
    padding: 8px;
    overflow: hidden;
    border: none;
    z-index: 10001;
}

.fotoart-chat-button-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
    background: transparent;
    border: none;
    outline: none;
}

.fotoart-chat-button-text {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    opacity: 1;
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    text-align: center;
    line-height: 1.2;
    display: block;
    margin-top: 0;
    background: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
    text-shadow: none;
}

.fotoart-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

/* Notificación animada */
.fotoart-chat-notification {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: #fff;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 250px;
    z-index: 10003;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: all 0.3s ease;
    pointer-events: auto; /* Cambiado a auto para permitir clicks */
    cursor: pointer; /* Cursor pointer para indicar que es clickeable */
}

.fotoart-chat-notification-icon {
    font-size: 24px;
    text-align: center;
    margin-bottom: 6px;
    animation: wave 1.5s ease-in-out infinite;
}

@keyframes wave {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(20deg);
    }
    75% {
        transform: rotate(-20deg);
    }
}

.fotoart-chat-notification-show {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: notificationBounce 0.5s ease;
    pointer-events: auto; /* Asegurar que sea clickeable cuando está visible */
    cursor: pointer;
}

.fotoart-chat-notification:hover {
    background: #f8f8f8;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(0) scale(1.02);
}

@keyframes notificationBounce {
    0% {
        transform: translateY(10px) scale(0.9);
        opacity: 0;
    }
    50% {
        transform: translateY(-5px) scale(1.05);
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.fotoart-chat-notification-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.fotoart-chat-notification-content p {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    color: #333;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.fotoart-chat-notification-arrow {
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

@media screen and (max-width: 480px) {
    .fotoart-chat-notification {
        max-width: 200px;
        font-size: 12px;
        padding: 10px 14px;
    }
}

.fotoart-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ea272d;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid #fff;
}

/* Ventana del chat */
.fotoart-chat-window {
    display: none;
    flex-direction: column;
    width: 380px;
    height: 600px;
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    position: fixed;
    bottom: 90px;
    right: 20px;
    max-height: calc(100vh - 180px);
    z-index: 10002;
}

.fotoart-chat-window[style*="flex"] {
    display: flex !important;
}

@media screen and (max-width: 480px) {
    .fotoart-chat-window {
        width: 100vw;
        width: 100dvw; /* Dynamic viewport width para iOS */
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height para iOS */
        max-width: 100vw;
        max-width: 100dvw;
        max-height: 100vh;
        max-height: 100dvh;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        border-radius: 0;
        position: fixed;
        margin: 0;
        padding: 0;
        padding-bottom: 0;
        display: none;
        flex-direction: column;
        /* Asegurar que el chat use el viewport completo incluso con el teclado */
        box-sizing: border-box;
        /* Asegurar que el contenido no quede oculto por la barra de navegación */
        overflow: hidden;
    }
    
    .fotoart-chat-window[style*="flex"] {
        display: flex !important;
    }
    
    /* Prevenir scroll del body cuando el chat está abierto */
    body.chat-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
        /* Prevenir que el body se mueva cuando aparece el teclado en iOS */
        touch-action: none;
    }
    
    .fotoart-chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .fotoart-chat-button {
        width: 50px;
        height: 50px;
    }
    
    .fotoart-chat-button-text {
        font-size: 11px;
    }
    
    .fotoart-chat-notification {
        bottom: 70px;
        right: 5px;
        max-width: calc(100vw - 80px);
    }
    
    /* Asegurar que el header esté siempre visible */
    .fotoart-chat-header {
        position: relative;
        z-index: 10;
        flex-shrink: 0;
        min-height: 60px;
    }
    
    /* Asegurar que el input container esté siempre visible */
    .fotoart-chat-input-container {
        position: relative;
        z-index: 10;
        flex-shrink: 0;
        min-height: 60px;
        /* Asegurar que tenga suficiente espacio para no quedar oculto */
        padding-bottom: calc(12px + env(safe-area-inset-bottom) + 50px) !important;
    }
    
    /* Área de mensajes con scroll */
    .fotoart-chat-messages {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
        /* Asegurar que el scroll funcione correctamente en iOS */
        overscroll-behavior: contain;
        /* Asegurar que el área de mensajes no oculte el input */
        padding-bottom: 0;
        margin-bottom: 0;
    }
    
    /* Ajustes adicionales para iOS Safari cuando el teclado está visible */
    @supports (-webkit-touch-callout: none) {
        .fotoart-chat-window {
            /* iOS Safari específico */
            height: -webkit-fill-available;
            /* Asegurar que el chat no quede oculto por la barra de navegación */
            padding-bottom: 0;
        }
        
        .fotoart-chat-input-container {
            /* Asegurar que el input tenga suficiente espacio en iOS para la barra de navegación de Safari */
            padding-bottom: calc(12px + env(safe-area-inset-bottom) + 50px) !important;
            /* Asegurar que esté visible por encima de la barra de navegación */
            position: sticky;
            bottom: 0;
        }
    }
}

/* Header del chat */
.fotoart-chat-header {
    background: #fff;
    color: #333;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

@media screen and (max-width: 480px) {
    .fotoart-chat-header {
        padding: 12px 15px;
    }
}

.fotoart-chat-logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fotoart-chat-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 4px;
}

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

.fotoart-chat-title-container h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #333;
    line-height: 1.2;
}

.fotoart-chat-title-container p {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: #666;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

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

.fotoart-chat-close {
    background: none;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    font-weight: 300;
    line-height: 1;
    flex-shrink: 0;
    z-index: 11;
}

@media screen and (max-width: 480px) {
    .fotoart-chat-close {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 28px;
    }
}

.fotoart-chat-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

/* Área de mensajes */
.fotoart-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
    min-height: 0;
}

@media screen and (max-width: 480px) {
    .fotoart-chat-messages {
        padding: 15px;
    }
}

.fotoart-message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

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

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

.fotoart-message-bot {
    justify-content: flex-start;
}

.fotoart-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.fotoart-message-user .fotoart-message-avatar {
    order: 2;
    margin-left: 10px;
}

.fotoart-message-bot .fotoart-message-avatar {
    order: 0;
    margin-right: 0;
}

.fotoart-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.fotoart-message-user .fotoart-message-content {
    background: #A68B5B;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.fotoart-message-bot .fotoart-message-content {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.fotoart-message-content p {
    margin: 0 0 10px 0;
    font-size: 15px;
    line-height: 1.6;
}

.fotoart-message-content p:last-child {
    margin-bottom: 0;
}

.fotoart-message-content strong {
    font-weight: 600;
    color: #333;
    display: block;
    margin: 15px 0 8px 0;
    font-size: 16px;
}

.fotoart-message-content ul {
    margin: 10px 0;
    padding-left: 20px;
    list-style-type: disc;
}

.fotoart-message-content li {
    margin: 8px 0;
    line-height: 1.6;
    font-size: 15px;
}

.fotoart-message-link {
    color: #A68B5B;
    text-decoration: underline;
    word-break: break-all;
    transition: color 0.3s ease;
}

.fotoart-message-link:hover {
    color: #6B7654;
    text-decoration: underline;
}

/* Indicador de escritura */
.fotoart-typing-dots {
    display: flex;
    gap: 5px;
    padding: 5px 0;
}

.fotoart-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

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

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

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

/* Input y botón de envío */
.fotoart-chat-input-container {
    display: flex;
    padding: 15px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
    flex-shrink: 0;
}

@media screen and (max-width: 480px) {
    .fotoart-chat-input-container {
        padding: 12px 15px;
        /* Padding extra para evitar que quede oculto detrás de la barra de navegación de Safari */
        padding-bottom: calc(12px + env(safe-area-inset-bottom) + 50px);
        gap: 8px;
        display: flex;
        align-items: center;
        position: relative;
        z-index: 10;
        background: #fff;
        /* Asegurar que esté por encima de la barra de navegación */
        margin-bottom: 0;
    }
    
    .fotoart-chat-input {
        font-size: 16px; /* Evita zoom automático en iOS */
        padding: 10px 16px;
        flex: 1;
        min-width: 0;
    }
    
    .fotoart-chat-send {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        flex-shrink: 0;
    }
    
    /* Asegurar que el input container esté siempre visible cuando el teclado está activo */
    .fotoart-chat-window {
        display: flex;
        flex-direction: column;
    }
    
    .fotoart-chat-input-container.keyboard-active {
        padding-bottom: calc(12px + env(safe-area-inset-bottom) + 50px);
    }
}

.fotoart-chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #333;
    background: #fff;
    outline: none;
    transition: border-color 0.3s ease;
}

.fotoart-chat-input:focus {
    border-color: #A68B5B;
    color: #333;
}

.fotoart-chat-input::placeholder {
    color: #999;
}

.fotoart-chat-send {
    width: 45px;
    height: 45px;
    min-width: 45px;
    min-height: 45px;
    border-radius: 50%;
    background: #A68B5B;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.fotoart-chat-send:hover {
    transform: scale(1.1);
}

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

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

.fotoart-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.fotoart-chat-messages::-webkit-scrollbar-thumb {
    background: #A68B5B;
    border-radius: 3px;
}

.fotoart-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #A68B5B;
}

