/* =============================================================================
   TargetVision Research — Estilos personalizados
   Paleta: blanco, gris oscuro, azul tecnológico (#1e40af, #2563eb, #3b82f6)
   ============================================================================= */

:root {
    --tv-primary:        #1e40af;
    --tv-primary-light:  #2563eb;
    --tv-primary-soft:   #dbeafe;
    --tv-dark:           #1f2937;
    --tv-gray:           #6b7280;
    --tv-gray-light:     #f3f4f6;
    --tv-gray-border:    #e5e7eb;
    --tv-bg:             #f9fafb;
    --tv-sidebar-bg:     #0f172a;
    --tv-sidebar-bg-2:   #1e293b;
    --tv-sidebar-text:   #cbd5e1;
    --tv-sidebar-active: #2563eb;
    --tv-sidebar-width:  260px;
    --tv-topbar-height:  64px;
}

body.tv-app {
    background: var(--tv-bg);
    color: var(--tv-dark);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
}

.tv-skip-link {
    position: fixed;
    top: .75rem;
    left: .75rem;
    z-index: 2000;
    transform: translateY(-160%);
    background: #fff;
    color: var(--tv-primary);
    border: 2px solid var(--tv-primary);
    border-radius: .5rem;
    padding: .5rem .75rem;
    font-weight: 600;
    text-decoration: none;
}
.tv-skip-link:focus {
    transform: translateY(0);
    outline: 3px solid rgba(37, 99, 235, .35);
    outline-offset: 2px;
}

.tv-app :focus-visible {
    outline: 3px solid rgba(37, 99, 235, .45);
    outline-offset: 2px;
}

.tv-content:focus {
    outline: none;
}

/* -----------------------------------------------------------------------------
   Sidebar
   ----------------------------------------------------------------------------- */
.tv-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--tv-sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--tv-sidebar-bg) 0%, var(--tv-sidebar-bg-2) 100%);
    color: var(--tv-sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}
.tv-sidebar__brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.tv-logo {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, #2563eb, #06b6d4);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .65rem;
    box-shadow: 0 4px 14px rgba(37,99,235,.4);
}
.tv-sidebar__title {
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.2;
}
.tv-sidebar__subtitle {
    color: #94a3b8;
    font-size: .75rem;
    margin-top: .15rem;
}

.tv-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: .75rem .5rem;
}
.tv-sidebar__link {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .65rem .9rem;
    margin: .15rem .25rem;
    color: var(--tv-sidebar-text);
    text-decoration: none;
    border-radius: .5rem;
    font-size: .9rem;
    transition: background .15s, color .15s;
    position: relative;
}
.tv-sidebar__link i { width: 18px; text-align: center; opacity: .85; }
.tv-sidebar__link:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}
.tv-sidebar__link.is-active {
    background: var(--tv-sidebar-active);
    color: #fff;
    box-shadow: 0 4px 14px rgba(37,99,235,.45);
}
.tv-sidebar__link.is-active i { opacity: 1; }
.tv-sidebar__link.is-disabled {
    opacity: .55;
    cursor: not-allowed;
}
.tv-badge-soon {
    margin-left: auto;
    background: rgba(255,255,255,.08);
    color: #94a3b8;
    font-size: .65rem;
    padding: .15rem .45rem;
    border-radius: .25rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.tv-sidebar__footer {
    padding: 1rem 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
}
.tv-sidebar__user {
    display: flex;
    align-items: center;
    gap: .65rem;
}
.tv-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #475569, #334155);
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .9rem;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,.12);
}
.tv-sidebar__user-name {
    color: #fff;
    font-size: .85rem;
    line-height: 1.2;
    font-weight: 600;
}
.tv-sidebar__user-role {
    color: #cbd5e1;
    font-size: .7rem;
    margin-top: 1px;
}

/* -----------------------------------------------------------------------------
   Main + Topbar
   ----------------------------------------------------------------------------- */
