/* =========================================================
   CRM de ACR - Tema visual
   Paleta extraída de las capturas de referencia (estilo Pipedrive):
   morado/violeta primario, tarjetas blancas redondeadas, pills de
   colores para etiquetas, barra de progreso verde, notas resaltadas.
   ========================================================= */

:root {
    --crm-primary: #6C4CFF;
    --crm-primary-dark: #5636D1;
    --crm-primary-light: #EFEAFF;
    --crm-success: #1BA672;
    --crm-success-light: #E4F7EF;
    --crm-warning-bg: #FFF6D8;
    --crm-warning-border: #F0DE9B;
    --crm-danger: #E5484D;
    --crm-bg: #F5F6FA;
    --crm-card-bg: #FFFFFF;
    --crm-border: #E4E7EC;
    --crm-text: #1F2430;
    --crm-text-muted: #6B7280;
    --crm-radius: 10px;
    --crm-shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);

    --tag-cliente: #2FBF9E;
    --tag-muy-interesado: #E5484D;
    --tag-interesado: #F0B429;
    --tag-poco-interesado: #3B82F6;
}

* { box-sizing: border-box; }

body {
    background-color: var(--crm-bg);
    color: var(--crm-text);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}

a { color: var(--crm-primary); text-decoration: none; }
a:hover { color: var(--crm-primary-dark); text-decoration: underline; }

/* ---------- Navbar ---------- */
.navbar-crm {
    background: var(--crm-card-bg);
    border-bottom: 1px solid var(--crm-border);
    padding: .55rem 1.25rem;
}

.navbar-crm .brand-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .1rem;
    line-height: 1;
}

.navbar-crm .brand-logo {
    height: 28px;
    width: auto;
    object-fit: contain;
}

.navbar-crm .brand-title {
    font-weight: 700;
    font-size: .95rem;
    color: var(--crm-primary);
}

.navbar-crm .nav-link-crm {
    color: var(--crm-text-muted);
    font-weight: 600;
    font-size: .92rem;
    padding: .5rem .85rem;
    border-radius: 8px;
}

.navbar-crm .nav-link-crm.active,
.navbar-crm .nav-link-crm:hover {
    color: var(--crm-primary);
    background: var(--crm-primary-light);
}

/* Módulo visible pero deshabilitado por permisos de rol: se ve, pero no se puede entrar. */
.nav-link-crm.nav-link-deshabilitado {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}
.navbar-crm .nav-link-crm.nav-link-deshabilitado:hover {
    color: var(--crm-text-muted);
    background: transparent;
}

/* Menú móvil (offcanvas) */
.offcanvas .nav-link-crm {
    display: block;
    width: 100%;
    color: var(--crm-text);
    font-weight: 600;
    font-size: 1rem;
    padding: .85rem 1rem;
    border-radius: 8px;
}

.offcanvas .nav-link-crm.active,
.offcanvas .nav-link-crm:hover {
    color: var(--crm-primary);
    background: var(--crm-primary-light);
}

.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--crm-primary-light);
    color: var(--crm-primary-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
}

/* ---------- Botones ---------- */
.btn-crm-primary {
    background: var(--crm-primary);
    border-color: var(--crm-primary);
    color: #fff;
    font-weight: 600;
    border-radius: 8px;
}
.btn-crm-primary:hover { background: var(--crm-primary-dark); border-color: var(--crm-primary-dark); color: #fff; }

.btn-crm-success {
    background: var(--crm-success);
    border-color: var(--crm-success);
    color: #fff;
    font-weight: 600;
    border-radius: 8px;
}
.btn-crm-success:hover { filter: brightness(0.92); color: #fff; }

.btn-crm-outline {
    background: #fff;
    border: 1px solid var(--crm-border);
    color: var(--crm-text);
    font-weight: 600;
    border-radius: 8px;
}
.btn-crm-outline:hover { border-color: var(--crm-primary); color: var(--crm-primary); }

/* ---------- Tarjetas ---------- */
.card-crm {
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow);
}

.card-crm .card-header-crm {
    padding: .9rem 1.1rem;
    border-bottom: 1px solid var(--crm-border);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-crm .card-body-crm { padding: 1.1rem; }

/* ---------- Panel lateral de detalle (expediente) ---------- */
.detalle-sidebar { display: flex; flex-direction: column; gap: 1rem; }

.detalle-section {
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    padding: 1rem;
}

.detalle-section h6 {
    font-weight: 700;
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

/* ---------- Pestañas ---------- */
.tabs-crm {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--crm-border);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tabs-crm .tab-link {
    padding: .6rem 1rem;
    font-weight: 600;
    color: var(--crm-text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.tabs-crm .tab-link.active {
    color: var(--crm-primary);
    border-bottom-color: var(--crm-primary);
}

/* ---------- Pills / Etiquetas ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    padding: .18rem .6rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .02em;
    text-transform: uppercase;
}

/* ---------- Nota resaltada ---------- */
.nota-highlight {
    background: var(--crm-warning-bg);
    border: 1px solid var(--crm-warning-border);
    border-radius: var(--crm-radius);
    padding: .85rem 1rem;
}

/* ---------- Barra de progreso de trato ---------- */
.progreso-trato {
    height: 6px;
    border-radius: 4px;
    background: var(--crm-border);
    overflow: hidden;
}
.progreso-trato .relleno {
    height: 100%;
    background: var(--crm-success);
}

/* ---------- Timeline / Historial ---------- */
.timeline-item {
    position: relative;
    padding-left: 2rem;
    padding-bottom: 1.25rem;
    border-left: 2px dashed var(--crm-border);
    margin-left: .5rem;
}
.timeline-item:last-child { border-left-color: transparent; }
.timeline-item .timeline-dot {
    position: absolute;
    left: -7px;
    top: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--crm-primary);
    border: 2px solid #fff;
}

/* ---------- Adjuntos / miniaturas ---------- */
.miniatura-adjunto {
    width: 92px;
    height: 92px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--crm-border);
    cursor: pointer;
    transition: transform .12s ease;
}
.miniatura-adjunto:hover { transform: scale(1.04); box-shadow: var(--crm-shadow); }

.adjunto-item { position: relative; }
.btn-eliminar-adjunto {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--crm-danger);
    color: #fff;
    border: 2px solid #fff;
    font-size: .65rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    box-shadow: var(--crm-shadow);
}
.btn-eliminar-adjunto:hover { filter: brightness(0.9); }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    position: relative;
}
.login-page::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(45,20,120,.55), rgba(20,10,60,.65));
}
.login-card {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 2.25rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-card .brand {
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--crm-primary);
    margin-bottom: .25rem;
}

.login-brand-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .4rem;
    margin-bottom: .25rem;
}

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

/* ---------- Utilidades ---------- */
.text-crm-muted { color: var(--crm-text-muted); }
.bg-crm-primary-light { background: var(--crm-primary-light); }
.rounded-crm { border-radius: var(--crm-radius); }

.table-crm thead th {
    color: var(--crm-text-muted);
    font-weight: 700;
    font-size: .78rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--crm-border);
}
.table-crm td { vertical-align: middle; }
.table-crm tbody tr:hover { background: var(--crm-primary-light); }
