/* ====================================================================
   eRAsolar Cloud System - CRM Clientes & Máquina de Ventas 360°
   Styles & UI Design System
   ==================================================================== */

:root {
    --era-gold: #fdb813;
    --era-gold-dark: #d97706;
    --era-gold-light: #fef3c7;
    --era-navy: #0f172a;
    --era-navy-light: #1e293b;
    --era-blue: #0ea5e9;
    --era-blue-dark: #0284c7;
    --era-blue-light: #e0f2fe;
    --era-emerald: #10b981;
    --era-emerald-dark: #059669;
    --era-emerald-light: #d1fae5;
    --era-purple: #8b5cf6;
    --era-purple-light: #ede9fe;
    --era-red: #ef4444;
    --era-red-light: #fee2e2;
    --era-orange: #f97316;
    --era-orange-light: #ffedd5;
    --era-slate-50: #f8fafc;
    --era-slate-100: #f1f5f9;
    --era-slate-200: #e2e8f0;
    --era-slate-300: #cbd5e1;
    --era-slate-400: #94a3b8;
    --era-slate-500: #64748b;
    --era-slate-600: #475569;
    --era-slate-700: #334155;
    --era-slate-800: #1e293b;
    --era-slate-900: #0f172a;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-brand: 'Outfit', var(--font-sans);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: var(--font-sans);
    background: #f8fafc;
    color: var(--era-slate-800);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- HEADER PRINCIPAL --- */
.era-header {
    background: #0f172a;
    color: white;
    padding: 0.75rem 1.5rem;
    border-bottom: 2px solid var(--era-gold);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.brand-text h1 {
    font-family: var(--font-brand);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.brand-tag {
    background: var(--era-gold);
    color: #0f172a;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--era-slate-400);
}

/* --- NAVEGACIÓN UNIVERSAL eRASOLAR --- */
.era-suite-links {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.era-suite-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--era-slate-300);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    cursor: pointer;
}

.era-suite-pill:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-color: var(--era-gold);
}

.era-suite-pill.active {
    background: var(--era-gold);
    color: #0f172a;
    font-weight: 800;
    border-color: var(--era-gold);
}

.era-suite-pill i {
    width: 14px;
    height: 14px;
}

.era-suite-divider {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 0.2rem;
}

/* --- CONTENEDOR PRINCIPAL --- */
.crm-container {
    max-width: 100%;
    padding: 1rem 1.25rem 3rem 1.25rem;
    margin: 0 auto;
}

/* --- TOP KPI CARDS --- */
.crm-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.crm-kpi-card {
    background: white;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    border: 1px solid var(--era-slate-200);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.crm-kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--card-accent, var(--era-gold));
}

.kpi-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.kpi-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--era-slate-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--icon-bg, #fef3c7);
    color: var(--icon-color, #d97706);
}

.kpi-val {
    font-size: 1.25rem;
    font-weight: 800;
    font-family: var(--font-brand);
    color: var(--era-slate-900);
    line-height: 1.2;
}

.kpi-meta {
    font-size: 0.7rem;
    color: var(--era-slate-500);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* --- TOOLBAR & FILTERS --- */
.crm-toolbar {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--era-slate-200);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-input-wrap {
    position: relative;
    min-width: 240px;
}

.search-input-wrap i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--era-slate-400);
    width: 14px;
    height: 14px;
}

.search-input {
    width: 100%;
    padding: 0.45rem 0.65rem 0.45rem 2rem;
    font-size: 0.8rem;
    border: 1px solid var(--era-slate-300);
    border-radius: 6px;
    outline: none;
    background: var(--era-slate-50);
    transition: all 0.2s ease;
}

.search-input:focus {
    border-color: var(--era-gold);
    background: white;
    box-shadow: 0 0 0 2px rgba(253, 184, 19, 0.2);
}

.filter-select {
    padding: 0.45rem 0.65rem;
    font-size: 0.8rem;
    border: 1px solid var(--era-slate-300);
    border-radius: 6px;
    background: white;
    color: var(--era-slate-700);
    font-weight: 500;
    cursor: pointer;
    outline: none;
}

.filter-select:focus {
    border-color: var(--era-gold);
}

