/**
 * Estilos para el widget de chat anónimo
 */

.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Botón flotante */
.chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4A6FA5 0%, #7B68EE 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(74, 111, 165, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(74, 111, 165, 0.6);
}

.chat-button:active {
    transform: scale(0.95);
}

/* Badge de mensajes no leídos */
.chat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Ventana de chat */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 360px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chat-widget.open .chat-window {
    display: flex;
}

/* Ocultar botón flotante cuando el chat está abierto */
.chat-widget.open .chat-button {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header del chat */
.chat-header {
    background: linear-gradient(135deg, #4A6FA5 0%, #7B68EE 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.chat-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Área de mensajes */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Mensaje de bienvenida */
.chat-welcome {
    background: #e3f2fd;
    color: #1976d2;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    text-align: center;
    border-left: 4px solid #1976d2;
    margin-bottom: 8px;
}

/* Mensajes */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: messageIn 0.2s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.sent {
    align-self: flex-end;
}

.chat-message.received {
    align-self: flex-start;
}

.chat-message-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-message.sent .chat-message-content {
    background: linear-gradient(135deg, #4A6FA5 0%, #7B68EE 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.received .chat-message-content {
    background: white;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-message-time {
    font-size: 11px;
    color: #718096;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-message.sent .chat-message-time {
    text-align: right;
}

.chat-message.received .chat-message-time {
    text-align: left;
}

/* Input de mensaje */
.chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Botones de acción (ubicación, foto, archivo) */
.chat-actions {
    display: flex;
    gap: 8px;
    padding-bottom: 8px;
}

.chat-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    color: #4A6FA5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-action-btn:hover {
    background: #e3f2fd;
    border-color: #4A6FA5;
    transform: scale(1.05);
}

.chat-action-btn:active {
    transform: scale(0.95);
}

/* Contenedor de input y botón enviar */
.chat-input-container>div:last-of-type {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    max-height: 100px;
    overflow-y: auto;
}

.chat-input:focus {
    border-color: #4A6FA5;
}

.chat-input::-webkit-scrollbar {
    width: 4px;
}

.chat-input::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4A6FA5 0%, #7B68EE 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(74, 111, 165, 0.4);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 480px) {
    .chat-widget {
        right: 0;
        bottom: 0;
        left: 0;
    }

    .chat-button {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 9998;
    }

    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .chat-header {
        padding: 12px 16px;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .chat-header-title {
        font-size: 15px;
    }

    .chat-close-btn {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    .chat-messages {
        /* Ajustar altura para dejar espacio al teclado */
        max-height: calc(100vh - 200px);
        padding: 12px;
    }

    .chat-input-container {
        padding: 12px;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 2px solid #e2e8f0;
    }

    .chat-actions {
        padding-bottom: 6px;
    }

    .chat-action-btn {
        width: 32px;
        height: 32px;
    }

    .chat-input {
        font-size: 16px;
        /* Evita zoom en iOS */
        padding: 10px 14px;
    }

    .chat-send-btn {
        width: 36px;
        height: 36px;
    }

    .chat-message-content {
        font-size: 14px;
        max-width: 85%;
    }
}

/* Tablets */
@media (min-width: 481px) and (max-width: 768px) {
    .chat-window {
        width: 400px;
        height: 600px;
        max-height: 80vh;
    }
}

/* Landscape móvil */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-window {
        height: 90vh;
        max-height: 90vh;
    }

    .chat-messages {
        max-height: calc(90vh - 180px);
    }
}

/* Fix para teclado en iOS */
@media (max-width: 480px) {
    .chat-widget.open .chat-window {
        /* En iOS, cuando se abre el teclado, ajustar */
        height: 100%;
        min-height: 100vh;
    }

    /* Asegurar que el input siempre sea visible */
    .chat-input-container {
        position: relative;
        bottom: 0;
    }
}

/* Estados de carga */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #718096;
    font-size: 14px;
}

.chat-loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%,
    100% {
        content: '...';
    }
}

/* Estado vacío */
.chat-empty {
    text-align: center;
    padding: 40px 20px;
    color: #718096;
    font-size: 14px;
}

.chat-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}