/* Chat Widget Tecnosatelites - Simple y Robusto */

/* Reset básico */
#ts-chat-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Clase helper para ocultar */
.ts-hidden {
    display: none !important;
}

/* Botón flotante */
.ts-chat-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #046bd2, #045cb4);
    border: none;
    box-shadow: 0 4px 12px rgba(4, 107, 210, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 9998;
}

.ts-chat-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(4, 107, 210, 0.5);
}

.ts-chat-btn.ts-active {
    background: linear-gradient(135deg, #045cb4, #034a96);
}

/* Badge de notificación */
.ts-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    font-family: Arial, sans-serif;
}

/* Ventana del chat */
.ts-chat-box {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* Header */
.ts-chat-header {
    background: linear-gradient(135deg, #046bd2, #045cb4);
    color: white;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ts-chat-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.ts-chat-header p {
    font-size: 13px;
    margin: 0;
    opacity: 0.9;
}

.ts-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.ts-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Body (área de contenido) */
.ts-chat-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
}

/* Menú de opciones */
.ts-menu-intro {
    text-align: center;
    margin-bottom: 20px;
}

.ts-menu-intro p {
    color: #64748b;
    font-size: 14px;
}

.ts-menu-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ts-menu-btn {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.ts-menu-btn:hover {
    border-color: #046bd2;
    background: #f0f5fa;
    transform: translateY(-1px);
}

.ts-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.ts-btn-text {
    flex: 1;
}

.ts-btn-text strong {
    display: block;
    color: #1e293b;
    font-size: 14px;
    margin-bottom: 2px;
}

.ts-btn-text small {
    color: #64748b;
    font-size: 12px;
}

/* Área de mensajes */
.ts-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 100%;
}

.ts-message {
    display: flex;
    width: 100%;
}

.ts-msg-user {
    justify-content: flex-end;
}

.ts-msg-bot {
    justify-content: flex-start;
}

.ts-msg-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
}

.ts-msg-user .ts-msg-bubble {
    background: linear-gradient(135deg, #046bd2, #045cb4);
    color: white;
    border-bottom-right-radius: 4px;
}

.ts-msg-bot .ts-msg-bubble {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

.ts-msg-bubble p {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
}

.ts-msg-time {
    display: block;
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.7;
}

/* Animación de escritura */
.ts-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.ts-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: ts-typing-anim 1.4s infinite;
}

.ts-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.ts-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ts-typing-anim {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* Footer con input */
.ts-chat-footer {
    border-top: 1px solid #e2e8f0;
    padding: 12px 16px;
    background: white;
    border-radius: 0 0 12px 12px;
    flex-shrink: 0;
}

.ts-back-btn {
    background: none;
    border: none;
    color: #046bd2;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 0;
    margin-bottom: 8px;
    display: block;
    font-family: inherit;
}

.ts-back-btn:hover {
    color: #045cb4;
    text-decoration: underline;
}

.ts-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ts-chat-input {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.ts-chat-input:focus {
    border-color: #046bd2;
}

.ts-send-btn {
    background: linear-gradient(135deg, #046bd2, #045cb4);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
}

.ts-send-btn:hover {
    transform: scale(1.05);
}

.ts-send-btn:active {
    transform: scale(0.95);
}

/* Scrollbar personalizado */
.ts-chat-body::-webkit-scrollbar,
.ts-messages::-webkit-scrollbar {
    width: 6px;
}

.ts-chat-body::-webkit-scrollbar-track,
.ts-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ts-chat-body::-webkit-scrollbar-thumb,
.ts-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.ts-chat-body::-webkit-scrollbar-thumb:hover,
.ts-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive */
@media (max-width: 480px) {
    .ts-chat-box {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: 10px;
        bottom: 80px;
    }

    .ts-chat-btn {
        width: 56px;
        height: 56px;
        bottom: 16px;
        right: 16px;
    }
}
