/* Modal de Conversa */
.conversation-modal {
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.conversation-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    border-radius: 15px 15px 0 0;
    color: white;
}

.lead-profile-summary {
    display: flex;
    gap: 15px;
    align-items: center;
}

.lead-profile-summary .lead-avatar-img {
    width: 60px;
    height: 60px;
    border: 3px solid white;
}

.profile-info h3 {
    margin: 0 0 5px 0;
    font-size: 20px;
    color: white;
}

.profile-info a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 14px;
}

.tipo-badge-large {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin-top: 5px;
}

.btn-close-modal {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-close-modal:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.conversation-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    background: var(--bg-primary);
}

.conversation-timeline {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message-item {
    display: flex;
    gap: 10px;
    animation: fadeInMessage 0.3s ease;
}

@keyframes fadeInMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-item.received {
    justify-content: flex-start;
}

.message-item.sent {
    justify-content: flex-end;
}

.message-avatar {
    flex-shrink: 0;
}

.message-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.message-content {
    max-width: 70%;
}

.message-bubble {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
}

.message-item.sent .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-bubble p {
    margin: 0;
    line-height: 1.5;
    font-size: 14px;
}

.message-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 5px;
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 0 5px;
}

.sent-tag {
    color: #667eea;
    font-weight: 600;
}

.action-alert {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #856404;
    font-weight: 600;
    margin-top: 10px;
}

.alert-icon {
    font-size: 24px;
}

.conversation-notes {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 10px;
    margin-top: 20px;
    border-left: 4px solid #667eea;
}

.conversation-notes h4 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
    font-size: 14px;
}

.conversation-notes p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.conversation-modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--bg-secondary);
    border-radius: 0 0 15px 15px;
}

