@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --bg-main: #0B0E14;
    --bg-sidebar: #131722;
    --bg-card: #1C212E;
    --bg-message-in: #2A3142;
    --bg-message-out: #8B5CF6;
    --text-main: #F8FAFC;
    --text-muted: #64748B;
    --accent: #A855F7;
    --accent-hover: #9333EA;
    --border: #2D3748;
    --radius: 16px;
}

/* Premium Enhancements */
.inner-sidebar, .contact-sidebar {
    background: rgba(19, 23, 34, 0.7) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.contact-sidebar {
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-right: none;
}

.avatar {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.contact-item:hover .avatar {
    transform: scale(1.1);
}

.btn-mode.active {
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.spin {
    animation: spin 1s linear infinite;
}

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

#ai-summary-content {
    animation: fadeInSlide 0.4s ease-out;
}

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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    /* Banner no topo */
    overflow: hidden;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    width: 100%;
}

/* Impersonation Banner */
.impersonation-banner {
    background: linear-gradient(90deg, #A855F7, #6366F1);
    color: white;
    padding: 10px 20px;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.banner-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-size: 0.9rem;
    font-weight: 500;
}

.banner-content i {
    font-size: 1.1rem;
}

.btn-stop-impersonation {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-stop-impersonation:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* Premium Tooltip */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    background-color: var(--bg-card);
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    border: 1px solid var(--border);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    visibility: hidden;
    display: block;
    /* Mantém no DOM para transição */
}

.sidebar.collapsed [data-tooltip]:hover::after {
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateY(-50%) translateX(18px) !important;
}

[data-tooltip]::before {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(2px);
    border: 6px solid transparent;
    border-right-color: var(--bg-card);
    /* Ajustado para a cor do card */
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    pointer-events: none;
}

.sidebar.collapsed [data-tooltip]:hover::before {
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateY(-50%) translateX(6px) !important;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible !important;
}

.sidebar.collapsed {
    width: 80px;
    scrollbar-width: none;
}

.sidebar.collapsed::-webkit-scrollbar,
.sidebar.collapsed *::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.sidebar.collapsed,
.sidebar.collapsed * {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 80px;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
    overflow: visible;
}

.btn-toggle-menu {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-left: auto;
}

.btn-toggle-menu:hover {
    color: var(--accent);
}

.sidebar.collapsed .btn-toggle-menu {
    margin-left: 0;
    width: 100%;
    max-width: 80px;
}

.sidebar.collapsed .brand-logo,
.sidebar.collapsed .brand-name,
.sidebar.collapsed .profile-selector-container {
    display: none;
}

.brand-logo {
    width: 32px;
    height: 32px;
    background-color: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Evita scroll horizontal no modo normal */
}

.nav-group-label {
    padding: 24px 12px 12px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    max-width: 100%;
    position: relative;
    /* Importante para tooltip */
}

.nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.nav-item i {
    font-size: 1.1rem;
    min-width: 24px;
    text-align: center;
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-group-label,
.sidebar.collapsed .nav-dropdown-toggle i:last-child {
    display: none !important;
}

.sidebar.collapsed .sidebar-nav {
    padding: 0 8px;
    overflow: visible !important;
    /* Essencial para tooltips */
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px;
    width: 100%;
    max-width: 80px;
}

.sidebar.collapsed .nav-sub-menu {
    padding-left: 0;
    margin-left: 0;
    border-left: none;
    opacity: 1;
    /* Garantir visibilidade se aberto */
}

.sidebar.collapsed .sub-nav-item {
    justify-content: center;
    padding: 10px 0;
}

.sidebar.collapsed .sub-nav-item span {
    display: none;
}

.sidebar.collapsed .nav-group-label {
    text-align: center;
    padding: 20px 0 10px;
}

.sidebar.collapsed .profile-info {
    display: none;
}

.sidebar.collapsed .user-profile {
    flex-direction: column;
    gap: 12px;
    padding: 0;
    overflow: visible;
}

.sidebar.collapsed .user-profile .btn-icon {
    display: flex;
    margin-left: 0 !important;
}

.sidebar.collapsed .sidebar-footer {
    padding: 24px 0;
    display: flex;
    justify-content: center;
}

.nav-item:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--accent);
    background-color: rgba(168, 85, 247, 0.1);
}

/* Nav Dropdown */
.nav-dropdown {
    display: flex;
    flex-direction: column;
}

.nav-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.nav-dropdown-toggle i:last-child {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.nav-dropdown.open .nav-dropdown-toggle i:last-child {
    transform: rotate(180deg);
}

.nav-sub-menu {
    max-height: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding-left: 12px;
    margin-left: 16px;
    border-left: 1px solid var(--border);
    opacity: 0;
}

.nav-dropdown.open .nav-sub-menu {
    max-height: 500px;
    opacity: 1;
    margin-top: 4px;
    margin-bottom: 12px;
}

.sidebar.collapsed .nav-dropdown.open .nav-sub-menu {
    overflow: visible;
}

.sub-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    /* Importante para tooltip */
}

.sub-nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.sub-nav-item i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.sub-nav-item:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
}

