/**
 * Estilos para el Sistema de Chat Integrado
 * iSeller Store
 */

/* ===================================
   1. BOTÓN FLOTANTE
   =================================== */

.chat-floating-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
    border: none;
}

.chat-floating-button:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.5);
}

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

.chat-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* ===================================
   2. MODAL DE CHAT
   =================================== */

.chat-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

.chat-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-modal {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    height: 90vh;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* ===================================
   3. HEADER DEL CHAT
   =================================== */

.chat-header {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-header-info {
    flex: 1;
}

.chat-header-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-subtitle span {
    display: flex;
    align-items: center;
    gap: 4px;
}

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

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

/* ===================================
   4. VISTAS DEL CHAT
   =================================== */

.chat-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.chat-view {
    display: none;
    flex-direction: column;
    height: 100%;
}

.chat-view.active {
    display: flex;
}

/* Vista de inicio */
.chat-start-view {
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    justify-content: center;
}

.chat-welcome-message {
    text-align: center;
    color: #6b7280;
    margin-bottom: 24px;
}

.chat-welcome-message h3 {
    color: #111827;
    font-size: 20px;
    margin-bottom: 8px;
}

.chat-action-btn {
    width: 100%;
    padding: 16px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.chat-action-btn:hover {
    background: #f9fafb;
    border-color: #10b981;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.chat-action-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    flex-shrink: 0;
}

.chat-action-content h4 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 4px 0;
}

.chat-action-content p {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

/* ===================================
   5. NUEVA CONVERSACIÓN
   =================================== */

.chat-new-conversation {
    padding: 20px;
    overflow-y: auto;
}

.chat-form-group {
    margin-bottom: 20px;
}

.chat-form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.chat-form-select,
.chat-form-input,
.chat-form-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    font-family: inherit;
}

.chat-form-select:focus,
.chat-form-input:focus,
.chat-form-textarea:focus {
    outline: none;
    border-color: #10b981;
}

.chat-form-textarea {
    resize: vertical;
    min-height: 100px;
}

.chat-category-option {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

.chat-back-btn {
    padding: 10px 16px;
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    margin-bottom: 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.chat-back-btn:hover {
    background: #e5e7eb;
}

/* ===================================
   6. LISTA DE CONVERSACIONES
   =================================== */

.chat-conversations-list {
    overflow-y: auto;
    padding: 12px;
}

.chat-conversation-item {
    padding: 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-conversation-item:hover {
    background: #f9fafb;
    border-color: #10b981;
    transform: translateX(4px);
}

.chat-conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.chat-conversation-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    flex: 1;
}

.chat-conversation-badge {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.chat-conversation-badge.abierta {
    background: #dbeafe;
    color: #1e40af;
}

.chat-conversation-badge.cerrada {
    background: #e5e7eb;
    color: #6b7280;
}

.chat-conversation-preview {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-conversation-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 12px;
    color: #9ca3af;
}

/* ===================================
   7. CONVERSACIÓN ACTIVA
   =================================== */

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: messageSlide 0.2s ease;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    position: relative;
}

.chat-message.user .chat-message-bubble {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.admin .chat-message-bubble {
    background: white;
    color: #111827;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.chat-message-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message-time {
    font-size: 11px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.chat-message.admin .chat-message-time {
    color: #9ca3af;
}

.chat-message-status i {
    font-size: 14px;
}

/* ===================================
   8. INPUT DE MENSAJE
   =================================== */

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

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

.chat-input-field {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-input-field:focus {
    outline: none;
    border-color: #10b981;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

/* ===================================
   9. ESTADOS Y UTILIDADES
   =================================== */

.chat-loading {
    text-align: center;
    padding: 32px;
    color: #9ca3af;
}

.chat-spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #10b981;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

.chat-empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #9ca3af;
}

.chat-empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.chat-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    width: fit-content;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    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;
}

/* ===================================
   10. ANIMACIONES
   =================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

/* ===================================
   11. RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    .chat-modal {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .chat-floating-button {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
    
    .chat-floating-button i {
        font-size: 24px;
    }
    
    .chat-message-bubble {
        max-width: 85%;
    }
}

/* Scrollbar personalizado */
.chat-messages-container::-webkit-scrollbar,
.chat-conversations-list::-webkit-scrollbar,
.chat-new-conversation::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-container::-webkit-scrollbar-track,
.chat-conversations-list::-webkit-scrollbar-track,
.chat-new-conversation::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.chat-messages-container::-webkit-scrollbar-thumb,
.chat-conversations-list::-webkit-scrollbar-thumb,
.chat-new-conversation::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-messages-container::-webkit-scrollbar-thumb:hover,
.chat-conversations-list::-webkit-scrollbar-thumb:hover,
.chat-new-conversation::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}
