/* ═══════════════════════════════════════════════════════════════════════════
   CRM LEADS — HubSpot-level UI
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-primary-light: rgba(99,102,241,0.1);
    --color-sidebar: #0f172a;
    --color-sidebar-hover: rgba(255,255,255,0.05);
    --color-sidebar-active: #6366f1;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.1);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    letter-spacing: -0.011em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
    background: var(--color-sidebar);
    transition: transform 0.3s var(--transition);
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    color: rgba(255,255,255,0.65);
    transition: all var(--transition);
    position: relative;
}

.sidebar .nav-link:hover {
    background: var(--color-sidebar-hover);
    color: rgba(255,255,255,0.95);
}

.sidebar .nav-link.active {
    background: rgba(99,102,241,0.15);
    color: #818cf8;
}

.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0.375rem;
    bottom: 0.375rem;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--color-primary);
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); position: fixed; z-index: 50; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
}

/* ─── Top Bar ────────────────────────────────────────────────────────────── */
.topbar {
    height: 56px;
    border-bottom: 1px solid #eef0f3;
    background: white;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 30;
}

/* ─── Command Palette (Cmd+K) ────────────────────────────────────────────── */
.cmd-palette-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20vh;
    animation: fadeIn 0.15s ease;
}

.cmd-palette {
    background: white;
    border-radius: var(--radius-xl);
    width: 580px;
    max-width: 90vw;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: slideDown 0.2s ease;
}

.cmd-palette input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: none;
    font-size: 1rem;
    outline: none;
    border-bottom: 1px solid #eef0f3;
}

.cmd-palette-results {
    max-height: 320px;
    overflow-y: auto;
}

.cmd-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    transition: background var(--transition);
}

.cmd-result:hover, .cmd-result.selected {
    background: #f7f8fa;
}

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