.tv-main {
    margin-left: var(--tv-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.tv-topbar {
    height: var(--tv-topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--tv-gray-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.tv-topbar__title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
    color: var(--tv-dark);
}
.tv-topbar__actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.tv-topbar__toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--tv-gray-border);
    border-radius: .5rem;
    padding: .4rem .6rem;
    color: var(--tv-dark);
}
.tv-flash {
    font-size: .85rem;
    padding: .35rem .65rem;
    border-radius: .4rem;
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}
.tv-flash--success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }

.tv-content {
    flex: 1;
    padding: 1.5rem;
}

/* -----------------------------------------------------------------------------
   KPI cards
   ----------------------------------------------------------------------------- */
.tv-kpi {
    background: #fff;
    border: 1px solid var(--tv-gray-border);
    border-radius: .75rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: .9rem;
    transition: transform .15s, box-shadow .15s;
}
.tv-kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15,23,42,.06);
}
.tv-kpi__icon {
    width: 48px; height: 48px;
    border-radius: .65rem;
    background: var(--tv-primary-soft);
    color: var(--tv-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.tv-kpi__value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--tv-dark);
    line-height: 1.1;
}
.tv-kpi__label {
    color: var(--tv-gray);
    font-size: .8rem;
    margin-top: .15rem;
}
.tv-kpi__hint {
    text-align: right;
    font-size: .7rem;
    color: var(--tv-gray);
    margin-top: .25rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* -----------------------------------------------------------------------------
   Next steps list
   ----------------------------------------------------------------------------- */
.tv-next-steps li {
    padding: .65rem 0;
    border-bottom: 1px dashed var(--tv-gray-border);
    display: flex;
    align-items: center;
    gap: .75rem;
}
.tv-next-steps li:last-child { border-bottom: 0; }
.tv-step-badge {
    background: var(--tv-primary-soft);
    color: var(--tv-primary);
    font-weight: 700;
    font-size: .75rem;
    padding: .25rem .55rem;
    border-radius: .35rem;
    min-width: 36px;
    text-align: center;
}

/* -----------------------------------------------------------------------------
   Overlay (móvil)
   ----------------------------------------------------------------------------- */
.tv-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.55);
    z-index: 1035;
}
.tv-overlay.is-active { display: block; }

/* -----------------------------------------------------------------------------
   Responsive
   ----------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .tv-sidebar { transform: translateX(-100%); }
    .tv-sidebar.is-open { transform: translateX(0); }
    .tv-main { margin-left: 0; }
    .tv-topbar__toggle { display: inline-flex; }
}

/* -----------------------------------------------------------------------------
   Tablas sortables + Paginación (Bloque 2.3)
   ----------------------------------------------------------------------------- */
.tv-table-sortable th a,
.tv-table-sortable th span {
    display: inline-flex;
    align-items: center;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.tv-table-sortable th a:hover {
    color: var(--tv-primary);
    text-decoration: underline;
}

.tv-pagination .pagination {
    margin-bottom: 0;
}
.tv-pagination .page-link {
    color: var(--tv-primary);
}
.tv-pagination .page-item.active .page-link {
    background-color: var(--tv-primary);
    border-color: var(--tv-primary);
    color: #fff;
}
.tv-pagination .page-item.disabled .page-link {
    color: var(--tv-gray);
}

/* -----------------------------------------------------------------------------
   Loading state + form UX (Bloque 2.4)
   ----------------------------------------------------------------------------- */
button.is-loading,
button[type="submit"]:disabled {
    cursor: not-allowed;
    opacity: 0.85;
}
button.is-loading .spinner-border {
    vertical-align: middle;
}

/* Inputs con validación cliente */
.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    box-shadow: 0 0 0 .2rem rgba(220, 53, 69, .15);
}
.form-control.is-valid:focus,
.form-select.is-valid:focus {
    box-shadow: 0 0 0 .2rem rgba(25, 135, 84, .15);
}

/* Contador de caracteres */
.tv-counter {
    display: block;
    text-align: right;
    margin-top: .25rem;
}

/* Transición para alerts que se auto-cierran */
.alert {
    transition: opacity .35s ease, transform .35s ease;
}

/* Indicador visual de fila "hover" en tablas */
.table-hover tbody tr {
    transition: background-color .12s ease;
}
