/* ==========================================
   CHAT WIDGET
   ========================================== */

.chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.6);
}

.chat-button i {
    color: white;
    font-size: 24px;
}

.chat-widget {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 550px;
    max-height: calc(100vh - 150px);
    background: #1e293b;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-widget.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

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

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-avatar i {
    color: white;
    font-size: 20px;
}

.chat-header-text h3 {
    margin: 0;
    color: white;
    font-size: 16px;
    font-weight: 600;
}

.chat-header-text p {
    margin: 2px 0 0 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 24px;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #0f172a;
}

.chat-message {
    display: flex;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

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

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

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-message-avatar i {
    color: white;
    font-size: 16px;
}

/* Avatar del usuario (verde) */
.chat-message.user .chat-message-avatar {
    background: linear-gradient(135deg, #10B981, #059669);
}

/* Avatar del admin (naranja/dorado) */
.chat-message.admin .chat-message-avatar {
    background: linear-gradient(135deg, #F59E0B, #D97706);
}

.chat-message-content {
    max-width: 75%;
    background: #1e293b;
    padding: 10px 14px;
    border-radius: 12px;
    color: #cbd5e1;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.user .chat-message-content {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
}

.chat-message.bot .chat-message-content {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-message.admin .chat-message-content {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

.chat-message-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 4px;
}

/* Chat Options */
.chat-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.chat-option-btn {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    text-align: left;
}

.chat-option-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateX(4px);
}

.chat-option-btn i {
    margin-right: 8px;
}

/* Chat Input */
/* Formulario de usuario no autenticado */
.chat-user-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* Permite que el scroll funcione correctamente */
    justify-content: center;
    align-items: center;
}

.form-content {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: auto 0; /* Centrar verticalmente dentro del área con scroll */
}

/* Estilo de scrollbar personalizado para el formulario */
.chat-user-form::-webkit-scrollbar {
    width: 6px;
}

.chat-user-form::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

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

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

.form-content h4 {
    color: white;
    margin: 0 0 8px 0;
    font-size: 1.1rem;
}

.form-content p {
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 20px 0;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #3B82F6;
    background: rgba(255, 255, 255, 0.15);
}

.form-group input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.btn-submit-form {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.btn-submit-form:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-submit-form i {
    margin-right: 8px;
}

.chat-input-container {
    padding: 16px;
    background: #1e293b;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #3B82F6;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chat-send-btn {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    border: none;
    color: white;
    padding: 0 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.05);
}

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

.chat-attach-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 0 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-attach-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: scale(1.05);
}

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

/* Image Preview */
.chat-image-preview {
    padding: 12px 16px;
    background: #0f172a;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.chat-image-preview img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 8px;
    object-fit: contain;
}

.chat-image-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.chat-image-remove:hover {
    background: rgba(239, 68, 68, 0.8);
    transform: scale(1.1);
}

/* Chat Message Image */
.chat-message-image {
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 300px;
}

.chat-message-image img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-message-image img:hover {
    transform: scale(1.02);
}

.chat-message-text {
    margin-top: 4px;
}

/* Typing Indicator */
.chat-typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3B82F6;
    margin: 0 16px 8px 16px;
    border-radius: 8px;
    color: #93c5fd;
    font-size: 13px;
    font-style: italic;
    animation: fadeIn 0.3s ease;
}

.chat-typing-indicator #typingText {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-typing-indicator::before {
    content: '✍️';
    font-size: 14px;
}

.typing-indicator {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #1e293b;
    border-radius: 12px;
    width: fit-content;
}

.typing-indicator.active {
    display: flex;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #64748b;
    animation: typing 1.4s infinite;
}

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

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

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

/* Chat Closed Message */
.chat-closed-message {
    padding: 20px;
    margin: 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    text-align: center;
}

.chat-closed-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.chat-closed-content i {
    font-size: 32px;
    color: #EF4444;
    margin-bottom: 4px;
}

.chat-closed-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
    font-weight: 500;
    margin: 0;
}

.chat-closed-question {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin: 4px 0 0 0;
}

.chat-closed-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    width: 100%;
    max-width: 300px;
}

.chat-btn-yes,
.chat-btn-no {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.chat-btn-yes {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
}

.chat-btn-yes:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.chat-btn-no {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-btn-no:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Responsive */
@media (max-width: 640px) {
    .chat-widget {
        right: 12px;
        bottom: 90px;
        width: calc(100vw - 24px);
        height: calc(100vh - 120px);
    }
    
    .chat-button {
        right: 12px;
        bottom: 12px;
    }
}