/* ─── Status Badges ──────────────────────────────────────────────────────── */
.badge-nuevo { background: #e8f4fd; color: #0b76b7; }
.badge-contactado { background: #fff3cd; color: #856404; }
.badge-calificado { background: #d4edda; color: #155724; }
.badge-propuesta { background: #e8daef; color: #6c3483; }
.badge-ganado { background: #c6f6d5; color: #22543d; }
.badge-perdido { background: #fed7d7; color: #9b2c2c; }

/* New agency states */
.badge-contactar { background: #e0f2fe; color: #0369a1; }
.badge-no_contesta { background: #fef3c7; color: #92400e; }
.badge-follow_up { background: #e0e7ff; color: #3730a3; }
.badge-reunion_agendada { background: #ede9fe; color: #5b21b6; }
.badge-no_show { background: #fee2e2; color: #991b1b; }
.badge-negociacion { background: #fef3c7; color: #78350f; }
.badge-negociando { background: #fef3c7; color: #78350f; }

/* Dot variant */
.dot-nuevo { background: #0b76b7; }
.dot-contactar { background: #0284c7; }
.dot-no_contesta { background: #d97706; }
.dot-follow_up { background: #6366f1; }
.dot-contactado { background: #d69e2e; }
.dot-calificado { background: #38a169; }
.dot-reunion_agendada { background: #7c3aed; }
.dot-no_show { background: #dc2626; }
.dot-propuesta { background: #805ad5; }
.dot-negociacion { background: #b45309; }
.dot-negociando { background: #b45309; }
.dot-ganado { background: #2f855a; }
.dot-perdido { background: #e53e3e; }

/* Kanban column top borders */
.border-t-nuevo { border-top: 3px solid #0b76b7; }
.border-t-contactar { border-top: 3px solid #0284c7; }
.border-t-no_contesta { border-top: 3px solid #d97706; }
.border-t-follow_up { border-top: 3px solid #6366f1; }
.border-t-contactado { border-top: 3px solid #d69e2e; }
.border-t-calificado { border-top: 3px solid #38a169; }
.border-t-reunion_agendada { border-top: 3px solid #7c3aed; }
.border-t-no_show { border-top: 3px solid #dc2626; }
.border-t-propuesta { border-top: 3px solid #805ad5; }
.border-t-negociacion { border-top: 3px solid #b45309; }
.border-t-negociando { border-top: 3px solid #b45309; }
.border-t-ganado { border-top: 3px solid #2f855a; }
.border-t-perdido { border-top: 3px solid #e53e3e; }

/* ─── Kanban ──────────────────────────────────────────────────────────────── */
.kanban-board {
    display: flex;
    gap: 0.5rem;
    min-height: calc(100vh - 240px);
    padding-bottom: 1rem;
}

.kanban-column {
    min-width: 0;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #f7f8fa;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.kanban-column .column-header {
    padding: 0.625rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    border-bottom: 1px solid #eef0f3;
}

.kanban-column .column-header h3 {
    font-size: 0.75rem;
    white-space: nowrap;
}

.kanban-column .card-list {
    flex: 1;
    padding: 0.5rem;
    min-height: 120px;
    overflow-y: auto;
    transition: background var(--transition);
}

.kanban-column.drag-over .card-list {
    background: rgba(99, 102, 241, 0.04);
}

.kanban-card {
    background: white;
    border: 1px solid #eef0f3;
    border-radius: var(--radius);
    padding: 0.625rem;
    margin-bottom: 0.375rem;
    cursor: grab;
    transition: all var(--transition);
    position: relative;
}

.kanban-card:hover {
    border-color: #d1d5db;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.kanban-card.dragging {
    opacity: 0.4;
    transform: rotate(3deg) scale(1.02);
    box-shadow: var(--shadow-lg);
    cursor: grabbing;
}

.kanban-card .card-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

/* ─── Slide-Over Panel ───────────────────────────────────────────────────── */
.slide-over-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(2px);
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.slide-over {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 520px;
    max-width: 100vw;
    background: white;
    z-index: 101;
    box-shadow: -8px 0 32px rgba(0,0,0,0.1);
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.slide-over-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* ─── Activity Timeline ──────────────────────────────────────────────────── */
.timeline-item {
    position: relative;
    padding-left: 2.25rem;
    padding-bottom: 1.75rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 0.6875rem;
    top: 1.75rem;
    bottom: 0;
    width: 2px;
    background: #eef0f3;
}

.timeline-item:last-child::before { display: none; }

.timeline-dot {
    position: absolute;
    left: 0;
    top: 0.125rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    border: 2px solid white;
    box-shadow: 0 0 0 2px #eef0f3;
}

/* ─── Skeleton Loader ────────────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

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

.skeleton-text { height: 0.875rem; margin-bottom: 0.5rem; }
.skeleton-text.short { width: 60%; }
.skeleton-title { height: 1.25rem; width: 40%; margin-bottom: 0.75rem; }
.skeleton-avatar { width: 2.5rem; height: 2.5rem; border-radius: 50%; }
.skeleton-card { height: 80px; margin-bottom: 0.5rem; }
.skeleton-stat { height: 5rem; border-radius: var(--radius-lg); }

/* ─── Stat Cards v2 ──────────────────────────────────────────────────────── */
.stat-card-v2 {
    background: white;
    border: 1px solid #eef0f3;
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card-v2:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px -5px rgba(0,0,0,0.08);
    border-color: #d1d5db;
}

.stat-card-v2.stat-highlight {
    border-color: rgba(99,102,241,0.2);
    background: linear-gradient(135deg, #fff 60%, #f5f3ff 100%);
}

.stat-card-v2.stat-highlight:hover {
    border-color: rgba(99,102,241,0.35);
}

.stat-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #111827;
    line-height: 1.2;
    margin-top: 0.25rem;
    letter-spacing: -0.02em;
}

/* ─── Dashboard Cards ────────────────────────────────────────────────────── */
.dash-card {
    background: white;
    border: 1px solid #eef0f3;
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    transition: box-shadow var(--transition);
}

.dash-card:hover {
    box-shadow: 0 2px 12px -2px rgba(0,0,0,0.05);
}

.dash-card-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: #1f2937;
}

/* ─── Pipeline Bar v2 ────────────────────────────────────────────────────── */
.pipeline-bar-v2 {
    display: flex;
    height: 28px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
    gap: 2px;
}

.pipeline-bar-v2 .pipeline-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-width: 4px;
}

.pipeline-bar-v2 .pipeline-segment:first-child { border-radius: 8px 0 0 8px; }
.pipeline-bar-v2 .pipeline-segment:last-child { border-radius: 0 8px 8px 0; }

.pipeline-bar-v2 .pipeline-segment span {
    font-size: 0.6875rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.pipeline-bar-v2 .pipeline-segment:hover {
    filter: brightness(1.1);
    transform: scaleY(1.1);
}

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

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

.data-table thead th {
    position: sticky;
    top: 0;
    background: #f7f8fa;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    padding: 0.75rem 1rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid #eef0f3;
}

.data-table tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.8125rem;
    color: #374151;
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.data-table tbody tr.selected {
    background: var(--color-primary-light);
}

/* Row checkbox */
.row-check {
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
    border: 2px solid #d1d5db;
    cursor: pointer;
    transition: all var(--transition);
    appearance: none;
    -webkit-appearance: none;
}

.row-check:checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px;
}

/* Bulk Actions Bar */
.bulk-bar {
    background: var(--color-sidebar);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideUp 0.2s ease;
    box-shadow: var(--shadow-lg);
}

.bulk-bar button {
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all var(--transition);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    background: transparent;
}

.bulk-bar button:hover { background: rgba(255,255,255,0.1); }
.bulk-bar .bulk-primary { background: var(--color-primary); border-color: var(--color-primary); }
.bulk-bar .bulk-primary:hover { background: var(--color-primary-dark); }

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

/* ─── Avatar Colors ──────────────────────────────────────────────────────── */
.avatar-1 { background: #818cf8; }
.avatar-2 { background: #00bda5; }
.avatar-3 { background: #6a78d1; }
.avatar-4 { background: #f5c26b; }
.avatar-5 { background: #516f90; }
.avatar-6 { background: #e0558d; }
.avatar-7 { background: #00a4bd; }
.avatar-8 { background: #7c98b6; }

/* ─── Import Drop Zone ───────────────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed #d1d5db;
    border-radius: var(--radius-xl);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.drop-zone:hover, .drop-zone.active {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

/* ─── Toast Notifications ────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-lg);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 360px;
}

.toast.toast-success { background: #1a1a2e; border-left: 4px solid #22c55e; }
.toast.toast-error { background: #1a1a2e; border-left: 4px solid #ef4444; }
.toast.toast-warning { background: #1a1a2e; border-left: 4px solid #f59e0b; }
.toast.toast-info { background: #1a1a2e; border-left: 4px solid #3b82f6; }

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

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

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    max-width: 560px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5625rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    border: none;
    outline: none;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}
.btn-primary:hover { background: var(--color-primary-dark); box-shadow: var(--shadow-md); }

.btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
}
.btn-secondary:hover { background: #f9fafb; border-color: #9ca3af; }

.btn-ghost {
    background: transparent;
    color: #6b7280;
}
.btn-ghost:hover { background: #f3f4f6; color: #374151; }

.btn-danger {
    background: white;
    color: #dc2626;
    border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fef2f2; }

/* ─── Form Inputs ────────────────────────────────────────────────────────── */
.form-input {
    width: 100%;
    padding: 0.5625rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-lg);
    font-size: 0.8125rem;
    transition: all var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder { color: #9ca3af; }

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.375rem;
}

.form-label-sm {
    font-size: 0.75rem;
    color: #6b7280;
}

/* ─── Loading Spinner ────────────────────────────────────────────────────── */
.loading-spinner {
    border: 3px solid #eef0f3;
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    animation: spin 0.8s linear infinite;
}

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

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state .empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #f7f8fa;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.empty-state h4 { font-size: 1rem; font-weight: 600; color: #374151; margin-bottom: 0.375rem; }
.empty-state p { font-size: 0.875rem; color: #9ca3af; }

/* ─── Pill Tabs ──────────────────────────────────────────────────────────── */
.pill-tabs {
    display: flex;
    gap: 0.25rem;
    background: #f3f4f6;
    padding: 0.25rem;
    border-radius: var(--radius);
}

.pill-tab {
    padding: 0.375rem 0.875rem;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.8125rem;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: transparent;
}

.pill-tab:hover { color: #374151; }
.pill-tab.active { background: white; color: #374151; box-shadow: var(--shadow-sm); }

/* ─── Misc ───────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: #eef0f3; }

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hover-actions { opacity: 0; transition: opacity var(--transition); }
tr:hover .hover-actions, .kanban-card:hover .hover-actions { opacity: 1; }

/* Progress pipeline mini bar */
.pipeline-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    background: #eef0f3;
}

.pipeline-bar .segment {
    transition: width 0.5s ease;
}
