/* BiblioUPEA — correcciones de modo claro para utilidades Tailwind dark-first */

html:not(.dark) {
    color-scheme: light;
}

html:not(.dark) .page-title {
    color: #0f172a !important;
}

/* Texto claro solo donde el fondo lo exige */
html:not(.dark) .bg-\[\#2563EB\].text-white,
html:not(.dark) .bg-\[\#2563EB\] .text-white,
html:not(.dark) .bg-blue-600.text-white,
html:not(.dark) .bg-blue-600 .text-white,
html:not(.dark) .bg-blue-700.text-white,
html:not(.dark) .bg-blue-700 .text-white,
html:not(.dark) .bg-emerald-600.text-white,
html:not(.dark) .bg-emerald-600 .text-white,
html:not(.dark) .bg-emerald-700.text-white,
html:not(.dark) .bg-emerald-700 .text-white,
html:not(.dark) .bg-red-500.text-white,
html:not(.dark) .bg-red-500 .text-white,
html:not(.dark) .bg-red-600.text-white,
html:not(.dark) .bg-red-600 .text-white,
html:not(.dark) .bg-red-700.text-white,
html:not(.dark) .bg-red-700 .text-white,
html:not(.dark) .bg-orange-600.text-white,
html:not(.dark) .bg-orange-700.text-white,
html:not(.dark) .digital-tab.bg-\[\#2563EB\],
html:not(.dark) .digital-tab.bg-\[\#2563EB\] *,
html:not(.dark) .req-tab.bg-\[\#2563EB\],
html:not(.dark) .req-tab.bg-\[\#2563EB\] *,
html:not(.dark) .my-loans-filter-btn.bg-\[\#0F172A\],
html:not(.dark) .req-filter-btn.bg-\[\#0F172A\],
html:not(.dark) [class*="from-black"] .text-white,
html:not(.dark) [class*="bg-black"] .text-white,
html:not(.dark) .bg-black\/60 .text-white,
html:not(.dark) .bg-black\/70 .text-white {
    color: #ffffff !important;
}

/* Títulos y textos pensados para fondo oscuro */
html:not(.dark) .text-white:not(.bg-\[\#2563EB\]):not(.bg-blue-600):not(.bg-blue-700):not(.bg-emerald-600):not(.bg-emerald-700):not(.bg-red-500):not(.bg-red-600):not(.bg-red-700):not(.bg-orange-600):not(.bg-orange-700) {
    color: #0f172a !important;
}

html:not(.dark) .text-slate-200 {
    color: #334155 !important;
}

html:not(.dark) .text-slate-300 {
    color: #475569 !important;
}

html:not(.dark) .text-slate-400,
html:not(.dark) .text-slate-500 {
    color: #64748b !important;
}

/* Superficies oscuras → claras */
html:not(.dark) .bg-\[\#0F172A\],
html:not(.dark) .bg-\[\#0F172A\]\/95,
html:not(.dark) .bg-\[\#0F172A\]\/90,
html:not(.dark) .bg-slate-700,
html:not(.dark) .bg-slate-800,
html:not(.dark) .bg-slate-800\/60,
html:not(.dark) .bg-slate-800\/70,
html:not(.dark) .bg-slate-800\/80,
html:not(.dark) .bg-slate-800\/90,
html:not(.dark) .bg-slate-900,
html:not(.dark) .bg-slate-900\/60 {
    background-color: #ffffff !important;
}

html:not(.dark) .bg-slate-700.text-slate-200,
html:not(.dark) .bg-slate-700.text-slate-300 {
    background-color: #f1f5f9 !important;
}

html:not(.dark) .border-slate-700,
html:not(.dark) .border-slate-800 {
    border-color: #e2e8f0 !important;
}

/* Formularios HTMX y filtros */
html:not(.dark) input:not([type="checkbox"]):not([type="radio"]),
html:not(.dark) select,
html:not(.dark) textarea {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

html:not(.dark) input::placeholder,
html:not(.dark) textarea::placeholder {
    color: #94a3b8 !important;
}

html:not(.dark) code {
    background-color: #f1f5f9 !important;
    color: #334155 !important;
}

/* Hover en botones/tablas dark-first */
html:not(.dark) .hover\:bg-slate-700:hover,
html:not(.dark) .hover\:bg-slate-600:hover,
html:not(.dark) .hover\:bg-slate-800:hover {
    background-color: #f1f5f9 !important;
}

html:not(.dark) .hover\:bg-slate-700\/50:hover {
    background-color: #f8fafc !important;
}

html:not(.dark) .hover\:text-white:hover {
    color: #0f172a !important;
}

/* Badges y pills (roles, estados) */
html:not(.dark) .bg-emerald-900 { background-color: #d1fae5 !important; }
html:not(.dark) .text-emerald-300 { color: #047857 !important; }
html:not(.dark) .bg-amber-900 { background-color: #fef3c7 !important; }
html:not(.dark) .text-amber-300 { color: #b45309 !important; }
html:not(.dark) .bg-red-900 { background-color: #fee2e2 !important; }
html:not(.dark) .text-red-300,
html:not(.dark) .text-red-400 { color: #b91c1c !important; }
html:not(.dark) .bg-blue-900 { background-color: #dbeafe !important; }
html:not(.dark) .text-blue-300,
html:not(.dark) .text-blue-400 { color: #1d4ed8 !important; }
html:not(.dark) .bg-violet-900 { background-color: #ede9fe !important; }
html:not(.dark) .text-violet-300 { color: #6d28d9 !important; }
html:not(.dark) .bg-teal-900 { background-color: #ccfbf1 !important; }
html:not(.dark) .text-teal-300 { color: #0f766e !important; }
html:not(.dark) .bg-orange-900 { background-color: #ffedd5 !important; }
html:not(.dark) .text-orange-300 { color: #c2410c !important; }

/* Alertas N2 y formularios inline */
html:not(.dark) .bg-red-900\/10 {
    background-color: #fef2f2 !important;
}

html:not(.dark) .border-red-900\/50 {
    border-color: #fecaca !important;
}

html:not(.dark) .text-red-300.font-medium {
    color: #b91c1c !important;
}

/* Botones de acción principal */
html:not(.dark) .btn-library:not(.bg-\[\#2563EB\]) {
    background-color: #0f172a !important;
    color: #f8fafc !important;
}

html:not(.dark) .btn-library:not(.bg-\[\#2563EB\]):hover {
    background-color: #1e293b !important;
}

/* Botones secundarios claros (filtros, cancelar) */
html:not(.dark) .bg-white.text-\[\#0F172A\] {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #e2e8f0;
}

html:not(.dark) .bg-white.text-\[\#0F172A\]:hover {
    background-color: #f8fafc !important;
}

/* Paginación HTMX */
html:not(.dark) .bg-\[\#2563EB\].text-white.font-medium {
    color: #ffffff !important;
}

/* Hero del catálogo en modo claro */
html:not(.dark) .catalog-page-hero {
    background: linear-gradient(135deg, #f0f7ff 0%, #f8fafc 55%, #eef2ff 100%) !important;
    border-color: #e2e8f0 !important;
    color: #0f172a;
}

html:not(.dark) .catalog-page-hero .text-white {
    color: #0f172a !important;
}

html.dark .catalog-page-hero {
    background: linear-gradient(135deg, #0b1220 0%, #0f172a 52%, #172554 100%) !important;
    border-color: #334155 !important;
}

html.dark .catalog-hero-portada {
    filter: invert(1) hue-rotate(180deg) brightness(1.05) contrast(0.92);
}

html.dark .catalog-hero-portada-wrap {
    opacity: 0.42;
}

/* Chips de tipo en hero del catálogo — conservar colores semánticos en claro */
html:not(.dark) .catalog-type-chip.bg-blue-50 { background-color: #eff6ff !important; border-color: #bfdbfe !important; color: #1e40af !important; }
html:not(.dark) .catalog-type-chip.bg-violet-50 { background-color: #f5f3ff !important; border-color: #ddd6fe !important; color: #5b21b6 !important; }
html:not(.dark) .catalog-type-chip.bg-teal-50 { background-color: #f0fdfa !important; border-color: #99f6e4 !important; color: #0f766e !important; }
html:not(.dark) .catalog-type-chip.bg-amber-50 { background-color: #fffbeb !important; border-color: #fde68a !important; color: #b45309 !important; }
html:not(.dark) .catalog-type-chip:hover.bg-blue-100 { background-color: #dbeafe !important; }
html:not(.dark) .catalog-type-chip:hover.bg-violet-100 { background-color: #ede9fe !important; }
html:not(.dark) .catalog-type-chip:hover.bg-teal-100 { background-color: #ccfbf1 !important; }
html:not(.dark) .catalog-type-chip:hover.bg-amber-100 { background-color: #fef3c7 !important; }

/* Etiquetas Libro/Tesis en tarjetas del catálogo */
html:not(.dark) .bg-blue-50\/95 { background-color: rgb(239 246 255 / 0.95) !important; }
html:not(.dark) .bg-violet-50\/95 { background-color: rgb(245 243 255 / 0.95) !important; }
html:not(.dark) .bg-teal-50\/95 { background-color: rgb(240 253 250 / 0.95) !important; }
html:not(.dark) .bg-amber-50\/95 { background-color: rgb(255 251 235 / 0.95) !important; }
html:not(.dark) .text-blue-800 { color: #1e40af !important; }
html:not(.dark) .text-violet-800 { color: #5b21b6 !important; }
html:not(.dark) .text-teal-800 { color: #0f766e !important; }
html:not(.dark) .text-amber-800 { color: #b45309 !important; }
html:not(.dark) .text-red-700 { color: #b91c1c !important; }
html:not(.dark) .text-emerald-700 { color: #047857 !important; }
html:not(.dark) .bg-red-100 { background-color: #fee2e2 !important; }
html:not(.dark) .bg-emerald-100 { background-color: #d1fae5 !important; }
html:not(.dark) .bg-blue-100 { background-color: #dbeafe !important; }

/* Tarjetas premium en grilla (catálogo, materiales) */
html:not(.dark) .premium-card.bg-slate-800,
html:not(.dark) .premium-card.bg-slate-800\/80,
html:not(.dark) .premium-card.bg-slate-900 {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
}

html:not(.dark) .bg-slate-900\/50,
html:not(.dark) .bg-slate-900\/80 {
    background-color: #ffffff !important;
}

html:not(.dark) .text-blue-200 {
    color: #1d4ed8 !important;
}

/* Clases semánticas reutilizables */
.biblio-card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    color: #0f172a;
}

html.dark .biblio-card {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

.biblio-input {
    width: 100%;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    border-radius: 0.75rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
}

.biblio-input:focus {
    outline: none;
    border-color: #2563eb;
    background-color: #ffffff;
}

html.dark .biblio-input {
    background-color: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

html.dark .biblio-input:focus {
    background-color: #1e293b;
}

.biblio-btn-secondary {
    background-color: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
}

.biblio-btn-secondary:hover {
    background-color: #e2e8f0;
}

html.dark .biblio-btn-secondary {
    background-color: #334155;
    color: #e2e8f0;
    border-color: #475569;
}

html.dark .biblio-btn-secondary:hover {
    background-color: #475569;
}