:root {
    /* Color System - Light Minimal */
    --primary: #212529;
    --primary-alt: #000000;
    --accent: #495057;
    --success: #2b8a3e;
    --error: #c92a2a;
    --warning: #f08c00;
    
    --bg-light: #f8f9fa;
    --bg-gradient: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    
    --surface: #ffffff;
    --surface-hover: #f1f3f5;
    --surface-active: #e9ecef;
    --surface-border: #dee2e6;
    
    --text-primary: #1a1a1a;
    --text-secondary: #495057;
    --text-muted: #868e96;
    
    /* Spacing Scale (8dp) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
    --space-6: 48px;
    
    /* Animation Tokens */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --spring-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-light);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.glass-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    backdrop-filter: blur(10px);
}

/* Sidebar - Pro Max Style */
.sidebar {
    width: 80px;
    padding: var(--space-5) var(--space-2);
    background: #ffffff;
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.02);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}

.logo h1 {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.logo span, .sidebar nav li span {
    display: none;
}

nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

nav li {
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
}

nav li:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    transform: scale(1.05);
}

nav li.active {
    background: #000;
    color: #fff;
    border: 1px solid #000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Content Area */
.content {
    flex: 1;
    padding: 0;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.tab-content {
    animation: fadeIn 400ms var(--spring-ease);
}

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

header, .tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    padding: var(--space-4) var(--space-4) 0 var(--space-4);
}

h2 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.8px;
}

/* Cards */
.glass-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    padding: var(--space-4);
    transition: var(--transition-base);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.glass-card:hover {
    border-color: var(--text-muted);
}

/* Leads Table */
.table-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    border: 1px solid var(--surface-border);
    overflow: hidden;
}

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

th {
    padding: var(--space-3);
    text-align: left;
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.02);
}

td {
    padding: var(--space-3);
    border-bottom: 1px solid var(--surface-border);
    color: var(--text-secondary);
}

tr:hover td {
    background: var(--surface);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.ativo { background: rgba(0, 210, 255, 0.15); color: var(--accent); }
.status-badge.comprou { background: rgba(0, 230, 118, 0.15); color: var(--success); }
.status-badge.suporte { background: rgba(255, 215, 64, 0.15); color: var(--warning); }

/* --- New Chat Layout (Integrated) --- */
.leads-chat-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
    background: var(--bg-light);
}

.conversations-sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.search-container {
    padding: var(--space-1);
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    color: var(--text-primary);
    outline: none;
}

.search-input:focus { border-color: var(--primary); }

.conversations-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding-right: 4px;
}

.conv-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: 16px;
    cursor: pointer;
    transition: var(--transition-base);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
}

.conv-item:hover { background: var(--surface); }
.conv-item.active {
    background: linear-gradient(135deg, rgba(194, 157, 255, 0.1), rgba(0, 210, 255, 0.05));
    border-color: rgba(194, 157, 255, 0.2);
}

.conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface-active);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.conv-info { flex: 1; min-width: 0; }
.conv-info h4 { font-size: 15px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-info p { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Chat Main Surface */
.chat-window {
    display: flex;
    flex-direction: column;
    background: white;
    border-left: 1px solid var(--surface-border);
    height: 100vh;
}

.chat-header {
    padding: var(--space-3) var(--space-4);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-messages-box {
    flex: 1;
    padding: var(--space-4);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.msg-row {
    display: flex;
    width: 100%;
    margin-bottom: var(--space-1);
}

.msg-row.sent { justify-content: flex-end; }
.msg-row.received { justify-content: flex-start; }

.chat-bubble {
    max-width: 75%;
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 14px;
    position: relative;
    line-height: 1.5;
}

/* Chat Bubbles - Light Minimal */
.msg-row.sent .chat-bubble {
    background: #000;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg-row.received .chat-bubble {
    background: #f1f3f5;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
    border: 1px solid #e9ecef;
}

.msg-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
    text-align: right;
}

.chat-input-area {
    padding: var(--space-3) var(--space-4);
    background: rgba(255, 255, 255, 0.01);
    border-top: 1px solid var(--surface-border);
    display: flex;
    gap: var(--space-2);
}

.chat-input-area input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 10px 16px;
    color: var(--text-primary);
    outline: none;
}

/* Details Sidebar */
.lead-details-sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.lead-profile-card {
    padding: var(--space-4);
    text-align: center;
    background: var(--surface);
    border-radius: 24px;
    border: 1px solid var(--surface-border);
}

.big-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto var(--space-3);
    background: var(--surface-active);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
    margin-top: var(--space-3);
}

.detail-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }
.detail-value { font-size: 14px; color: var(--text-primary); font-weight: 500; }

