:root {
    --primary-blue: #1546A0;
    --blue-shadow: #0F2F6B;
    --blue-highlight: #2E6CFF;
    --light-blue: #F4F7FB;
    --dark: #101820;
    --gray: #4B4F54;
    --turquoise: #2CD5C4;
    --border-gray: #D9DEE5;
    --content-bg: #EEF1F6;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden; /* el navegador NUNCA arma su propia barra de scroll a nivel de
                          página — todo el scroll real vive adentro de .main-area, para
                          que el men\u00fa de la izquierda quede siempre fijo */
}

body {
    font-family: 'Century Gothic', 'Poppins', 'Segoe UI', Tahoma, sans-serif;
    margin: 0;
    height: 100%;
    background: var(--content-bg);
    font-size: 14px;
    color: var(--dark);
    overflow: hidden; /* mismo candado que html — ver comentario arriba */
}

h1 {
    font-size: 1.6rem;
    color: var(--dark);
    margin: 0 0 1rem 0;
    letter-spacing: -0.3px;
}

h3 {
    font-size: 1rem;
    color: var(--primary-blue);
    margin: 0 0 1rem 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--light-blue);
}

a {
    color: var(--primary-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

/* ===================== LAYOUT PRINCIPAL ===================== */

.page-layout {
    display: flex;
    height: 100vh; /* antes: min-height:100vh — dejaba que TODO (menú + contenido) creciera
                      junto y se moviera como un solo bloque al scrollear. Con altura fija acá,
                      cada columna de abajo maneja su propio scroll por separado. */
    width: 100%;
    max-width: 100vw;
    overflow: hidden; /* nada se scrollea en este nivel — ver .sidebar y .main-area abajo */
}

/* ---- SIDEBAR ---- */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--blue-shadow) 0%, #0B2451 100%);
    color: white;
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
}

.sidebar-logo-box {
    background: var(--primary-blue);
    border-radius: 18px;
    padding: 16px 10px;
    margin-bottom: 10px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.sidebar-logo-box .logo-on {
    font-size: 28px;
    font-weight: bold;
    color: white;
    line-height: 1.1;
    letter-spacing: 1px;
}

.sidebar-logo-box .logo-insurance {
    font-size: 12px;
    font-weight: 600;
    color: #D9DEE5;
    letter-spacing: 2px;
}

.sidebar-company {
    text-align: center;
    color: white;
    font-size: 13px;
    font-weight: bold;
    margin-top: 6px;
}

.sidebar-subtitle {
    text-align: center;
    color: #8FA0C4;
    font-size: 10px;
    letter-spacing: 1px;
    margin-bottom: 20px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #D6DEEB;
    text-decoration: none;
    padding: 11px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 3px;
    transition: background 0.15s ease, transform 0.1s ease;
}

.sidebar a i {
    width: 18px;
    text-align: center;
    font-size: 15px;
}

.sidebar a:hover {
    background: rgba(46, 108, 255, 0.25);
    color: white;
    text-decoration: none;
}

.sidebar a.active {
    background: var(--blue-highlight);
    color: white;
    box-shadow: 0 2px 8px rgba(46,108,255,0.5);
}

.sidebar-divider {
    height: 1px;
    background: var(--blue-highlight);
    opacity: 0.3;
    margin: 14px 4px;
}

.sidebar-logout {
    margin-top: auto;
    padding-top: 10px;
}

.sidebar-logout button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.06);
    color: #D6DEEB;
    border: none;
    padding: 11px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.sidebar-logout button:hover {
    background: rgba(248, 113, 113, 0.2);
    color: white;
}