.sub-nav-item.active {
    color: var(--accent);
    background-color: rgba(168, 85, 247, 0.05);
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8B5CF6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
    box-shadow: 0 4px 10px rgba(168, 85, 247, 0.2);
}

.profile-info {
    overflow: hidden;
}

.profile-info h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-info p {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-card {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.dot-online {
    width: 8px;
    height: 8px;
    background-color: #10B981;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

/* Page Header */
.page-header {
    padding: 40px 40px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.page-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

/* Chat List Sidebar (Inner) */
.inner-sidebar {
    width: 320px;
    background-color: var(--bg-main);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.inner-sidebar-header {
    padding: 32px 24px;
    border-bottom: 1px solid var(--border);
}

.contact-list {
    flex: 1;
    overflow-y: auto;
}

.contact-item {
    padding: 16px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.contact-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.contact-item.active {
    background-color: rgba(168, 85, 247, 0.05);
    border-left: 3px solid var(--accent);
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
    /* Garante que a foto não saia dos limites */
}

.contact-info {
    flex: 1;
    overflow: hidden;
}

.contact-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.contact-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background-color: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
}

.chat-header {
    padding: 24px 32px;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-input-area {
    padding: 24px 32px;
    background-color: var(--bg-main);
    border-top: 1px solid var(--border);
}

.messages-container {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message {
    width: fit-content;
    max-width: 65%;
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.message.inbound {
    align-self: flex-start;
    background-color: var(--bg-card);
    border-bottom-left-radius: 4px;
}

.message.has-image {
    padding: 6px; /* Reduz padding para a imagem preencher melhor a bolha */
}

.message.has-image .image-wrapper {
    margin: 0;
    line-height: 0;
}

.chat-img {
    display: block;
    max-width: 250px;
    max-height: 300px;
    object-fit: cover;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.chat-img:hover {
    transform: scale(1.01);
}

.message.outbound {
    align-self: flex-end;
    background-color: #221e38;
    /* Roxo Profundo mais escuro */
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message.outbound.is-ai {
    background-color: #363060;
    /* Um tom apenas levemente diferente do padrão */
    /* border-left: 3px solid var(--accent); Borda sutil lateral para indicar a IA */
    border-bottom-right-radius: 4px;
}

.message.private {
    align-self: center;
    background-color: rgba(251, 191, 36, 0.05);
    color: #FBBF24;
    border: 1px dashed rgba(251, 191, 36, 0.3);
    max-width: 70%;
    border-radius: 12px;
    text-align: center;
    padding: 8px 16px;
    margin: 8px 0;
}

.message.private .message-time {
    color: rgba(251, 191, 36, 0.6);
}

.btn-mode {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-mode.active {
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent);
}

/* Estilo para o modo privado ativo */
.btn-mode#btn-mode-private.active {
    background: rgba(251, 191, 36, 0.1);
    color: #FBBF24;
}

.chat-input-area.private-active {
    background: rgba(251, 191, 36, 0.02) !important;
}

/* Sidebar Notes */
.sidebar-notes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-note {
    background: rgba(251, 191, 36, 0.05);
    border: 1px dashed rgba(251, 191, 36, 0.2);
    border-radius: 12px;
    padding: 12px;
    font-size: 0.85rem;
    color: var(--text-main);
    position: relative;
    line-height: 1.4;
}

.sidebar-note .note-date {
    display: block;
    font-size: 0.7rem;
    color: rgba(251, 191, 36, 0.6);
    margin-top: 6px;
    text-align: right;
}

.chat-input-area.private-active .form-control {
    border-color: rgba(251, 191, 36, 0.3);
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.btn-pagination {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-pagination:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-pagination.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Search Box Premium */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

.search-box .form-control {
    padding-left: 48px !important;
    background-color: rgba(255, 255, 255, 0.05);
    min-width: 350px;
    height: 48px;
}

.search-box .form-control:focus {
    background-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.1);
}


.message-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 2px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.badge.suspended {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge.active {
    background: rgba(34, 197, 94, 0.1);
    color: #22C55E;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* Views Management */
.view-section {
    display: none;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

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

/* Apenas a view de configurações e contas deve ser coluna */
#view-settings.active,
#view-accounts.active,
#view-users.active {
    flex-direction: column;
}

.view-content {
    flex: 1;
    padding: 0 40px 40px;
    overflow-y: auto;
}

/* Form Controls */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-control option {
    background-color: #1e1e2e;
    /* Fundo escuro para as opções */
    color: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Buttons */
.btn {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.2);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    color: var(--accent);
}

/* Botões de Ação da Tabela (Estilo Premium) */
.btn-action-table {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
}

.btn-action-table.edit {
    background: rgba(59, 130, 246, 0.1);
    color: #3B82F6;
    border-color: rgba(59, 130, 246, 0.2);
}

.btn-action-table.edit:hover {
    background: #3B82F6;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-action-table.delete {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    border-color: rgba(239, 68, 68, 0.2);
}

.btn-action-table.delete:hover {
    background: #EF4444;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Table */
.table-container {
    padding: 0 40px 40px;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.table td {
    padding: 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    background-color: rgba(16, 185, 129, 0.1);
    color: #10B981;
}

.badge.inactive {
    background-color: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background-color: var(--bg-card);
    width: 600px;
    max-width: 90%;
    border-radius: 20px;
    padding: 32px;
    border: 1px solid var(--border);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    position: relative;
    /* Necessário para o botão fechar absoluto */
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.btn-close-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.btn-close-icon:hover {
    color: #EF4444;
    transform: rotate(90deg);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.toggle-slider {
    background-color: rgba(168, 85, 247, 0.2);
    border-color: var(--accent);
}

input:checked+.toggle-slider:before {
    transform: translateX(22px);
    background-color: var(--accent);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    background-color: var(--text-muted);
}

.toggle-status-dot.active {
    background-color: #10B981;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background-color: #10B981;
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 10000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 16px;
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.3;
}

.spin {
    animation: spin 2s linear infinite;
}

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

    to {
        transform: rotate(360deg);
    }
}

/* Post Cards */
.post-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.post-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.post-thumb {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}

.post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-type {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.post-content {
    padding: 16px;
}

.post-caption {
    font-size: 0.85rem;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
    line-height: 1.4;
}

.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* CONFIGURAÇÕES UNIFICADAS */
.settings-tabs {
    display: flex !important;
    flex-direction: row !important;
    gap: 32px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 32px;
    padding-bottom: 0;
}

.s-tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 12px 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.s-tab-btn:hover {
    color: var(--text-main);
}

.s-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.s-tab-content {
    display: none;
    max-width: 1000px;
    /* Limita largura para não ficar gigante em telas ultra-wide */
}

.s-tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

.tags-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tag-config-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s;
}

.tag-config-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
}

.tag-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tag-color-preview {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.tag-config-name {
    font-weight: 600;
    font-size: 0.95rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Contact Sidebar (Right) */
.contact-sidebar {
    width: 320px;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    height: 100%;
    overflow-y: auto;
}

.tag-pill {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.contact-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 0;
    margin-top: 6px;
}

.tag-mini {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1;
}

.tag-item-selector {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.tag-item-selector:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}

.tag-item-selector.active {
    border-color: white;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.quick-reply-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.quick-reply-item:hover {
    background: rgba(168, 85, 247, 0.1);
}

.quick-reply-item h5 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--accent);
}

.quick-reply-item p {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- SaaS & Team Management --- */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:hover {
    background: rgba(255, 255, 255, 0.01);
}

.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    display: inline-block;
}

.bg-primary {
    background: rgba(168, 85, 247, 0.2);
    color: var(--accent);
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.bg-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #EF4444;
}

.btn-outline-danger:hover {
    background: #EF4444;
    color: white;
}

/* ================================================
   DASHBOARD STYLES
   ================================================ */

#view-dashboard.active {
    flex-direction: column;
    overflow-y: auto;
}

.dashboard-wrapper {
    padding: 40px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

.dashboard-header {
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.dashboard-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.dashboard-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.dashboard-refresh-btn {
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.2);
    color: var(--accent);
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-family: inherit;
}

.dashboard-refresh-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    transform: translateY(-1px);
}

/* KPI CARDS GRID */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: hidden;
    cursor: default;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.kpi-card.purple::before { background: linear-gradient(90deg, #A855F7, #8B5CF6); }
.kpi-card.blue::before   { background: linear-gradient(90deg, #3B82F6, #6366F1); }
.kpi-card.green::before  { background: linear-gradient(90deg, #10B981, #059669); }
.kpi-card.orange::before { background: linear-gradient(90deg, #F59E0B, #EF4444); }

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

.kpi-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 16px;
}

.kpi-card.purple .kpi-card-icon { background: rgba(168, 85, 247, 0.12); color: #A855F7; }
.kpi-card.blue .kpi-card-icon   { background: rgba(59, 130, 246, 0.12); color: #3B82F6; }
.kpi-card.green .kpi-card-icon  { background: rgba(16, 185, 129, 0.12); color: #10B981; }
.kpi-card.orange .kpi-card-icon { background: rgba(245, 158, 11, 0.12); color: #F59E0B; }

.kpi-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 6px;
}

.kpi-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-sub .up   { color: #10B981; }
.kpi-sub .down { color: #EF4444; }

/* BG GLOW DECORATION */
.kpi-card .kpi-bg-glow {
    position: absolute;
    right: -20px;
    bottom: -20px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    opacity: 0.04;
}

.kpi-card.purple .kpi-bg-glow { background: #A855F7; }
.kpi-card.blue .kpi-bg-glow   { background: #3B82F6; }
.kpi-card.green .kpi-bg-glow  { background: #10B981; }
.kpi-card.orange .kpi-bg-glow { background: #F59E0B; }

/* CHARTS + RECENT LEADS GRID */
.dashboard-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-card-title {
    font-size: 0.95rem;
    font-weight: 700;
}

.chart-card-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.chart-card-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent);
    border: 1px solid rgba(168, 85, 247, 0.2);
}

/* RECENT LEADS */
.recent-leads-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    grid-column: span 1;
}

.recent-lead-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: opacity 0.2s;
}

.recent-lead-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.recent-lead-item:first-child {
    padding-top: 0;
}

.recent-lead-item:hover {
    opacity: 0.8;
}

.recent-lead-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
    overflow: hidden;
}

.recent-lead-info {
    flex: 1;
    overflow: hidden;
}

.recent-lead-name {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-lead-msg {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.recent-lead-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* STATUS BAR */
.dashboard-status-bar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 12px;
}

.status-service-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-service-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.status-service-info {
    flex: 1;
}

.status-service-name {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.status-service-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.status-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.status-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-pill.online {
    background: rgba(16, 185, 129, 0.1);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-pill.online::before {
    background: #10B981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
    animation: pulse-green 1.5s infinite;
}

.status-pill.offline {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-pill.offline::before {
    background: #EF4444;
}

.status-pill.paused {
    background: rgba(245, 158, 11, 0.1);
    color: #F59E0B;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-pill.paused::before {
    background: #F59E0B;
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 4px rgba(16, 185, 129, 0.4); }
    50%       { box-shadow: 0 0 10px rgba(16, 185, 129, 0.8); }
}

/* SKELETON LOADER */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255,255,255,0.04) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

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

/* BADGE PULSE */
@keyframes pulse-badge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.4); }
    50%       { box-shadow: 0 0 0 6px rgba(168, 85, 247, 0); }
}

/* COUNTER ANIMATION */
@keyframes countUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.kpi-value.animate-in {
    animation: countUp 0.4s ease forwards;
}

/* RESPONSIVE */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-bottom { grid-template-columns: 1fr 1fr; }
    .recent-leads-card { grid-column: span 2; }
}

@media (max-width: 768px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-bottom { grid-template-columns: 1fr; }
    .recent-leads-card { grid-column: span 1; }
    .dashboard-status-bar { grid-template-columns: 1fr; }
    .dashboard-wrapper { padding: 20px; }
}

/* ── TOAST NOTIFICATIONS ──────────────────────────── */
#toast-container {
    position: fixed; top: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 12px;
    z-index: 10001;
}

.toast-notification {
    min-width: 300px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex; align-items: center; gap: 14px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast-notification.show { transform: translateX(0); }
.toast-notification i { font-size: 1.4rem; }
.toast-notification.success i { color: #10B981; }
.toast-notification.error i { color: #EF4444; }
.toast-notification span { font-size: 0.88rem; font-weight: 500; color: var(--text-main); }

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 20px;
    padding: 0 40px 40px;
    overflow-x: auto;
    align-items: flex-start;
    height: calc(100vh - 180px);
}

.kanban-column {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 18px;
    width: 320px;
    min-width: 320px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    transition: background 0.2s ease;
}

.kanban-column.drag-over {
    background: rgba(168, 85, 247, 0.05);
    border-color: var(--accent);
}

.kanban-column-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    cursor: grab;
}

.kanban-column-header:active {
    cursor: grabbing;
}

.kanban-column-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 0.95rem;
}

.kanban-column-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.kanban-column-count {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.kanban-cards {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    min-height: 100px;
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: grab;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.kanban-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.kanban-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(168, 85, 247, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    overflow: hidden;
}

.kanban-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-card-body {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.kanban-card-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
}

.kanban-card-time {
    color: var(--text-muted);
}

.kanban-card-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tag-mini-kanban {
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    color: white;
}

.sortable-ghost {
    opacity: 0.4;
    border: 2px dashed var(--accent);
}