/**
 * DigitalBox - CSS do Chat de Suporte
 * Estilos modernos para o sistema de chat
 */

/* =====================================================
   BOTÃO FLUTUANTE
   ===================================================== */

.chat-floating-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    background: var(--gradient-red);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.chat-floating-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 0, 0, 0.6);
}

.chat-floating-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

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

.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 600px;
    background: var(--card-black);
    border: 1px solid var(--border-black);
    border-radius: var(--radius-xl);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    transform: translateY(calc(100% + 40px));
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

/* Header do Chat */
.chat-widget-header {
    background: var(--gradient-red);
    color: white;
    padding: 1rem;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header-info i {
    font-size: 1.5rem;
}

.chat-header-info h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.chat-status {
    font-size: 0.75rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chat-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #00ff00;
    border-radius: 50%;
    display: inline-block;
    animation: blink 2s infinite;
}

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

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
}

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

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Corpo do Chat */
.chat-widget-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--soft-black);
}

.chat-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    pointer-events: none;
}

.chat-view.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
}

/* =====================================================
   LISTA DE CONVERSAS
   ===================================================== */

.chat-actions {
    padding: 1rem;
    border-bottom: 1px solid var(--border-black);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--card-black);
    border: 1px solid var(--border-black);
    border-radius: var(--radius-lg);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-item:hover {
    background: var(--pure-black);
    border-color: var(--primary-red);
    transform: translateX(5px);
}

.chat-item.unread {
    border-left: 3px solid var(--primary-red);
}

.chat-item-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.chat-item-header strong {
    color: white;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    color: var(--text-gray);
    font-size: 0.75rem;
    white-space: nowrap;
}

.chat-item-preview {
    color: var(--text-gray);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.5rem;
}

.chat-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-status-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 50px;
    font-weight: 600;
}

.chat-status-badge.status-open {
    background: rgba(0, 255, 0, 0.2);
    color: #00ff00;
}

.chat-status-badge.status-waiting {
    background: rgba(255, 165, 0, 0.2);
    color: #ffa500;
}

.chat-status-badge.status-answered {
    background: rgba(0, 123, 255, 0.2);
    color: #007bff;
}

.chat-status-badge.status-closed {
    background: rgba(128, 128, 128, 0.2);
    color: #888;
}

.chat-unread-count {
    background: var(--primary-red);
    color: white;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 50px;
    font-weight: bold;
}

/* Estados vazios e loading */
.chat-loading,
.chat-empty,
.chat-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-gray);
    text-align: center;
}

.chat-loading i,
.chat-empty i,
.chat-error i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.chat-error {
    color: var(--primary-red);
}

/* Skeleton Loader */
.skeleton-loader {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.skeleton-message {
    display: flex;
    gap: 0.75rem;
    animation: fadeIn 0.3s;
}

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

.skeleton-message.right {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.skeleton-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(90deg, var(--soft-black) 25%, var(--card-black) 50%, var(--soft-black) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-content {
    flex: 1;
    max-width: 70%;
}

.skeleton-header {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.skeleton-name {
    width: 80px;
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--soft-black) 25%, var(--card-black) 50%, var(--soft-black) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-time {
    width: 50px;
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--soft-black) 25%, var(--card-black) 50%, var(--soft-black) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-bubble {
    height: 50px;
    border-radius: var(--radius-lg);
    background: linear-gradient(90deg, var(--soft-black) 25%, var(--card-black) 50%, var(--soft-black) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Estado de envio */
.chat-message.message-sending {
    opacity: 0.7;
}

.message-status {
    display: inline-flex;
    align-items: center;
    margin-left: 0.5rem;
    font-size: 0.65rem;
    color: var(--text-gray);
}

.message-status i {
    margin-left: 0.25rem;
}

.message-status.sending i {
    animation: spin 1s linear infinite;
}

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

.message-status.sent i {
    color: var(--primary-red);
}

/* =====================================================
   FORMULÁRIO DE NOVA CONVERSA
   ===================================================== */

.btn-back {
    background: transparent;
    border: none;
    color: var(--text-gray);
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-black);
}

.btn-back:hover {
    color: white;
    background: var(--card-black);
}

.chat-new-form {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    color: white;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--card-black);
    border: 1px solid var(--border-black);
    border-radius: var(--radius-lg);
    color: white;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-red);
}

.w-100 {
    width: 100%;
}

/* =====================================================
   VISUALIZAÇÃO DE CONVERSA
   ===================================================== */

.chat-conversation-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-black);
    background: var(--card-black);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Mensagem individual */
.chat-message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
}

.chat-message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    background: var(--gradient-red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

.chat-message.sent .message-avatar {
    display: none; /* Esconder avatar das mensagens enviadas */
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.message-header {
    display: none; /* Esconder header com nomes */
}

.message-text {
    background: var(--card-black);
    color: white;
    padding: 0.75rem;
    padding-bottom: 0.5rem;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.chat-message.sent .message-text {
    background: var(--gradient-red);
}

.message-time {
    display: block;
    text-align: right;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.65rem;
    margin-top: 0.35rem;
    font-weight: 400;
}

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

.message-image {
    margin-bottom: 0.5rem;
}

.message-image img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-image img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.3);
}

/* =====================================================
   ÁREA DE INPUT
   ===================================================== */

.chat-input-area {
    border-top: 1px solid var(--border-black);
    background: var(--card-black);
}

.chat-closed-notice {
    padding: 0.75rem 1rem;
    background: rgba(255, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 0, 0, 0.3);
    color: var(--primary-red);
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.chat-closed-notice i {
    margin-right: 0.5rem;
}

.chat-image-preview {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-black);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-image-preview img {
    max-width: 60px;
    max-height: 60px;
    border-radius: var(--radius-md);
}

.btn-remove-image {
    background: var(--primary-red);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.chat-send-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
}

.chat-send-form input[type="text"] {
    flex: 1;
    background: var(--soft-black);
    border: 1px solid var(--border-black);
    border-radius: 50px;
    padding: 0.75rem 1rem;
    color: white;
    font-size: 0.9rem;
}

.chat-send-form input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-red);
}

.btn-send {
    background: var(--gradient-red) !important;
}

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

/* =====================================================
   RESPONSIVIDADE
   ===================================================== */

@media (max-width: 480px) {
    .chat-widget {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: 10px;
        bottom: 10px;
    }

    .chat-floating-btn {
        right: 15px;
        bottom: 15px;
    }

    .chat-message {
        max-width: 90%;
    }
}

/* =====================================================
   SCROLLBAR PERSONALIZADA
   ===================================================== */

.chat-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.chat-new-form::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.chat-new-form::-webkit-scrollbar-track {
    background: var(--soft-black);
}

.chat-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.chat-new-form::-webkit-scrollbar-thumb {
    background: var(--border-black);
    border-radius: 10px;
}

.chat-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.chat-new-form::-webkit-scrollbar-thumb:hover {
    background: var(--primary-red);
}