/* ---- CONTENIDO / HEADER ---- */
.main-area {
    flex: 1;
    min-width: 0; /* FIX: sin esto, cualquier contenido ancho (tabla larga, texto sin
                     salto de línea) empuja este bloque más allá del viewport y corta
                     la barra superior — bug clásico de flexbox, pasaba en TODAS las
                     pantallas, no solo en una puntual. */
    height: 100vh;
    overflow-y: auto; /* ACÁ vive el scroll real de "la página" ahora — el menú de al
                          lado (.sidebar) no se mueve para nada mientras esto scrollea */
    background: var(--content-bg);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.top-header {
    background: white;
    border-radius: 16px;
    padding: 18px 24px;
    margin-bottom: 18px;
    box-shadow: 0 4px 16px rgba(15,47,107,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-header .title {
    font-size: 22px;
    font-weight: bold;
    color: var(--dark);
    margin: 0;
}

.top-header .subtitle {
    font-size: 13px;
    color: #6B7280;
    margin: 3px 0 0 0;
}

.top-header .user-box {
    background: var(--light-blue);
    border-radius: 18px;
    padding: 8px 18px;
    min-width: 110px;
    text-align: center;
}

.top-header .user-box .user-name {
    font-size: 13px;
    font-weight: bold;
    color: #111827;
}

.top-header .user-box .user-role {
    font-size: 11px;
    color: #6B7280;
}

.content {
    flex: 1;
    width: 100%;    /* antes: max-width:1200px dejaba una franja gris vacía en pantallas
                        anchas — un CRM con tablas/formularios debe usar todo el ancho
                        disponible, no comportarse como un blog angosto */
    min-width: 0;   /* mismo fix que .main-area — evita que una tabla ancha empuje el layout */
    overflow-x: auto; /* si igual queda algo más ancho (tabla grande), scrollea adentro
                          en vez de romper la página entera */
}

/* ===================== TABLAS ===================== */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    font-size: 0.88rem;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(15,47,107,0.07);
    border: 1px solid var(--border-gray);
}

th, td {
    text-align: left;
    padding: 0.7rem 1rem;
    white-space: nowrap;
}

th {
    background: linear-gradient(135deg, var(--blue-shadow) 0%, var(--primary-blue) 100%);
    color: white;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

tbody tr {
    border-bottom: 1px solid var(--border-gray);
    transition: background 0.12s ease;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:nth-child(even) {
    background: #FAFBFD;
}

tbody tr:hover {
    background: var(--light-blue);
}

/* ===================== BOTONES ===================== */

button {
    padding: 0.55rem 1.15rem;
    background: linear-gradient(135deg, var(--blue-shadow) 0%, var(--primary-blue) 45%, var(--blue-highlight) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(21,70,160,0.25);
    transition: transform 0.08s ease, box-shadow 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(21,70,160,0.35);
}

button:active {
    transform: translateY(0);
}

/* botones secundarios (Cancelar, Editar) — un poco más discretos */
table button, .form-box button:not(:first-of-type) {
    background: white;
    color: var(--primary-blue);
    border: 1px solid var(--border-gray);
    box-shadow: none;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
}

table button:hover, .form-box button:not(:first-of-type):hover {
    background: var(--light-blue);
    box-shadow: none;
    transform: none;
}

/* ===================== FORMULARIOS ===================== */

.login-box {
    max-width: 380px;
    margin: 4rem auto;
    padding: 2.2rem;
    background: white;
    border-radius: 18px;
    box-shadow: 0 10px 40px rgba(15,47,107,0.15);
}

.login-box h2 {
    color: var(--primary-blue);
    margin-top: 0;
}

input, select, textarea {
    padding: 0.55rem 0.75rem;
    box-sizing: border-box;
    border: 1px solid var(--border-gray);
    border-radius: 7px;
    font-family: inherit;
    font-size: 0.88rem;
    background: white;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue-highlight);
    box-shadow: 0 0 0 3px rgba(46,108,255,0.15);
}

.login-box input {
    width: 100%;
    margin-bottom: 0.85rem;
}

.error-msg {
    color: #dc2626;
    margin-bottom: 0.75rem;
    font-size: 0.88rem;
}

.success-msg {
    color: #16a34a;
    margin-bottom: 0.75rem;
    font-size: 0.88rem;
}

.hint-text {
    color: #6b7280;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.form-box {
    background: white;
    padding: 1.4rem 1.6rem;
    border-radius: 14px;
    box-shadow: 0 3px 14px rgba(15,47,107,0.07);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-gray);
}

.form-box button {
    margin-right: 0.5rem;
    margin-top: 0.25rem;
}

.field {
    display: inline-block;
    vertical-align: top;
    margin: 0 12px 14px 0;
}

.field label {
    display: block;
    font-size: 10.5px;
    color: #6B7280;
    margin-bottom: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.field input, .field select {
    min-width: 170px;
}

.field input[type="checkbox"] {
    min-width: auto;
    margin-right: 4px;
    vertical-align: middle;
    accent-color: var(--primary-blue);
}

/* ===================== TAREAS ===================== */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 1rem;
}

.toolbar input, .toolbar select {
    height: 40px;
}

.toolbar input[type="text"] {
    flex: 1;
    min-width: 200px;
}

/* !important acá a propósito: sin esto, tbody tr:nth-child(even) (el rayado alternado de
   filas, más arriba en este archivo) le GANA en especificidad CSS a estas clases en las filas
   que caen en posición par de la tabla — así se veía una tarea vencida en rojo y la de al lado
   (misma condición, posición par) sin resaltar. El color de estado siempre debe ganar sobre el
   rayado decorativo. */
.task-row-urgente { background: #FFB3B3 !important; }
.task-row-alta { background: #FFD9B3 !important; }
.task-row-media { background: #FFF6B3 !important; }
.task-row-baja { background: #D6E9FF !important; }
.task-row-vencida { background: #FF8080 !important; font-weight: bold; }
.task-row-completada { background: #C8F7C5 !important; color: #1B5E20; }
.task-row-cancelada { background: #E0E0E0 !important; color: #555555; }

.task-row-urgente:hover, .task-row-alta:hover, .task-row-media:hover,
.task-row-baja:hover, .task-row-vencida:hover,
.task-row-completada:hover, .task-row-cancelada:hover {
    filter: brightness(0.96);
    cursor: pointer;
}

/* ===================== DASHBOARD KPIs ===================== */

.kpi-row {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.kpi-card {
    background: white;
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 3px 14px rgba(15,47,107,0.08);
    border: 1px solid var(--border-gray);
    flex: 1;
    min-width: 160px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.15s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
}

.kpi-card .kpi-icon {
    font-size: 24px;
}

.kpi-card .kpi-label {
    font-size: 12px;
    font-weight: 700;
    color: #6B7280;
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.kpi-card .kpi-number {
    font-size: 26px;
    font-weight: bold;
    color: var(--primary-blue);
}

.kpi-blue { background: #EFF6FF; border-color: #BFDBFE; }
.kpi-blue .kpi-label { color: #1D4ED8; }
.kpi-blue .kpi-number { color: #2563EB; }

.kpi-green { background: #F0FDF4; border-color: #BBF7D0; }
.kpi-green .kpi-label { color: #166534; }
.kpi-green .kpi-number { color: #16A34A; }

.kpi-purple { background: #F5F3FF; border-color: #DDD6FE; }
.kpi-purple .kpi-label { color: #6D28D9; }
.kpi-purple .kpi-number { color: #7C3AED; }

.kpi-red { background: #FFF1F2; border-color: #FECACA; }
.kpi-red .kpi-label { color: #991B1B; }
.kpi-red .kpi-number { color: #DC2626; }

.kpi-orange { background: #FFF7ED; border-color: #FED7AA; }
.kpi-orange .kpi-label { color: #9A3412; }
.kpi-orange .kpi-number { color: #D97706; }

.chart-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.chart-box {
    background: white;
    border-radius: 16px;
    padding: 1.4rem;
    box-shadow: 0 3px 14px rgba(15,47,107,0.08);
    border: 1px solid var(--border-gray);
    flex: 1;
    min-width: 320px;
}

.bar-chart {
    width: 100%;
    height: auto;
}

.bar-label {
    font-size: 11px;
    fill: #374151;
}

.bar-value {
    font-size: 12px;
    fill: #111827;
    font-weight: bold;
}

.donut-chart {
    width: 100%;
    max-width: 220px;
    height: auto;
}

.donut-center {
    font-size: 22px;
    font-weight: bold;
    fill: #111827;
}

.donut-legend {
    font-size: 11px;
    fill: #374151;
}

.empty-msg {
    color: #9ca3af;
    font-style: italic;
    padding: 1rem 0;
}

.filter-inactive {
    background: white;
    color: var(--primary-blue);
    border: 1px solid var(--border-gray);
    box-shadow: none;
}

.status-card {
    background: white;
    border-radius: 14px;
    padding: 14px 18px;
    border: 1px solid var(--border-gray);
    flex: 1;
    min-width: 200px;
    box-shadow: 0 2px 10px rgba(15,47,107,0.06);
}

.status-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-value {
    font-size: 22px;
    font-weight: bold;
    margin: 2px 0;
}

.status-detail {
    font-size: 11px;
    color: #6B7280;
}

/* ===================== ACTIVIDAD ===================== */

.activity-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    border-radius: 14px;
    padding: 14px 18px;
    margin-bottom: 10px;
    border: 1px solid var(--border-gray);
    box-shadow: 0 2px 8px rgba(15,47,107,0.05);
}

.activity-icon {
    font-size: 20px;
}

.activity-body {
    flex: 1;
}

.activity-title {
    font-weight: bold;
    color: #111827;
}

.activity-meta {
    font-size: 12px;
    color: #6B7280;
    margin-top: 2px;
}

.activity-detail {
    font-size: 12px;
    color: #374151;
    margin-top: 4px;
}

.activity-when {
    font-size: 12px;
    color: #6B7280;
    white-space: nowrap;
}

/* ===================== KANBAN DE LEADS ===================== */

.kanban-board {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.kanban-column {
    background: #EEF1F6;
    border-radius: 14px;
    padding: 12px;
    min-width: 250px;
    max-width: 250px;
    flex-shrink: 0;
    min-height: 200px;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 13px;
    color: #374151;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.kanban-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.kanban-count {
    margin-left: auto;
    background: white;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    color: #6B7280;
}

.kanban-card {
    background: white;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 6px rgba(15,47,107,0.08);
    cursor: grab;
    border: 1px solid var(--border-gray);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card-name {
    font-weight: 700;
    font-size: 13px;
    color: #111827;
}

.kanban-card-meta {
    font-size: 12px;
    color: #6B7280;
    margin-top: 2px;
}

.kanban-card-tag {
    display: inline-block;
    background: var(--light-blue);
    color: var(--primary-blue);
    font-size: 10px;
    font-weight: 600;
    border-radius: 6px;
    padding: 2px 6px;
    margin-top: 6px;
}

.kanban-card-priority {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    border-radius: 6px;
    padding: 2px 6px;
    margin-top: 6px;
    margin-left: 4px;
}

.priority-alta { background: #FEE2E2; color: #B91C1C; }
.priority-media { background: #FEF3C7; color: #92400E; }
.priority-baja { background: #DCFCE7; color: #166534; }

.kanban-column {
    max-height: 70vh;
    overflow-y: auto;
}

.pagination-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #6B7280;
}

.pagination-bar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
