/**
 * Chat Widget Styles - Doer TI
 * Sistema de chat en vivo
 * Versión: 1.0
 */

/* ============================================
   Botón Flotante del Chat
   ============================================ */

.doer-chat-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #00D9A3 0%, #0066CC 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(0, 217, 163, 0.4);
    transition: all 0.3s ease;
    z-index: 9998;
    border: none;
    color: white;
    font-size: 1.8rem;
}

.doer-chat-toggle i {
    color: white;
    display: block;
    font-size: inherit;
}

.doer-chat-toggle:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 217, 163, 0.6);
}

.doer-chat-toggle.active {
    transform: scale(0.9);
}

.doer-chat-toggle .fa-times {
    display: none;
}

.doer-chat-toggle.active .fa-comments {
    display: none;
}

.doer-chat-toggle.active .fa-times {
    display: block;
}

/* Badge de notificación */
.doer-chat-toggle .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #FF6B6B;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid white;
}

/* ============================================
   Ventana del Chat
   ============================================ */

.doer-chat-widget {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 490px;
    max-width: calc(100vw - 40px);
    height: 800px;
    max-height: calc(100vh - 140px);
    background: #1a1a2e;
    border-radius: 20px;
    box-shadow: 0 15px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 9997;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.doer-chat-widget.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ============================================
   Header del Chat
   ============================================ */

.doer-chat-header {
    background: linear-gradient(135deg, #00D9A3 0%, #0066CC 100%);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 20px 20px 0 0;
    position: relative;
}

.doer-chat-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.doer-chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.doer-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.doer-chat-avatar i {
    font-size: 1.5rem;
    color: #0066CC;
    display: flex;
    align-items: center;
    justify-content: center;
}

.doer-chat-header-text h3 {
    margin: 0;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
}

.doer-chat-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.2rem;
}

.doer-chat-status-dot {
    width: 8px;
    height: 8px;
    background: #4ADE80;
    border-radius: 50%;
    animation: pulse-status 2s ease-in-out infinite;
}

@keyframes pulse-status {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

.doer-chat-status-text {
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.85rem;
}

.doer-chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.3rem;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.doer-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* ============================================
   Cuerpo del Chat (Mensajes)
   ============================================ */

.doer-chat-body {
    flex: 1;
    min-height: 150px;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #0a0a0a;
}

/* Scrollbar personalizado */
.doer-chat-body::-webkit-scrollbar {
    width: 6px;
}

.doer-chat-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.doer-chat-body::-webkit-scrollbar-thumb {
    background: rgba(0, 217, 163, 0.5);
    border-radius: 10px;
}

.doer-chat-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 217, 163, 0.7);
}

/* Mensajes */
.chat-message {
    display: flex;
    margin-bottom: 0.5rem;
    animation: fadeInMessage 0.3s ease;
}

@keyframes fadeInMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.received {
    justify-content: flex-start;
}

.chat-message.sent {
    justify-content: flex-end;
}

.message-content {
    max-width: 75%;
    padding: 0.9rem 1.1rem;
    border-radius: 15px;
    position: relative;
}

.chat-message.received .message-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 4px;
}

