/* Reset e Variáveis */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Cores principais */
    --primary: #7C3AED;
    --primary-dark: #6D28D9;
    --secondary: #10B981;
    --accent: #EC4899;
    
    /* WhatsApp */
    --whatsapp: #25D366;
    --whatsapp-dark: #128C7E;
    
    /* Neutros */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    /* Status */
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;
    
    /* Estágios do funil */
    --stage-new: #6366F1;
    --stage-engaged: #8B5CF6;
    --stage-interested: #EC4899;
    --stage-qualified: #F59E0B;
    --stage-converted: #10B981;
    --stage-lost: #EF4444;
    
    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    overflow-x: hidden;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #7C3AED 0%, #6D28D9 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}

.logo i {
    font-size: 28px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
    font-size: 14px;
    font-weight: 500;
}

.nav-item i {
    font-size: 18px;
    width: 20px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: white;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--accent);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

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

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.user-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-online {
    color: var(--success);
    animation: pulse 2s infinite;
}

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

/* Main Area */
.main-area {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    background: var(--gray-50);
}

/* Pages */
.page {
    display: none;
    padding: 24px;
    animation: fadeIn 0.3s;
}

.page.active {
    display: block;
}

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

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.page-header p {
    font-size: 14px;
    color: var(--gray-500);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-refresh {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-refresh {
    background: white;
    color: var(--primary);
    border: 1px solid var(--gray-200);
}

.btn-refresh:hover {
    background: var(--gray-50);
    border-color: var(--primary);
}

.time-badge {
    padding: 10px 16px;
    background: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary);
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.info::before { background: var(--info); }
.stat-card.purple::before { background: #8B5CF6; }
.stat-card.pink::before { background: var(--accent); }

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    flex-shrink: 0;
}

.stat-card.primary .stat-icon { background: linear-gradient(135deg, #7C3AED, #6D28D9); }
.stat-card.success .stat-icon { background: linear-gradient(135deg, #10B981, #059669); }
.stat-card.warning .stat-icon { background: linear-gradient(135deg, #F59E0B, #D97706); }
.stat-card.info .stat-icon { background: linear-gradient(135deg, #3B82F6, #2563EB); }
.stat-card.purple .stat-icon { background: linear-gradient(135deg, #8B5CF6, #7C3AED); }
.stat-card.pink .stat-icon { background: linear-gradient(135deg, #EC4899, #DB2777); }

.stat-info {
    flex: 1;
}

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.stat-info p {
    font-size: 14px;
    color: var(--gray-500);
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-trend {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stat-trend.up {
    color: var(--success);
}

.stat-trend.down {
    color: var(--error);
}

/* Card */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 24px;
}

/* period-select */
.period-select {
    padding: 8px 16px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 14px;
    color: var(--gray-700);
    background: white;
    cursor: pointer;
}

/* Funnel Visual */
.funnel-visual {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
}

.funnel-stage {
    width: 100%;
}

.funnel-bar {
    background: var(--gray-100);
    border-radius: 12px;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.funnel-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    opacity: 0.2;
    transition: width 0.8s ease-out;
    border-radius: 12px;
}

.funnel-stage[data-stage="new"] .funnel-progress { background: var(--stage-new); }
.funnel-stage[data-stage="engaged"] .funnel-progress { background: var(--stage-engaged); }
.funnel-stage[data-stage="interested"] .funnel-progress { background: var(--stage-interested); }
.funnel-stage[data-stage="qualified"] .funnel-progress { background: var(--stage-qualified); }
.funnel-stage[data-stage="converted"] .funnel-progress { background: var(--stage-converted); }

.funnel-label {
    font-weight: 600;
    font-size: 16px;
    z-index: 1;
    color: var(--gray-900);
}

.funnel-count {
    font-weight: 700;
    font-size: 20px;
    z-index: 1;
}

.funnel-stage[data-stage="new"] .funnel-count { color: var(--stage-new); }
.funnel-stage[data-stage="engaged"] .funnel-count { color: var(--stage-engaged); }
.funnel-stage[data-stage="interested"] .funnel-count { color: var(--stage-interested); }
.funnel-stage[data-stage="qualified"] .funnel-count { color: var(--stage-qualified); }
.funnel-stage[data-stage="converted"] .funnel-count { color: var(--stage-converted); }

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 8px;
}

.filter-tab {
    padding: 8px 16px;
    background: var(--gray-100);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    transition: all 0.2s;
}

.filter-tab:hover {
    background: var(--primary);
    color: white;
}

.filter-tab.active {
    background: var(--primary);
    color: white;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--gray-50);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
    color: var(--gray-900);
}

.data-table tbody tr {
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.no-data {
    text-align: center;
    padding: 60px !important;
    color: var(--gray-400);
}

.no-data i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-data p {
    font-size: 16px;
}

/* Stage Badge */
.stage-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.stage-badge.new { background: var(--stage-new); }
.stage-badge.engaged { background: var(--stage-engaged); }
.stage-badge.interested { background: var(--stage-interested); }
.stage-badge.qualified { background: var(--stage-qualified); }
.stage-badge.converted { background: var(--stage-converted); }
.stage-badge.lost { background: var(--stage-lost); }

/* Chat Container */
.chat-container {
    display: flex;
    height: calc(100vh - 120px);
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.chat-sidebar {
    width: 350px;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
}

.chat-search {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-search i {
    color: var(--gray-400);
}

.chat-search input {
    flex: 1;
    border: none;
    font-size: 14px;
    outline: none;
}

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

.chat-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-empty {
    text-align: center;
    color: var(--gray-400);
}

.chat-empty i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.chat-empty h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.chat-empty p {
    font-size: 14px;
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--gray-50);
    border-radius: 8px;
    flex: 1;
    max-width: 400px;
}

.search-box i {
    color: var(--gray-400);
}

.search-box input {
    border: none;
    background: none;
    flex: 1;
    font-size: 14px;
    outline: none;
}

/* Header Stats */
.header-stats {
    display: flex;
    gap: 12px;
}

.stat-badge {
    padding: 8px 16px;
    background: var(--gray-50);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Flows Grid */
.flows-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.flow-card {
    background: white;
    border-radius: 12px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
}

.flow-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.flow-card.new {
    border: 2px dashed var(--gray-300);
    background: var(--gray-50);
}

.flow-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.flow-card.new .flow-icon {
    background: var(--gray-200);
    color: var(--gray-600);
}

.flow-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--gray-900);
}

.flow-card p {
    font-size: 14px;
    color: var(--gray-500);
}

/* Device Status */
.device-status {
    text-align: center;
    padding: 40px;
}

.status-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
    border-radius: 50%;
    background: var(--whatsapp);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

.device-status h3 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--gray-900);
}

.device-status p {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 24px;
}

.device-info {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-bottom: 24px;
    font-size: 14px;
}

.device-info span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.device-info code {
    background: var(--gray-100);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 40px;
}

.empty-state i {
    font-size: 80px;
    color: var(--gray-300);
    margin-bottom: 24px;
}

.empty-state h3 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--gray-900);
}

.empty-state p {
    font-size: 16px;
    color: var(--gray-500);
    margin-bottom: 32px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

textarea.form-control {
    resize: vertical;
    font-family: inherit;
}

.range-input {
    width: 100%;
}

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .main-area {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        gap: 16px;
    }
    
    .filter-tabs {
        flex-wrap: wrap;
    }
    
    .chat-sidebar {
        display: none;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

:root {
    --primary: #25D366;
    --secondary: #128C7E;
    --dark: #075E54;
    --light: #ECE5DD;
    --white: #FFFFFF;
    --text: #333333;
    --text-light: #777777;
    --border: #E0E0E0;
    --shadow: rgba(0, 0, 0, 0.1);
    
    /* Cores dos estágios */
    --new: #6366F1;
    --engaged: #8B5CF6;
    --interested: #EC4899;
    --qualified: #F59E0B;
    --converted: #10B981;
    --lost: #EF4444;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--white);
    border-radius: 16px;
    padding: 24px 32px;
    margin-bottom: 24px;
    box-shadow: 0 4px 6px var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: var(--primary);
    font-size: 28px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-stats {
    display: flex;
    gap: 16px;
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--light);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.status-online {
    color: var(--converted);
    animation: pulse 2s infinite;
}

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

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 4px var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px var(--shadow);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--white);
}

.stat-card.total .stat-icon { background: linear-gradient(135deg, #667eea, #764ba2); }
.stat-card.new .stat-icon { background: var(--new); }
.stat-card.interested .stat-icon { background: var(--interested); }
.stat-card.qualified .stat-icon { background: var(--qualified); }
.stat-card.converted .stat-icon { background: var(--converted); }
.stat-card.conversion-rate .stat-icon { background: var(--primary); }

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.stat-info p {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
}

/* Funnel Section */
.funnel-section,
.leads-section {
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 6px var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 22px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
}

.refresh-btn {
    padding: 10px 20px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.refresh-btn:hover {
    background: var(--secondary);
}

.refresh-btn:active {
    transform: scale(0.98);
}

/* Funnel Chart */
.funnel-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
}

.funnel-stage {
    width: 100%;
}

.funnel-bar {
    background: var(--light);
    border-radius: 8px;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.funnel-bar::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: currentColor;
    opacity: 0.1;
    transition: width 0.5s ease-out;
}

.funnel-stage[data-stage="new"] .funnel-bar { color: var(--new); }
.funnel-stage[data-stage="engaged"] .funnel-bar { color: var(--engaged); }
.funnel-stage[data-stage="interested"] .funnel-bar { color: var(--interested); }
.funnel-stage[data-stage="qualified"] .funnel-bar { color: var(--qualified); }
.funnel-stage[data-stage="converted"] .funnel-bar { color: var(--converted); }

.funnel-label {
    font-weight: 600;
    font-size: 16px;
    z-index: 1;
}

.funnel-count {
    font-weight: 700;
    font-size: 18px;
    z-index: 1;
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 8px;
}

.filter-tab {
    padding: 8px 16px;
    background: var(--light);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.filter-tab:hover {
    background: var(--primary);
    color: var(--white);
}

.filter-tab.active {
    background: var(--primary);
    color: var(--white);
}

/* Table */
.table-container {
    overflow-x: auto;
}

.leads-table {
    width: 100%;
    border-collapse: collapse;
}

.leads-table thead {
    background: var(--light);
}

.leads-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

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

.leads-table tbody tr {
    transition: background 0.2s;
}

.leads-table tbody tr:hover {
    background: rgba(37, 211, 102, 0.05);
}

.no-data {
    text-align: center;
    padding: 48px !important;
    color: var(--text-light);
}

.no-data i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.no-data p {
    font-size: 16px;
}

.stage-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--white);
}

.stage-badge.new { background: var(--new); }
.stage-badge.engaged { background: var(--engaged); }
.stage-badge.interested { background: var(--interested); }
.stage-badge.qualified { background: var(--qualified); }
.stage-badge.converted { background: var(--converted); }
.stage-badge.lost { background: var(--lost); }

/* Footer */
.footer {
    background: var(--white);
    border-radius: 12px;
    padding: 16px 24px;
    margin-top: 24px;
    text-align: center;
    box-shadow: 0 2px 4px var(--shadow);
}

.footer p {
    color: var(--text-light);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#auto-refresh {
    margin-left: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        gap: 16px;
    }

    .filter-tabs {
        flex-wrap: wrap;
    }

    .footer p {
        flex-direction: column;
        gap: 8px;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Tooltips */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    color: var(--gray-400);
    cursor: help;
    position: relative;
    transition: color 0.2s;
}

.tooltip-icon:hover {
    color: var(--primary);
}

.tooltip-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--gray-900);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    max-width: 250px;
    white-space: normal;
    width: max-content;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.tooltip-icon::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-2px);
    border: 6px solid transparent;
    border-top-color: var(--gray-900);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}

.tooltip-icon:hover::after,
.tooltip-icon:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Alert Info */
.alert-info {
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    border-left: 4px solid var(--info);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.alert-info i {
    color: var(--info);
    font-size: 20px;
    margin-top: 2px;
    flex-shrink: 0;
}

.alert-info strong {
    color: var(--gray-900);
    display: block;
    margin-bottom: 8px;
}

.alert-info ol {
    margin-left: 20px;
    margin-top: 8px;
}

.alert-info li {
    margin-bottom: 6px;
    color: var(--gray-700);
}

.alert-info a {
    color: var(--info);
    text-decoration: underline;
    font-weight: 500;
}

.alert-info a:hover {
    color: var(--primary);
}

/* Help Link */
.help-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(124, 58, 237, 0.1);
    transition: all 0.2s;
    font-weight: 500;
}

.help-link:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.help-link i {
    font-size: 11px;
}

/* Form Hint */
.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--gray-500);
}

.form-hint i {
    margin-right: 4px;
}

/* Card Header com Link */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Sistema de Notificações */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 500px;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    z-index: 10000;
    font-size: 14px;
    font-weight: 500;
}

.notification.show {
    transform: translateX(0);
}

.notification i {
    font-size: 20px;
}

.notification-success {
    border-left: 4px solid var(--success);
    color: var(--gray-900);
}

.notification-success i {
    color: var(--success);
}

.notification-error {
    border-left: 4px solid var(--error);
    color: var(--gray-900);
}

.notification-error i {
    color: var(--error);
}

.notification-warning {
    border-left: 4px solid var(--warning);
    color: var(--gray-900);
}

.notification-warning i {
    color: var(--warning);
}

.notification-info {
    border-left: 4px solid var(--info);
    color: var(--gray-900);
}

.notification-info i {
    color: var(--info);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
}

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

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.modal-large {
    max-width: 800px;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h3 i {
    color: var(--primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    color: var(--gray-600);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--error);
    color: white;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Lead Details Modal */
.lead-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.lead-info-section h4,
.lead-stats-section h4,
.lead-messages-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

/* ===== CHAT AO VIVO ===== */

.chat-item {
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-item:hover {
    background: var(--gray-50);
}

.chat-item.active {
    background: var(--primary-light);
    border-left: 3px solid var(--primary-color);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.chat-info {
    flex: 1;
}

.chat-info h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--gray-800);
}

.chat-info p {
    font-size: 12px;
    color: var(--gray-500);
}

.chat-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

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

.chat-header-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--gray-800);
}

.chat-header-info p {
    font-size: 13px;
    color: var(--gray-500);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stage-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.stage-new { background: #e3f2fd; color: #1976d2; }
.stage-engaged { background: #f3e5f5; color: #7b1fa2; }
.stage-interested { background: #fff3e0; color: #f57c00; }
.stage-qualified { background: #e8f5e9; color: #388e3c; }
.stage-converted { background: #e8f5e9; color: #2e7d32; }
.stage-lost { background: #ffebee; color: #c62828; }

/* Mensagens */
.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-empty-messages {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gray-400);
}

.chat-empty-messages i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    animation: fadeIn 0.3s;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message.bot {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.user .message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.bot .message-content {
    background: white;
    color: var(--gray-800);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-content small {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.7;
}

.message-time {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
    padding: 0 4px;
}

.chat-message.user .message-time {
    text-align: right;
}

/* Input de chat */
.chat-input-wrapper {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid var(--gray-200);
}

.chat-input {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--gray-50);
    border-radius: 24px;
    padding: 8px 16px;
}

.chat-input input {
    flex: 1;
    border: none;
    background: none;
    font-size: 14px;
    outline: none;
    padding: 8px 0;
}

.chat-input .btn-icon {
    background: var(--primary-color);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input .btn-icon:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.chat-input .btn-icon:active {
    transform: scale(0.95);
}

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

.info-item label {
    font-weight: 500;
    color: var(--gray-600);
}

.info-item span {
    color: var(--gray-900);
    font-weight: 500;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 8px;
    margin-bottom: 12px;
}

.stat-item i {
    color: var(--primary);
    font-size: 20px;
}

.message-history {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.message-item {
    background: white;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    border-left: 3px solid var(--primary);
}

.message-item:last-child {
    margin-bottom: 0;
}

.message-item .message-meta {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.message-item .message-text {
    color: var(--gray-900);
}

/* Audio Preview */
.audio-preview {
    margin-top: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #F3E8FF 0%, #E9D5FF 100%);
    border-radius: 12px;
    border: 2px dashed var(--primary);
}

.audio-preview h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 16px;
}

.audio-preview audio {
    width: 100%;
    margin-bottom: 16px;
    border-radius: 8px;
}

.audio-actions {
    display: flex;
    gap: 12px;
}

.audio-actions button {
    flex: 1;
}

/* Character Counter */
#char-count {
    font-weight: 600;
    color: var(--primary);
}

/* Text Muted */
.text-muted {
    color: var(--gray-500);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Responsive Modals */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-width: none;
    }
    
    .lead-details-grid {
        grid-template-columns: 1fr;
    }
}

/* Provider Selector */
.provider-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 12px;
}

.provider-option {
    cursor: pointer;
}

.provider-option input[type="radio"] {
    display: none;
}

.provider-card {
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    padding: 20px;
    background: white;
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.provider-option input[type="radio"]:checked + .provider-card {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.05) 0%, rgba(109, 40, 217, 0.05) 100%);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.provider-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.provider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.provider-header i {
    font-size: 32px;
    color: var(--primary);
}

.provider-card h4 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 16px;
}

.provider-features {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
}

.provider-features li {
    padding: 8px 0;
    font-size: 14px;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
}

.provider-features li:last-child {
    border-bottom: none;
}

.setup-guide {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    margin-top: 16px;
    padding: 8px 12px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.setup-guide:hover {
    background: var(--primary);
    color: white;
}

.badge-success {
    background: var(--success);
    color: white;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-warning {
    background: var(--warning);
    color: white;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.alert-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
    border-left: 4px solid var(--success);
    padding: 16px;
    border-radius: 8px;
    display: flex;
    gap: 12px;
}

.alert-success i {
    color: var(--success);
    font-size: 20px;
    flex-shrink: 0;
}

.alert-success strong {
    display: block;
    color: var(--success);
    font-weight: 700;
    margin-bottom: 4px;
}

.alert-success p {
    color: var(--gray-700);
    font-size: 14px;
    margin: 0;
}

/* Responsive Provider Selector */
@media (max-width: 768px) {
    .provider-selector {
        grid-template-columns: 1fr;
    }
}
