/**
 * Huden — overrides finales (se cargan al cierre del body para ganar a estilos inline de páginas).
 */

html[data-huden-theme] body.client-portal-body {
    background: var(--huden-bg-page-gradient, var(--huden-bg-page, #020617)) !important;
    color: var(--huden-text, #e5e7eb) !important;
}

html[data-huden-theme] body.client-portal-body .card-vcc,
html[data-huden-theme] body.client-portal-body .card-vcc.p-4 {
    background: var(--huden-bg-card, #ffffff) !important;
    border-color: var(--huden-border, rgba(255, 255, 255, 0.08)) !important;
    color: var(--huden-text, inherit) !important;
}

html[data-huden-theme] body.client-portal-body .app-card {
    background: var(--huden-bg-card, linear-gradient(145deg, #0f172a, #020617)) !important;
    border-color: var(--huden-border, rgba(255, 255, 255, 0.08)) !important;
    color: var(--huden-text, #e5e7eb) !important;
}

html[data-huden-theme] body.client-portal-body .app-card:hover {
    border-color: color-mix(in srgb, var(--huden-accent, #38bdf8) 45%, transparent) !important;
}

html[data-huden-theme] body.client-portal-body .portal-apps-search {
    background: var(--huden-bg-input, rgba(15, 23, 42, 0.85)) !important;
    border-color: var(--huden-border, rgba(148, 163, 184, 0.25)) !important;
    color: var(--huden-text, #e2e8f0) !important;
}

html[data-huden-theme] body.client-portal-body .portal-apps-search:focus {
    border-color: color-mix(in srgb, var(--huden-accent, #38bdf8) 55%, transparent) !important;
    box-shadow: 0 0 0 0.2rem var(--huden-accent-ring, rgba(56, 189, 248, 0.15)) !important;
}

html[data-huden-theme] body.client-portal-body .portal-category-chip {
    background: var(--huden-bg-input, rgba(15, 23, 42, 0.65)) !important;
    border-color: var(--huden-border, rgba(148, 163, 184, 0.25)) !important;
    color: var(--huden-text-muted, #cbd5e1) !important;
}

html[data-huden-theme] body.client-portal-body .portal-category-chip.active,
html[data-huden-theme] body.client-portal-body .portal-view-toggle .btn.active {
    background: var(--huden-accent-soft, rgba(59, 130, 246, 0.25)) !important;
    border-color: color-mix(in srgb, var(--huden-accent, #38bdf8) 65%, transparent) !important;
    color: var(--huden-heading, var(--huden-text, #eff6ff)) !important;
}

/* Módulos con layout propio (Agenda, Formulación Magistral, etc.) */
html[data-huden-theme] body:not(.client-portal-body) {
    background: var(--huden-bg-page, #020617) !important;
    color: var(--huden-text, #e5e7eb) !important;
}

html[data-huden-theme] #vccSidebar {
    background: var(--huden-bg-sidebar, #020617) !important;
}

html[data-huden-theme] .sidebar {
    background: var(--huden-bg-sidebar, #020617) !important;
    border-color: var(--huden-border, #1e293b) !important;
}

html[data-huden-theme] .card-vcc,
html[data-huden-theme] .btn-action-card {
    background: var(--huden-bg-card, linear-gradient(145deg, #0f172a, #020617)) !important;
    border-color: var(--huden-border, #1e293b) !important;
    color: var(--huden-text, #e5e7eb) !important;
}

html[data-huden-theme] .btn-action-card:hover,
html[data-huden-theme] .card-vcc:hover {
    border-color: color-mix(in srgb, var(--huden-accent, #38bdf8) 35%, transparent) !important;
}

html[data-huden-theme] body.login-page-body .container {
    background: var(--huden-bg-login-box, rgba(2, 6, 23, 0.96)) !important;
    border: 1px solid var(--huden-border, rgba(148, 163, 184, 0.14));
    color: var(--huden-text, #e5e7eb);
}

html[data-huden-theme] body.login-page-body .actions a:not(.logout) {
    background: var(--huden-accent, #2563eb) !important;
    color: var(--huden-btn-primary-text, #fff) !important;
}

html[data-huden-theme] body.login-page-body h1 {
    color: var(--huden-heading, var(--huden-text, #f8fafc));
}

html[data-huden-theme] body.login-page-body .email,
html[data-huden-theme] body.login-page-body .role {
    color: var(--huden-text-muted, #94a3b8);
}

html[data-huden-theme] .header-card.card-header-vcc,
html[data-huden-theme] .card-header-vcc.header-card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #111827 !important;
}

html[data-huden-theme] .header-card.card-header-vcc h1,
html[data-huden-theme] .header-card.card-header-vcc h2,
html[data-huden-theme] .header-card.card-header-vcc h3,
html[data-huden-theme] .header-card.card-header-vcc h4,
html[data-huden-theme] .header-card.card-header-vcc h5,
html[data-huden-theme] .header-card.card-header-vcc h6,
html[data-huden-theme] .header-card.card-header-vcc .fm-header-title {
    color: #111827 !important;
}

html[data-huden-theme] .header-card.card-header-vcc .text-secondary,
html[data-huden-theme] .header-card.card-header-vcc small {
    color: #64748b !important;
}

html[data-huden-theme] .card-header-vcc:not(.header-card) {
    background: var(--huden-bg-surface-alt, linear-gradient(145deg, #020617, #0f172a)) !important;
    border-color: var(--huden-border, #1e293b) !important;
    color: var(--huden-text, #e5e7eb) !important;
}

html[data-huden-theme] .form-control,
html[data-huden-theme] .form-select,
html[data-huden-theme] textarea.form-control {
    background-color: var(--huden-bg-input, #1e293b) !important;
    border-color: var(--huden-border, #334155) !important;
    color: var(--huden-text, #f8fafc) !important;
}

html[data-huden-theme] .form-control:focus,
html[data-huden-theme] .form-select:focus {
    border-color: var(--huden-accent, #64748b) !important;
    box-shadow: 0 0 0 0.15rem var(--huden-accent-ring, rgba(56, 189, 248, 0.15)) !important;
}

html[data-huden-theme] .activo-suggestions {
    background: var(--huden-bg-surface, #1e293b) !important;
    border-color: var(--huden-border, #475569) !important;
}

html[data-huden-theme] .activo-suggestions button {
    color: var(--huden-text, #e2e8f0) !important;
}

html[data-huden-theme] .activo-suggestions button:hover,
html[data-huden-theme] .activo-suggestions button.active {
    background: var(--huden-accent-soft, #334155) !important;
    color: var(--huden-text-inverse, #fff) !important;
}

html[data-huden-theme] .drop-zone {
    background: color-mix(in srgb, var(--huden-bg-input, #0f172a) 60%, transparent) !important;
    border-color: var(--huden-border, #475569) !important;
}

html[data-huden-theme] .drop-zone.dragover {
    border-color: var(--huden-accent, #38bdf8) !important;
    background: var(--huden-accent-soft, rgba(56, 189, 248, 0.08)) !important;
}

html[data-huden-theme] .sidebar .nav-link:hover,
html[data-huden-theme] .nav-link:hover {
    background: var(--huden-sidebar-link-active-bg, rgba(255, 255, 255, 0.05)) !important;
    color: var(--huden-sidebar-link-active, #fff) !important;
}

html[data-huden-theme] h1.text-white,
html[data-huden-theme] h2.text-white,
html[data-huden-theme] h3.text-white,
html[data-huden-theme] h4.text-white,
html[data-huden-theme] h5.text-white {
    color: var(--huden-heading, var(--huden-text-inverse, #fff)) !important;
}

/* Formulación Magistral — cabeceros de formulario: título negro sobre fondo claro */
html[data-huden-theme] .header-card.card-header-vcc h1,
html[data-huden-theme] .header-card.card-header-vcc h2,
html[data-huden-theme] .header-card.card-header-vcc h3,
html[data-huden-theme] .header-card.card-header-vcc h4,
html[data-huden-theme] .header-card.card-header-vcc h5,
html[data-huden-theme] .header-card.card-header-vcc h6,
html[data-huden-theme] .header-card.card-header-vcc .fm-header-title,
html[data-huden-theme] .header-card.card-header-vcc h1.text-white,
html[data-huden-theme] .header-card.card-header-vcc h2.text-white,
html[data-huden-theme] .header-card.card-header-vcc h3.text-white,
html[data-huden-theme] .header-card.card-header-vcc h4.text-white,
html[data-huden-theme] .header-card.card-header-vcc h5.text-white {
    color: #111827 !important;
}

html[data-huden-theme] .btn-return {
    border-color: var(--huden-border, #64748b) !important;
    color: var(--huden-text-muted, #94a3b8) !important;
}

html[data-huden-theme] .btn-return:hover {
    background: var(--huden-accent-soft, #1e293b) !important;
    color: var(--huden-text-inverse, #fff) !important;
}

/* Formulación Magistral — paneles de formulario (tema Huden: texto oscuro sobre fondo claro) */
html[data-huden-theme] .card-vcc.fm-form-panel {
    background: var(--huden-bg-card, #ffffff) !important;
    border-color: var(--huden-border, #e2e8f0) !important;
    color: var(--huden-text, #1e293b) !important;
}

html[data-huden-theme] .card-vcc.fm-form-panel .form-control,
html[data-huden-theme] .card-vcc.fm-form-panel .form-select,
html[data-huden-theme] .card-vcc.fm-form-panel textarea.form-control {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #111827 !important;
}

html[data-huden-theme] .card-vcc.fm-form-panel .form-control:focus,
html[data-huden-theme] .card-vcc.fm-form-panel .form-select:focus,
html[data-huden-theme] .card-vcc.fm-form-panel textarea.form-control:focus {
    background-color: #ffffff !important;
    color: #111827 !important;
    border-color: var(--huden-accent, #0f766e) !important;
}

html[data-huden-theme] .card-vcc.fm-form-panel .form-control::placeholder {
    color: #94a3b8 !important;
}

html[data-huden-theme] .card-vcc.fm-form-panel .fm-form-label,
html[data-huden-theme] .card-vcc.fm-form-panel .form-label,
html[data-huden-theme] .card-vcc.fm-form-panel .form-check-label,
html[data-huden-theme] .card-vcc.fm-form-panel label,
html[data-huden-theme] .card-vcc.fm-form-panel p,
html[data-huden-theme] .card-vcc.fm-form-panel strong,
html[data-huden-theme] .card-vcc.fm-form-panel h6,
html[data-huden-theme] .card-vcc.fm-form-panel .text-light,
html[data-huden-theme] .card-vcc.fm-form-panel .text-white {
    color: var(--huden-heading, var(--huden-text, #111827)) !important;
}

html[data-huden-theme] .card-vcc.fm-form-panel h5.text-info,
html[data-huden-theme] .card-vcc.fm-form-panel h5.fm-section-title {
    color: #0f766e !important;
}

html[data-huden-theme] .card-vcc.fm-form-panel .text-secondary {
    color: var(--huden-text-muted, #64748b) !important;
}

html[data-huden-theme] .card-vcc.fm-form-panel .fm-info-box {
    background: var(--huden-bg-surface-alt, #f8fafc) !important;
    border-color: var(--huden-border, #e2e8f0) !important;
    color: var(--huden-text, #1e293b) !important;
}

html[data-huden-theme] .card-vcc.fm-form-panel .medico-ente-block {
    background: var(--huden-bg-surface-alt, #f8fafc);
    border-color: var(--huden-border, #e2e8f0) !important;
}

html[data-huden-theme] .card-vcc.fm-form-panel .drop-zone {
    background: var(--huden-bg-input, #f8fafc) !important;
    border-color: var(--huden-border, #cbd5e1) !important;
}

html[data-huden-theme="huden-brand"] .card-vcc.fm-form-panel .btn-warning.text-dark {
    color: #ffffff !important;
}