.chat-message.sent .message-content {
    background: linear-gradient(135deg, #00D9A3 0%, #0066CC 100%);
    border-bottom-right-radius: 4px;
}

.message-content p {
    margin: 0;
    color: white;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-time {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.4rem;
}

/* Indicador de escritura */
.typing-indicator .message-content {
    padding: 1rem 1.5rem;
}

.typing-dots {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ============================================
   Footer del Chat (Formulario)
   ============================================ */

.doer-chat-footer {
    padding: 1.2rem;
    background: #16213e;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 0 20px 20px;
}

.doer-chat-user-form {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.doer-chat-user-form input {
    padding: 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.doer-chat-user-form input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.doer-chat-user-form input:focus {
    outline: none;
    border-color: #00D9A3;
    background: rgba(255, 255, 255, 0.08);
}

.doer-chat-input-group {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
}

.doer-chat-input-group textarea {
    flex: 1;
    padding: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 0.95rem;
    resize: none;
    height: 45px;
    max-height: 120px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.doer-chat-input-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.doer-chat-input-group textarea:focus {
    outline: none;
    border-color: #00D9A3;
    background: rgba(255, 255, 255, 0.08);
    height: 80px;
}

.doer-chat-send-btn {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #00D9A3 0%, #0066CC 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.doer-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 217, 163, 0.4);
}

.doer-chat-send-btn:active {
    transform: scale(0.95);
}

/* Error messages */
.chat-error {
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.5);
    color: #FF6B6B;
    padding: 0.7rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 0.8rem;
    animation: fadeInMessage 0.3s ease;
}

/* ============================================
   Preguntas Sugeridas
   ============================================ */

.doer-chat-suggestions {
    padding: 1rem 1.2rem;
    background: #0f1626;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 350px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.doer-chat-suggestions.hidden {
    display: none;
}

/* Scrollbar para las sugerencias */
.doer-chat-suggestions::-webkit-scrollbar {
    width: 4px;
}

.doer-chat-suggestions::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.doer-chat-suggestions::-webkit-scrollbar-thumb {
    background: rgba(0, 217, 163, 0.3);
    border-radius: 10px;
}

.suggestions-header {
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.suggestions-header span {
    color: #00D9A3;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.suggestions-toggle {
    background: transparent;
    border: none;
    color: #00D9A3;
    cursor: pointer;
    padding: 0.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.suggestions-toggle:hover {
    opacity: 1;
    transform: scale(1.1);
}

.suggestions-toggle i {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

/* Estado colapsado de las sugerencias */
.doer-chat-suggestions.collapsed .suggestions-grid {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.doer-chat-suggestions.collapsed .suggestions-toggle i {
    transform: rotate(180deg);
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    max-height: 2000px;
    overflow: visible;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.suggestion-btn {
    background: linear-gradient(135deg, rgba(0, 217, 163, 0.1) 0%, rgba(0, 102, 204, 0.1) 100%);
    border: 1px solid rgba(0, 217, 163, 0.3);
    color: #fff;
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    text-align: left;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-btn i {
    color: #00D9A3;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.suggestion-btn:hover {
    background: linear-gradient(135deg, rgba(0, 217, 163, 0.2) 0%, rgba(0, 102, 204, 0.2) 100%);
    border-color: rgba(0, 217, 163, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 217, 163, 0.2);
}

.suggestion-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 217, 163, 0.2);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .doer-chat-toggle {
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
        font-size: 1.6rem;
    }

    .doer-chat-widget {
        bottom: 90px;
        right: 20px;
        left: 20px;
        width: auto;
        height: 550px;
        max-height: calc(100vh - 120px);
    }

    .doer-chat-header {
        padding: 1.2rem;
    }

    .doer-chat-body {
        padding: 1rem;
    }

    .doer-chat-footer {
        padding: 1rem;
    }

    .message-content {
        max-width: 85%;
    }

    .suggestions-grid {
        grid-template-columns: 1fr;
    }

    .doer-chat-suggestions {
        padding: 0.8rem 1rem;
    }
}

@media (max-width: 480px) {
    .doer-chat-widget {
        height: 500px;
    }

    .doer-chat-header-text h3 {
        font-size: 1rem;
    }

    .doer-chat-status-text {
        font-size: 0.8rem;
    }

    .suggestion-btn {
        font-size: 0.8rem;
        padding: 0.6rem 0.8rem;
    }
}

/* ============================================
   Animaciones y efectos adicionales
   ============================================ */

/* Efecto de pulsación para nuevos mensajes */
@keyframes pulse-new-message {
    0%, 100% {
        box-shadow: 0 8px 30px rgba(0, 217, 163, 0.4);
    }
    50% {
        box-shadow: 0 8px 30px rgba(0, 217, 163, 0.8);
    }
}

.doer-chat-toggle.has-new-message {
    animation: pulse-new-message 2s ease-in-out infinite;
}
