/* ===================================
   CHAT BOT - PUNTO 11
   Estilos para el chat bot integrado
   =================================== */

.chat-widget {
    position: fixed;
    bottom: var(--spacing-xl);
    left: var(--spacing-xl);
    z-index: var(--z-modal);
    font-family: var(--font-family-primary);
}

/* === TRIGGER BUTTON === */
.chat-trigger {
    width: 70px;
    height: 50px;
    border-radius: 25px 25px 25px 5px;
    background: var(--gradient-button);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-xl);
    transition: all var(--transition-normal);
    position: relative;
    border: 3px solid var(--white);
}

.chat-trigger:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-2xl), var(--shadow-glow);
}

.chat-avatar {
    width: 35px;
    height: 25px;
    border-radius: 15px 15px 15px 3px;
    overflow: hidden;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background: #ff4757;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: var(--font-size-xs);
    font-weight: 600;
    border: 2px solid var(--white);
    animation: pulse-notification 2s infinite;
}

/* === CHAT CONTAINER === */
.chat-container {
    position: absolute;
    bottom: 80px;
    left: 0;
    width: 380px;
    height: 500px;
    background: var(--white);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all var(--transition-normal);
    overflow: hidden;
}

.chat-widget.open .chat-container {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* === CHAT HEADER === */
.chat-header {
    background: var(--gradient-button);
    color: var(--white);
    padding: var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.chat-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.chat-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-header-text h4 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.chat-status {
    font-size: var(--font-size-xs);
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-status.online::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #2ed573;
    border-radius: 50%;
    animation: pulse-online 2s infinite;
}

.chat-close {
    background: none;
    border: none;
    color: var(--white);
    font-size: var(--font-size-lg);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

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

/* === CHAT MESSAGES === */
.chat-messages {
    flex: 1;
    padding: var(--spacing-lg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    background: var(--gray-50);
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--gray-100);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-full);
}

.chat-message {
    display: flex;
    gap: var(--spacing-sm);
    animation: messageSlideIn 0.3s ease-out;
}

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

.chat-message.user .message-content {
    background: var(--gradient-button);
    color: var(--white);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
    max-width: 80%;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.message-content {
    background: var(--white);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
    padding: var(--spacing-md);
    max-width: 80%;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
}

.message-text {
    margin-bottom: var(--spacing-sm);
    line-height: 1.5;
    color: var(--gray-800);
}

.message-text .emoji {
    font-size: 1.1em;
}

.message-text strong {
    color: var(--primary-blue);
    font-weight: 600;
}

.message-time {
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    opacity: 0.7;
}

.chat-message.user .message-time {
    color: rgba(255, 255, 255, 0.8);
}

/* === MESSAGE OPTIONS === */
.message-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
}

.message-option {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-full);
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--gray-700);
}

.message-option:hover {
    background: var(--primary-cyan);
    color: var(--white);
    border-color: var(--primary-cyan);
    transform: translateY(-1px);
}

/* === QUICK ACTIONS === */
.chat-quick-actions {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.quick-action {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--gray-700);
    flex: 1;
    justify-content: center;
    min-width: 70px;
}

.quick-action:hover {
    background: var(--gradient-button);
    color: var(--white);
    border-color: var(--primary-purple);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.quick-action i {
    font-size: 0.9em;
}

/* === CHAT INPUT === */
.chat-input-container {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: var(--spacing-lg);
}

.chat-input-wrapper {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

#chatInput {
    flex: 1;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-full);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: var(--font-size-sm);
    outline: none;
    transition: border-color var(--transition-fast);
}

#chatInput:focus {
    border-color: var(--primary-cyan);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-button);
    border: none;
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.chat-send:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

/* === TYPING INDICATOR === */
.chat-typing {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) 0;
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    font-style: italic;
}

.chat-typing span {
    width: 4px;
    height: 4px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: typing-dots 1.4s infinite ease-in-out;
}

.chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.chat-typing span:nth-child(2) { animation-delay: -0.16s; }
.chat-typing span:nth-child(3) { animation-delay: 0s; }

/* === ANIMACIONES === */
@keyframes pulse-notification {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

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

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

@keyframes typing-dots {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 20%, 60%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    80% {
        transform: translateY(-5px);
    }
}

/* === TEMA OSCURO === */
[data-theme="dark"] .chat-container {
    background: var(--gray-800);
    border-color: var(--gray-700);
}

[data-theme="dark"] .chat-messages {
    background: var(--gray-900);
}

[data-theme="dark"] .message-content {
    background: var(--gray-700);
    border-color: var(--gray-600);
}

[data-theme="dark"] .message-text {
    color: var(--gray-200);
}

[data-theme="dark"] .message-option {
    background: var(--gray-600);
    border-color: var(--gray-500);
    color: var(--gray-200);
}

[data-theme="dark"] .quick-action {
    background: var(--gray-700);
    border-color: var(--gray-600);
    color: var(--gray-200);
}

[data-theme="dark"] .chat-quick-actions,
[data-theme="dark"] .chat-input-container {
    background: var(--gray-800);
    border-color: var(--gray-700);
}

[data-theme="dark"] #chatInput {
    background: var(--gray-700);
    border-color: var(--gray-600);
    color: var(--gray-200);
}

[data-theme="dark"] #chatInput::placeholder {
    color: var(--gray-400);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .chat-widget {
        bottom: calc(var(--mobile-bottom-nav-height) + var(--spacing-lg));
        left: var(--spacing-md);
    }
    
    .chat-container {
        width: calc(100vw - 2rem);
        max-width: 350px;
        height: 450px;
        left: 0;
    }
    
    .chat-trigger {
        width: 60px;
        height: 40px;
        border-radius: 20px 20px 20px 4px;
    }
    
    .chat-avatar {
        width: 30px;
        height: 20px;
        border-radius: 12px 12px 12px 2px;
    }
    
    .quick-action {
        font-size: 10px;
        padding: var(--spacing-xs);
        min-width: 60px;
    }
    
    .message-content {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .chat-container {
        width: calc(100vw - 1rem);
        height: 400px;
        bottom: 70px;
        right: 0;
        left: 0;
        margin: 0 auto;
    }
    
    .chat-widget {
        left: var(--spacing-sm);
    }
    
    .chat-trigger {
        width: 55px;
        height: 35px;
        border-radius: 18px 18px 18px 3px;
    }
    
    .chat-avatar {
        width: 25px;
        height: 18px;
        border-radius: 10px 10px 10px 2px;
    }
    
    .chat-notification {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
}

/* === ACCESIBILIDAD === */
@media (prefers-reduced-motion: reduce) {
    .chat-trigger,
    .chat-container,
    .message-option,
    .quick-action,
    .chat-send {
        transition: none;
    }
    
    .chat-notification,
    .chat-status.online::before,
    .chat-typing span {
        animation: none;
    }
    
    .messageSlideIn {
        animation: none;
    }
}

/* === HIGH CONTRAST === */
@media (prefers-contrast: high) {
    .chat-container {
        border: 2px solid var(--gray-800);
    }
    
    .message-content {
        border: 2px solid var(--gray-300);
    }
    
    .chat-message.user .message-content {
        border-color: var(--white);
    }
    
    .message-option,
    .quick-action {
        border: 2px solid var(--gray-400);
    }
}