/* RAG Grid */
.rag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-4);
}

.rag-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-height: 320px;
    position: relative;
    border-top: 4px solid var(--primary);
}

.rag-card p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
    min-height: 40px;
}

.rag-card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: #000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rag-stats {
    background: #f8f9fa;
    border-radius: 12px;
    padding: var(--space-3);
    border: 1px solid var(--surface-border);
    flex: 1;
}

.stat-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-files {
    margin-top: var(--space-3);
    max-height: 80px;
    overflow-y: auto;
}

.file-chip {
    display: inline-block;
    background: #fff;
    border: 1px solid var(--surface-border);
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    margin: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.rag-actions {
    margin-top: auto;
    display: flex;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid #f1f3f5;
}

/* Forms & Editors */
.editor-container textarea {
    width: 100%;
    height: 65vh;
    background: var(--surface-hover);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    padding: var(--space-4);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    outline: none;
    transition: var(--transition-base);
}

.editor-container textarea:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}

/* Modals - Pro Max Fluid Style */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 300ms ease-out;
}

.chat-modal, .modal-form {
    background: #ffffff;
    border: 1px solid var(--surface-border);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: zoomIn 400ms var(--spring-ease);
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.chat-modal { width: 600px; height: 80vh; }
.modal-form { width: 480px; }

.modal-form header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-form .form-body {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.input-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-group input, .input-group textarea {
    background: var(--surface-hover);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-base);
}

.input-group input:focus, .input-group textarea:focus {
    border-color: #000;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0,0,0,0.05);
}

/* Buttons & Interactive */
button {
    padding: 12px 24px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary, .btn-save {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover, .btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(194, 157, 255, 0.3);
}

.btn-upload { background: var(--accent); color: #ffffff; }
.btn-clear { background: #f1f3f5; color: var(--error); border: 1px solid var(--surface-border); }
.btn-clear:hover { background: var(--error); color: #fff; border-color: var(--error); }

.btn-delete-small {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: var(--transition-fast);
}

.btn-delete-small:hover {
    color: var(--error);
    transform: scale(1.2);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .glass-container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; flex-direction: row; justify-content: space-between; padding: 15px 20px; }
    .logo { margin-bottom: 0; }
    nav ul { flex-direction: row; gap: 10px; }
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-close:hover {
    color: var(--error);
    transform: rotate(90deg);
}

button:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.chat-header { position: relative; }
.lead-info-panel {
    position: absolute;
    top: 70px;
    left: 15px;
    width: 250px;
    z-index: 100;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border: 1px solid var(--surface-border);
    padding: var(--space-3);
    animation: slipDown 300ms var(--spring-ease);
}

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

/* Funil Kanban Styles */
.funnel-container {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding: 0 var(--space-4) 20px var(--space-4); /* Adicionado padding lateral interno */
    height: calc(100vh - 160px);
    width: 100%;
    align-items: flex-start;
}

.funnel-column {
    flex: 0 0 280px;
    background: #f1f3f5;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-height: 100%;
    border: 1px solid var(--surface-border);
}

.column-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: inherit;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    border-radius: 12px 12px 0 0;
    z-index: 10;
}

.column-header h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: var(--text-main);
}

.col-count {
    font-size: 11px;
    background: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid var(--surface-border);
}

.column-cards {
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.funnel-card {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    border: 1px solid var(--surface-border);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    gap: 10px;
}

.funnel-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: var(--primary-color);
}

.card-avatar {
    width: 32px;
    height: 32px;
    background: var(--surface-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    flex-shrink: 0;
}

.card-body {
    flex: 1;
    min-width: 0;
}

.card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-phone {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.card-footer {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
    font-size: 10px;
    color: var(--text-muted);
}

.empty-column {
    padding: 20px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    border: 1px dashed var(--surface-border);
    border-radius: 8px;
}