/* --- BOTONES --- */
.btn-gold {
    background: var(--era-gold);
    color: #0f172a;
    border: 1px solid var(--era-gold-dark);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-gold:hover {
    background: #eab308;
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.btn-primary {
    background: #0f172a;
    color: white;
    border: 1px solid #1e293b;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: #1e293b;
    color: var(--era-gold);
}

.btn-secondary {
    background: white;
    color: var(--era-slate-700);
    border: 1px solid var(--era-slate-300);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--era-slate-50);
    border-color: var(--era-slate-400);
}

.btn-whatsapp {
    background: #25d366;
    color: white;
    border: none;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-whatsapp:hover {
    background: #128c7e;
    transform: translateY(-1px);
}

/* --- KANBAN BOARD CONTAINER --- */
.kanban-board {
    display: flex;
    gap: 0.85rem;
    overflow-x: auto;
    padding-bottom: 1.5rem;
    min-height: calc(100vh - 270px);
}

.kanban-column {
    flex: 0 0 300px;
    min-width: 300px;
    background: #f1f5f9;
    border-radius: 10px;
    border: 1px solid var(--era-slate-200);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 250px);
}

.kanban-column-header {
    padding: 0.75rem 0.85rem;
    border-bottom: 2px solid var(--col-color, #cbd5e1);
    background: white;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.col-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.col-icon {
    width: 16px;
    height: 16px;
    color: var(--col-color, var(--era-slate-700));
}

.col-title {
    font-weight: 800;
    font-size: 0.82rem;
    color: var(--era-slate-900);
}

.col-badge {
    background: var(--era-slate-100);
    color: var(--era-slate-700);
    font-size: 0.68rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 10px;
    border: 1px solid var(--era-slate-200);
}

.col-amount {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--era-slate-500);
}

.kanban-column-body {
    padding: 0.65rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

/* --- KANBAN CARD --- */
.kanban-card {
    background: white;
    border-radius: 8px;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--era-slate-200);
    box-shadow: var(--shadow-sm);
    cursor: grab;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    position: relative;
}

.kanban-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--era-gold);
    transform: translateY(-2px);
}

.kanban-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.35rem;
}

.card-client-name {
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--era-slate-900);
    line-height: 1.25;
}

.card-code {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--era-slate-500);
    background: var(--era-slate-100);
    padding: 1px 4px;
    border-radius: 3px;
    display: inline-block;
}

/* --- BADGES LEAD SCORING --- */
.tier-badge {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    text-transform: uppercase;
}

.tier-a {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.tier-b {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}

.tier-c {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

/* --- SEMÁFORO DE ACTIVIDAD / TEMPERATURA --- */
.temp-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.temp-hot {
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
}

.temp-warm {
    background: #f59e0b;
    box-shadow: 0 0 6px #f59e0b;
}

.temp-cold {
    background: #ef4444;
    box-shadow: 0 0 6px #ef4444;
}

.card-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem 0.5rem;
    font-size: 0.7rem;
    color: var(--era-slate-600);
    background: var(--era-slate-50);
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--era-slate-100);
}

.card-stat-label {
    color: var(--era-slate-400);
    font-size: 0.65rem;
    display: block;
}

.card-stat-val {
    font-weight: 700;
    color: var(--era-slate-800);
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.2rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--era-slate-100);
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.card-btn-action {
    background: none;
    border: 1px solid var(--era-slate-200);
    padding: 3px 6px;
    border-radius: 4px;
    color: var(--era-slate-600);
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.15s ease;
}

.card-btn-action:hover {
    background: var(--era-slate-100);
    color: var(--era-slate-900);
    border-color: var(--era-slate-300);
}

/* --- MODAL SYSTEM --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-card {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 780px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: modalSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.wide {
    max-width: 960px;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    background: #0f172a;
    color: white;
    padding: 0.85rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--era-gold);
}

.modal-header h3 {
    font-family: var(--font-brand);
    font-size: 1.05rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--era-slate-400);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: color 0.15s ease;
}

.modal-close:hover {
    color: white;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 0.85rem 1.25rem;
    background: var(--era-slate-50);
    border-top: 1px solid var(--era-slate-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* --- FORM STYLES --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--era-slate-700);
}

.form-control {
    padding: 0.5rem 0.65rem;
    font-size: 0.82rem;
    border: 1px solid var(--era-slate-300);
    border-radius: 6px;
    outline: none;
    background: white;
    color: var(--era-slate-800);
    transition: all 0.2s ease;
}

.form-control:focus {
    border-color: var(--era-gold);
    box-shadow: 0 0 0 2px rgba(253, 184, 19, 0.2);
}

/* --- PITCH CALCULATOR & FINANCIAL BOXES --- */
.pitch-box {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--era-gold);
    margin-bottom: 1rem;
}

.pitch-headline {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--era-gold);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.pitch-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.65rem;
}

.pitch-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pitch-label {
    font-size: 0.65rem;
    color: var(--era-slate-400);
    text-transform: uppercase;
}

.pitch-value {
    font-size: 1.05rem;
    font-weight: 800;
    color: white;
    font-family: var(--font-brand);
}

/* --- OBJECIONES ACORDEÓN --- */
.objection-item {
    background: var(--era-slate-50);
    border: 1px solid var(--era-slate-200);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.objection-trigger {
    padding: 0.65rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--era-slate-800);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.objection-trigger:hover {
    background: #fef3c7;
}

.objection-content {
    padding: 0.75rem 0.85rem;
    font-size: 0.75rem;
    color: var(--era-slate-600);
    border-top: 1px solid var(--era-slate-200);
    background: var(--era-slate-50);
    display: none;
}

.objection-item.open .objection-content {
    display: block;
}

/* --- CHECKLIST REQUISITOS --- */
.req-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    background: var(--era-slate-50);
    border: 1px solid var(--era-slate-200);
    font-size: 0.78rem;
    margin-bottom: 0.35rem;
}

.req-item input[type="checkbox"] {
    accent-color: var(--era-gold);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* --- TOAST NOTIFICATIONS --- */
.crm-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #0f172a;
    color: white;
    padding: 0.75rem 1.15rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--era-gold);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 2000;
    animation: toastIn 0.25s ease-out;
}

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