/**
 * Chat Widget Styles
 *
 * Intercom-style floating chat widget.
 * Modern gradient purple design with smooth animations.
 *
 * @version 1.0.0
 */

/* ========================================
   Chat Button (Floating)
   ======================================== */

.chat-widget-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    font-size: 24px;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.chat-widget-button:active {
    transform: scale(0.95);
}

.chat-widget-button.chat-open {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
}

/* Badge de mensajes no leídos */
.chat-widget-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e53e3e;
    color: white;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ========================================
   Chat Window
   ======================================== */

.chat-widget-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 9999;
    width: 380px;
    max-height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header del chat */
.chat-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-widget-header-title {
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-widget-header-actions {
    display: flex;
    gap: 8px;
}

.chat-widget-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-widget-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Indicador online */
.chat-status-indicator {
    width: 8px;
    height: 8px;
    background: #48bb78;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* ========================================
   Messages Container
   ======================================== */

.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f7fafc;
    max-height: 400px;
}

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

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

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

.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Mensaje individual */
.chat-message {
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease-in;
}

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

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

.chat-message-assistant {
    display: flex;
    justify-content: flex-start;
}

/* Burbuja de mensaje */
.chat-message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.chat-message-user .chat-message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-assistant .chat-message-bubble {
    background: white;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-message-bubble p {
    margin: 0 0 8px 0;
}

.chat-message-bubble p:last-child {
    margin-bottom: 0;
}

.chat-message-bubble ul {
    margin: 8px 0;
    padding-left: 20px;
}

.chat-message-bubble li {
    margin: 4px 0;
}

/* Timestamp */
.chat-message-timestamp {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 4px;
    text-align: right;
}

.chat-message-user .chat-message-timestamp {
    text-align: right;
}

.chat-message-assistant .chat-message-timestamp {
    text-align: left;
}

/* Typing indicator */
.chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    width: fit-content;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* ========================================
   Suggested Actions
   ======================================== */

.chat-suggested-actions {
    padding: 0 16px 12px 16px;
    background: #f7fafc;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-suggested-action-btn {
    padding: 8px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chat-suggested-action-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
}

/* ========================================
   Rate Limit Warning
   ======================================== */

.chat-rate-limit-warning {
    padding: 12px 16px;
    background: #fed7d7;
    border-top: 1px solid #fc8181;
    color: #c53030;
    font-size: 13px;
    text-align: center;
}

/* ========================================
   Input Area
   ======================================== */

.chat-widget-input {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input-field {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    transition: border-color 0.2s;
}

.chat-input-field:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input-field:disabled {
    background: #f7fafc;
    cursor: not-allowed;
}

.chat-send-btn {
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
}

.chat-send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   Mobile Responsive
   ======================================== */

@media (max-width: 480px) {
    .chat-widget-window {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        animation: slideUpMobile 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .chat-widget-button {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .chat-widget-messages {
        max-height: calc(100vh - 180px);
    }
}

/* ========================================
   Dark Mode Support (Optional)
   ======================================== */

@media (prefers-color-scheme: dark) {
    .chat-widget-window {
        background: #1a202c;
    }

    .chat-widget-messages {
        background: #2d3748;
    }

    .chat-message-assistant .chat-message-bubble {
        background: #4a5568;
        color: #f7fafc;
    }

    .chat-input-field {
        background: #2d3748;
        border-color: #4a5568;
        color: #f7fafc;
    }

    .chat-suggested-action-btn {
        background: #2d3748;
        border-color: #4a5568;
        color: #f7fafc;
    }
}
