/* ==========================================================================
   GLOBAL DESIGN SYSTEM - CRM 2.0 (DARK MODE)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Colors */
    --bg-dark: #0f111a;
    --bg-panel: #1a1d27;
    --bg-panel-hover: #232733;
    
    --primary: #8b5cf6; /* Púrpura (IA/Modern) */
    --primary-hover: #7c3aed;
    --secondary: #3b82f6; /* Azul */
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    
    /* Metrics */
    --header-height: 64px;
    --border-radius-sm: 6px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-family);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   HEADER / NAVBAR (Unified)
   ========================================================================== */
.crm-header {
    height: var(--header-height);
    background-color: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.crm-header-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

.crm-logo {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    letter-spacing: -0.5px;
}
.crm-logo span {
    color: var(--primary);
}

.crm-nav {
    display: flex;
    gap: 20px;
}

.crm-nav .nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--border-radius-md);
    transition: all 0.2s ease;
}

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

.crm-nav .nav-link.active {
    color: #ffffff;
    background: rgba(139, 92, 246, 0.15); /* Púrpura sutil */
    color: var(--primary);
}

.crm-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.crm-btn-connect {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s, transform 0.2s;
    border: none;
    cursor: pointer;
}
.crm-btn-connect:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.crm-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.crm-status-badge .pulse {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================================================
   GLOBAL LAYOUT (Main Container)
   ========================================================================== */
.crm-main-container {
    flex: 1;
    padding: 32px 48px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

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

.crm-page-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ==========================================================================
   GLOBAL BUTTONS
   ========================================================================== */
.crm-btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.crm-btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.crm-btn-secondary {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.crm-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-hover);
}

/* ==========================================================================
   GLOBAL TABLES (.crm-table)
   ========================================================================== */
.crm-table-container {
    background: var(--bg-panel);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.crm-table th {
    background: rgba(0, 0, 0, 0.2);
    padding: 16px 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.crm-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-main);
    vertical-align: middle;
}

.crm-table tr:last-child td {
    border-bottom: none;
}

.crm-table tbody tr {
    transition: background 0.15s ease;
}

.crm-table tbody tr:hover {
    background: var(--bg-panel-hover);
}

/* Status Badges in tables */
.crm-badge-active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.crm-badge-draft {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

/* Table Utilities */
.keyword-pill {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    margin-right: 4px;
    display: inline-block;
}
.keyword-more {
    color: var(--text-muted);
    font-size: 11px;
}
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: 0.2s;
}
.btn-icon:hover { color: var(--primary); background: rgba(255,255,255,0.05); }
.btn-icon.danger:hover { color: var(--danger); }

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.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.1); transition: .2s; border-radius: 20px;
}
.toggle-slider:before {
    position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px;
    background-color: white; transition: .2s; border-radius: 50%;
}
input:checked + .toggle-slider { background-color: var(--primary); }
input:checked + .toggle-slider:before { transform: translateX(16px); }