.btn-action {
    flex: 1;
    min-width: 150px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-action.btn-primary {
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    color: white;
}

.btn-action.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-action.btn-warning {
    background: #ffc107;
    color: #000;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.tipo-badge {
    font-size: 11px;
    opacity: 0.8;
}

/* Responsivo */
@media (max-width: 768px) {
    .conversation-modal {
        width: 95%;
        max-height: 90vh;
    }

    .conversation-modal-footer {
        flex-direction: column;
    }

    .btn-action {
        width: 100%;
    }

    .message-content {
        max-width: 85%;
    }
}

/* ========================================
   GLASSMORPHISM DARK THEME - MENSAGENS
   ======================================== */

/* Conversation Modal - Glassmorphism */
[data-theme="dark"] .conversation-modal {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .conversation-modal-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(139, 92, 246, 0.3) 100%);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .conversation-modal-body {
    background: rgba(17, 24, 39, 0.6);
}

[data-theme="dark"] .conversation-modal-footer {
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Message Bubbles - Glassmorphism */
[data-theme="dark"] .message-bubble {
    background: rgba(31, 41, 55, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .message-item.sent .message-bubble {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.4) 0%, rgba(139, 92, 246, 0.4) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow:
        0 4px 12px rgba(99, 102, 241, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Conversation Notes - Glassmorphism */
[data-theme="dark"] .conversation-notes {
    background: rgba(31, 41, 55, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 4px solid #6366f1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Action Alert - Glassmorphism */
[data-theme="dark"] .action-alert {
    background: rgba(245, 158, 11, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-left: 4px solid #f59e0b;
    color: #fbbf24;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

/* Buttons - Unified Glassmorphism Style */
[data-theme="dark"] .btn-action.btn-primary,
[data-theme="dark"] .btn-open-instagram {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: 2px solid rgba(99, 102, 241, 0.3);
    box-shadow:
        0 4px 12px rgba(99, 102, 241, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

[data-theme="dark"] .btn-action.btn-primary:hover,
[data-theme="dark"] .btn-open-instagram:hover {
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow:
        0 6px 20px rgba(99, 102, 241, 0.4),
        0 0 0 4px rgba(99, 102, 241, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

[data-theme="dark"] .btn-action.btn-secondary,
[data-theme="dark"] .btn-view-all {
    background: rgba(31, 41, 55, 0.6);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

[data-theme="dark"] .btn-action.btn-secondary:hover,
[data-theme="dark"] .btn-view-all:hover {
    background: rgba(31, 41, 55, 0.8);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow:
        0 4px 12px rgba(99, 102, 241, 0.2),
        0 0 0 4px rgba(99, 102, 241, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .btn-action.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: 2px solid rgba(245, 158, 11, 0.3);
    color: #fff;
    box-shadow:
        0 4px 12px rgba(245, 158, 11, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .btn-action.btn-warning:hover {
    border-color: rgba(245, 158, 11, 0.6);
    box-shadow:
        0 6px 20px rgba(245, 158, 11, 0.4),
        0 0 0 4px rgba(245, 158, 11, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Close Button - Glassmorphism */
[data-theme="dark"] .btn-close-modal {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

[data-theme="dark"] .btn-close-modal:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Refresh Button - Glassmorphism */
[data-theme="dark"] .btn-refresh-widget {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .btn-refresh-widget:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Instagram Widget - Glassmorphism */
[data-theme="dark"] .instagram-widget-container {
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .instagram-widget-header {
    background: linear-gradient(135deg, rgba(131, 58, 180, 0.4) 0%, rgba(253, 29, 29, 0.3) 50%, rgba(252, 176, 69, 0.3) 100%);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(131, 58, 180, 0.3);
}

[data-theme="dark"] .instagram-widget-footer {
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Conversation Items - Glassmorphism */
[data-theme="dark"] .conversation-item {
    background: rgba(31, 41, 55, 0.6);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

[data-theme="dark"] .conversation-item:hover {
    background: rgba(31, 41, 55, 0.8);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow:
        0 4px 16px rgba(99, 102, 241, 0.2),
        0 0 0 4px rgba(99, 102, 241, 0.05);
}

[data-theme="dark"] .conversation-item.unread {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow:
        0 4px 12px rgba(99, 102, 241, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Avatar Borders - Glassmorphism */
[data-theme="dark"] .lead-avatar-img {
    border: 3px solid rgba(99, 102, 241, 0.5);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .message-avatar-img {
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Scrollbar - Use Global Style */
[data-theme="dark"] .conversations-list::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 10px;
}

[data-theme="dark"] .conversations-list::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

[data-theme="dark"] .conversations-list::-webkit-scrollbar-track {
    background: rgba(17, 24, 39, 0.4);
}

/* Badges - Enhanced Glassmorphism */
[data-theme="dark"] .badge-waiting {
    background: rgba(245, 158, 11, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fbbf24;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .badge-responded {
    background: rgba(16, 185, 129, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #34d399;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

[data-theme="dark"] .unread-counter {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: 1px solid rgba(239, 68, 68, 0.4);
    box-shadow:
        0 2px 8px rgba(239, 68, 68, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .tipo-badge-large {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Loading Spinner - Glassmorphism */
[data-theme="dark"] .loading-spinner {
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: #6366f1;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

/* Empty State - Glassmorphism */
[data-theme="dark"] .empty-widget-state {
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 12px;
}

/* ========================================
   WIDGET INSTAGRAM - CONVERSAS
   ======================================== */

.dashboard-instagram-row {
    margin-top: 30px;
}

.instagram-widget-container {
    background: var(--bg-secondary);
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.instagram-widget-header {
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.instagram-widget-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-refresh-widget {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 12px 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
}

.btn-refresh-widget:hover {
    background: rgba(255, 255, 255, 0.3);
    /* transform: rotate(180deg); */
}

.conversations-list {
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
}

.conversations-list::-webkit-scrollbar {
    width: 8px;
}

.conversations-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 10px;
}

.conversations-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.conversations-list::-webkit-scrollbar-thumb:hover {
    background: #833ab4;
}

.conversation-item {
    display: flex;
    gap: 12px;
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    margin-bottom: 10px;
    background: var(--bg-primary);
}

.conversation-item:hover {
    background: var(--hover-bg);
    transform: translateX(5px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.conversation-item.unread {
    border-color: #833ab4;
    background: linear-gradient(135deg, rgba(131, 58, 180, 0.05) 0%, rgba(253, 29, 29, 0.05) 100%);
}

.lead-avatar-container {
    position: relative;
    flex-shrink: 0;
}

.lead-avatar-img {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: 3px solid #833ab4;
    object-fit: cover;
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid var(--bg-primary);
    background: #28a745;
}

.status-dot.offline {
    background: #6c757d;
}

.conversation-content {
    flex: 1;
    min-width: 0;
}

.lead-info-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5px;
}

.lead-name-box {
    min-width: 0;
    flex: 1;
}

.lead-name-text {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
    margin: 0 0 3px 0;
}

.lead-username {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.tipo-badge {
    font-size: 11px;
    opacity: 0.8;
}

.conversation-time {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.last-message-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.message-text {
    color: var(--text-secondary);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.conversation-item.unread .message-text {
    color: var(--text-primary);
    font-weight: 600;
}

.message-badge {
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-waiting {
    background: #ffc107;
    color: #000;
}

.badge-responded {
    background: #28a745;
    color: white;
}

.unread-counter {
    background: #dc3545;
    color: white;
    border-radius: 50%;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
}

.instagram-widget-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
}

.btn-instagram-action {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-open-instagram {
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    color: white;
}

.btn-open-instagram:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(131, 58, 180, 0.4);
}

.btn-view-all {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-view-all:hover {
    background: var(--hover-bg);
    border-color: #833ab4;
}

.empty-widget-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-widget-icon {
    font-size: 64px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-widget-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.empty-widget-text {
    font-size: 14px;
    line-height: 1.6;
}

.loading-widget {
    padding: 40px;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: #833ab4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}


@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsivo */
@media (max-width: 768px) {
    .conversations-list {
        max-height: 400px;
    }

    .lead-avatar-img {
        width: 45px;
        height: 45px;
    }

    .instagram-widget-footer {
        flex-direction: column;
    }

    .btn-instagram-action {
        width: 100%;
    }
}

/* ========================================
   PREVIEW DE MENSAGENS - WIDGET INSTAGRAM
   ======================================== */

.conversation-messages {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.message-preview {
    display: flex;
    gap: 6px;
    font-size: 13px;
    line-height: 1.4;
}

.message-preview .message-author {
    font-weight: 600;
    flex-shrink: 0;
    font-size: 12px;
}

.message-preview.message-received .message-author {
    color: #667eea;
}

.message-preview.message-sent .message-author {
    color: #28a745;
}

.message-preview .message-text {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.conversation-item.unread .message-preview.message-received .message-text {
    color: var(--text-primary);
    font-weight: 600;
}

/* Ajustar espaçamento do badge */
.conversation-messages .message-badge {
    margin-top: 4px;
    align-self: flex-start;
}


/* Badge de palavra-chave no widget */
.tipo-badge {
    font-size: 11px;
    opacity: 0.8;
}

/* Cores diferentes para cada tipo */
[data-tipo="direct"] .tipo-badge {
    color: #667eea;
}

[data-tipo="comentario"] .tipo-badge {
    color: #f5576c;
}

[data-tipo="palavra-chave"] .tipo-badge {
    color: #43e97b;
}