/* ============================================================
   THEME SYSTEM — Tema oscuro + tema claro profesional
   Las variables --th-* se definen dinámicamente desde
   appearance_css() según los settings de la BD.
   Aquí solo se DECLARAN los selectores que las usan.
   ============================================================ */

html, body {
  background: var(--th-body-bg) !important;
  color: var(--th-body-text) !important;
  transition: background .35s ease, color .35s ease;
}

/* === Suaviza transición de tema en todos los elementos === */
*, *::before, *::after {
  transition: background-color .3s ease, border-color .3s ease, color .25s ease;
}

/* === Títulos === */
h1, h2, h3, h4, h5, h6,
.section-title, .hero-title, .pub-title,
.text-white {
  color: var(--th-title) !important;
}

/* === Texto muted === */
.text-muted, .section-sub, .pub-card-excerpt, .pub-subtitle, small.text-muted {
  color: var(--th-muted) !important;
}

/* === Bordes === */
.border-secondary,
.border, .border-top, .border-bottom, .border-start, .border-end {
  border-color: var(--th-border) !important;
}

/* ====================================================
   CARDS / CONTENEDORES
   ==================================================== */
.card-tech, .product-card, .pub-card, .pub-featured,
.stat-card, .mvv-card, .team-card, .portfolio-card,
.floating-card, .feat-mini, .service-pro,
.cart-summary, .checkout-card, .order-card, .cart-list,
.adm-card, .track-card, .help-card,
.art-author-card, .art-sidebar, .art-rel-card,
.search-dropdown, .pub-search-card, .pub-newsletter-card,
.pub-error, .pub-empty {
  background: var(--th-card-bg) !important;
  border-color: var(--th-card-border) !important;
}

/* ====================================================
   NAVBAR / HEADER
   ==================================================== */
.navbar.navbar-tech, nav.navbar-tech {
  background: var(--th-header-bg) !important;
  border-bottom: 1px solid var(--th-header-border) !important;
  backdrop-filter: blur(20px);
}
.navbar-tech .navbar-brand,
.navbar-tech .brand-name { color: var(--th-header-text) !important; }
.navbar-tech .nav-link { color: var(--th-header-link) !important; }
.navbar-tech .nav-link:hover,
.navbar-tech .nav-link.active { color: var(--th-header-hover) !important; }

/* Toggler responsive en light */
html[data-theme="light"] .navbar-toggler {
  border-color: var(--th-border);
}
html[data-theme="light"] .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(15, 23, 42, .75)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E");
}

/* ====================================================
   FOOTER
   ==================================================== */
footer.tech-footer {
  background: var(--th-footer-bg) !important;
  color: var(--th-footer-text) !important;
  border-top: 1px solid var(--th-border);
}
footer.tech-footer h6 { color: var(--th-footer-title) !important; }
footer.tech-footer a, footer.tech-footer p { color: var(--th-footer-link) !important; }
footer.tech-footer a:hover { color: var(--th-footer-hover) !important; }

/* ====================================================
   BOTONES
   ==================================================== */
.btn-tech, .btn-primary {
  background: linear-gradient(135deg, var(--th-btn-primary-bg), var(--th-btn-secondary-bg)) !important;
  color: var(--th-btn-primary-text) !important;
  border: none !important;
}
.btn-tech:hover, .btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.btn-tech-secondary { background: var(--th-btn-secondary-bg) !important; color: var(--th-btn-secondary-text) !important; }
.btn-tech-accent    { background: var(--th-btn-accent-bg) !important;    color: var(--th-btn-accent-text) !important; }

.btn-ghost, .btn-outline-secondary {
  background: transparent !important;
  border: 1px solid var(--th-btn-ghost-bd) !important;
  color: var(--th-btn-ghost-text) !important;
}
.btn-ghost:hover, .btn-outline-secondary:hover {
  background: var(--th-btn-ghost-bd) !important;
}

.adm-btn {
  background: linear-gradient(135deg, var(--th-btn-primary-bg), var(--th-btn-secondary-bg)) !important;
  color: var(--th-btn-primary-text) !important;
}
.adm-btn-ghost {
  background: transparent !important;
  border: 1px solid var(--th-btn-ghost-bd) !important;
  color: var(--th-btn-ghost-text) !important;
}

/* ====================================================
   INPUTS / FORMULARIOS
   ==================================================== */
.form-control, .form-select,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="url"],
input[type="tel"], textarea, select {
  background-color: var(--th-input-bg) !important;
  color: var(--th-input-text) !important;
  border-color: var(--th-input-border) !important;
}
.form-control:focus, .form-select:focus, textarea:focus, input:focus {
  background-color: var(--th-input-bg) !important;
  color: var(--th-input-text) !important;
  border-color: var(--th-btn-primary-bg) !important;
  box-shadow: 0 0 0 .2rem color-mix(in oklab, var(--th-btn-primary-bg) 25%, transparent) !important;
}
.form-control::placeholder, .form-select::placeholder,
input::placeholder, textarea::placeholder {
  color: var(--th-input-placeholder) !important;
  opacity: 1;
}
.form-label { color: var(--th-body-text) !important; }
.input-group .btn-outline-secondary {
  background: var(--th-input-bg) !important;
  color: var(--th-input-text) !important;
  border-color: var(--th-input-border) !important;
}

/* ====================================================
   ESPECÍFICOS LIGHT MODE — Arreglos puntuales
   ==================================================== */
html[data-theme="light"] body {
  background:
    radial-gradient(900px circle at 10% 5%,  rgba(10,132,255,.06), transparent 55%),
    radial-gradient(800px circle at 90% 30%, rgba(94,92,230,.05), transparent 55%),
    var(--th-body-bg) !important;
}

/* Cards con sombra suave en light */
html[data-theme="light"] .card-tech,
html[data-theme="light"] .product-card,
html[data-theme="light"] .pub-card,
html[data-theme="light"] .pub-featured,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .mvv-card,
html[data-theme="light"] .team-card,
html[data-theme="light"] .portfolio-card,
html[data-theme="light"] .feat-mini,
html[data-theme="light"] .service-pro,
html[data-theme="light"] .adm-card,
html[data-theme="light"] .track-card,
html[data-theme="light"] .art-author-card,
html[data-theme="light"] .art-sidebar,
html[data-theme="light"] .art-rel-card {
  box-shadow: 0 4px 18px rgba(15,23,42,.06);
}

html[data-theme="light"] .card-tech:hover,
html[data-theme="light"] .product-card:hover,
html[data-theme="light"] .pub-card:hover {
  box-shadow: 0 16px 40px rgba(15,23,42,.12);
  border-color: var(--th-btn-primary-bg) !important;
}

/* Floating cards (Nosotros) → bordes y backdrop ajustados */
html[data-theme="light"] .floating-card {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 12px 32px rgba(15,23,42,.08);
}
html[data-theme="light"] .floating-card i {
  background: linear-gradient(135deg, var(--th-btn-primary-bg), var(--th-btn-secondary-bg)) !important;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Hero (publicaciones) → ajustar tinta */
html[data-theme="light"] .pub-eyebrow {
  background: #ffffff !important;
  color: var(--th-title) !important;
  border-color: var(--th-border) !important;
  box-shadow: 0 2px 8px rgba(15,23,42,.04);
}
html[data-theme="light"] .pub-title-hero,
html[data-theme="light"] .art-title {
  color: var(--th-title) !important;
}
html[data-theme="light"] .pub-subtitle-hero,
html[data-theme="light"] .art-subtitle {
  color: var(--th-muted) !important;
}

/* Filtros chips */
html[data-theme="light"] .pub-chip {
  background: #ffffff !important;
  border-color: var(--th-border) !important;
  color: #475569 !important;
}
html[data-theme="light"] .pub-chip:hover {
  background: #f1f5f9 !important;
  color: var(--th-title) !important;
}
html[data-theme="light"] .pub-chip-count {
  background: #f1f5f9 !important;
  color: #475569 !important;
}
html[data-theme="light"] .pub-chip.active .pub-chip-count {
  background: rgba(0,0,0,.18) !important;
  color: #fff !important;
}

/* Filtros section sticky */
html[data-theme="light"] .pub-filters-section {
  background: rgba(244,246,251,.88) !important;
  border-bottom-color: var(--th-border) !important;
}

/* Hero sections con fondos radiales más sutiles */
html[data-theme="light"] .pub-hero-bg {
  background:
    radial-gradient(900px circle at 12% 25%, rgba(10,132,255,.08), transparent 55%),
    radial-gradient(700px circle at 88% 75%, rgba(94,92,230,.05), transparent 55%) !important;
}
html[data-theme="light"] .nosotros-hero {
  background:
    radial-gradient(600px circle at 15% 50%, rgba(10,132,255,.06), transparent),
    radial-gradient(500px circle at 85% 50%, rgba(94,92,230,.04), transparent) !important;
}

/* Texto blanco en light se vuelve oscuro */
html[data-theme="light"] [style*="color:#fff"],
html[data-theme="light"] [style*="color: #fff"],
html[data-theme="light"] [style*="color:white"],
html[data-theme="light"] .text-light {
  color: var(--th-title) !important;
}

/* Botones secundarios (hero) en light */
html[data-theme="light"] .badge {
  background: #f1f5f9 !important;
  color: var(--th-title) !important;
  border-color: var(--th-border) !important;
}

/* Estado/badges en light */
html[data-theme="light"] .estado {
  background: #f1f5f9 !important;
  color: var(--th-title) !important;
}
html[data-theme="light"] .estado.pagado { background: #d1fae5 !important; color: #065f46 !important; }
html[data-theme="light"] .estado.pendiente { background: #fef3c7 !important; color: #92400e !important; }
html[data-theme="light"] .estado.cancelado, html[data-theme="light"] .estado.rechazado { background: #fee2e2 !important; color: #991b1b !important; }

/* Tablas en light */
html[data-theme="light"] table, html[data-theme="light"] .adm-table,
html[data-theme="light"] .track-table {
  color: var(--th-body-text) !important;
}
html[data-theme="light"] .adm-table thead th,
html[data-theme="light"] table thead th {
  background: #f8fafc !important;
  color: var(--th-title) !important;
  border-bottom: 1px solid var(--th-border) !important;
}
html[data-theme="light"] .adm-table tbody td,
html[data-theme="light"] table tbody td {
  border-color: var(--th-border) !important;
}

/* Loader inicial en light */
html[data-theme="light"] .page-loader {
  background: var(--th-body-bg) !important;
}
html[data-theme="light"] .page-loader-spin {
  border-color: rgba(15,23,42,.1);
  border-top-color: var(--th-btn-primary-bg);
}

/* Search dropdown */
html[data-theme="light"] .search-dropdown {
  background: #ffffff !important;
  border-color: var(--th-border) !important;
  box-shadow: 0 20px 60px rgba(15,23,42,.15);
}
html[data-theme="light"] .search-dropdown a {
  color: var(--th-body-text) !important;
  border-bottom-color: var(--th-border) !important;
}
html[data-theme="light"] .search-dropdown a:hover {
  background: #f8fafc !important;
}
html[data-theme="light"] .search-dropdown .sd-title { color: var(--th-title) !important; }

/* User menu dropdown */
html[data-theme="light"] .user-menu-dropdown .user-menu {
  background: #ffffff !important;
  border-color: var(--th-border) !important;
  box-shadow: 0 20px 60px rgba(15,23,42,.15);
}
html[data-theme="light"] .user-menu-dropdown .user-menu .dropdown-item div {
  color: var(--th-title) !important;
}
html[data-theme="light"] .user-menu-dropdown .user-menu .dropdown-divider {
  border-color: var(--th-border) !important;
}

/* Detalle de producto SKU box */
html[data-theme="light"] .sku-stock-row {
  background: #ffffff !important;
  border-color: var(--th-border) !important;
}
html[data-theme="light"] .ss-item strong { color: var(--th-title) !important; }

/* Carrusel marcas/clientes mask */
html[data-theme="light"] .marcas-marquee,
html[data-theme="light"] .clients-marquee {
  background: linear-gradient(180deg, #f8fafc, #ffffff) !important;
  border-top: 1px solid var(--th-border) !important;
  border-bottom: 1px solid var(--th-border) !important;
}

/* Pestañas (admin mensajes) */
html[data-theme="light"] .nav-tabs {
  border-bottom-color: var(--th-border) !important;
}
html[data-theme="light"] .nav-tabs .nav-link {
  color: #64748b !important;
  background: transparent !important;
  border-color: transparent !important;
}
html[data-theme="light"] .nav-tabs .nav-link.active {
  color: var(--th-btn-primary-bg) !important;
  background: #ffffff !important;
  border-color: var(--th-border) var(--th-border) #ffffff !important;
}

/* Section pills (apariencia) */
html[data-theme="light"] .section-pills .nav-link {
  background: #ffffff !important;
  color: #64748b !important;
  border-color: var(--th-border) !important;
}
html[data-theme="light"] .section-pills .nav-link:hover {
  background: #f1f5f9 !important;
  color: var(--th-title) !important;
}

/* SweetAlert popup */
html[data-theme="light"] .swal2-popup {
  background: #ffffff !important;
  color: var(--th-title) !important;
}

/* Timeline / seguimiento */
/* ====================================================
   FIX TEMA CLARO — TEXTOS Y CONTENEDORES (asegurar contraste)
   ==================================================== */
html[data-theme='light'] .text-light,
html[data-theme='light'] .text-white {
  color: #0f172a !important;
}
html[data-theme='light'] p,
html[data-theme='light'] li {
  color: #1f2937;
}
html[data-theme='light'] .lead,
html[data-theme='light'] .text-muted-small,
html[data-theme='light'] small {
  color: #475569 !important;
}

/* HERO / banners con fondos de imagen — mantener blanco sobre la imagen */
html[data-theme='light'] .hero-slide-content h1,
html[data-theme='light'] .hero-slide-content p,
html[data-theme='light'] .hero-title,
html[data-theme='light'] .hero-sub,
html[data-theme='light'] .hero-eyebrow {
  color: #ffffff !important;
}

/* Eyebrows que están sobre imágenes/gradientes oscuros */
html[data-theme='light'] .pub-eyebrow,
html[data-theme='light'] .art-tipo,
html[data-theme='light'] .srv-badge {
  color: #ffffff !important;
}

/* Asegurar que los hr o líneas de separación sean visibles */
html[data-theme='light'] hr,
html[data-theme='light'] hr.border-secondary {
  border-color: #e2e8f0 !important;
}

/* Inputs y placeholders */
html[data-theme='light'] .form-control,
html[data-theme='light'] .form-select {
  color: #0f172a !important;
}
html[data-theme='light'] .form-control::placeholder {
  color: #94a3b2 !important; opacity: 1;
}

/* Footer en modo claro: contenido legible */
html[data-theme='light'] footer.tech-footer p,
html[data-theme='light'] footer.tech-footer .small,
html[data-theme='light'] footer.tech-footer small {
  color: #64748b !important;
}
html[data-theme='light'] footer.tech-footer .copy {
  color: #94a3b2 !important;
  border-top: 1px solid #e2e8f0;
  padding-top: 16px; margin-top: 24px;
}

/* Sidebar/panel del cliente */
html[data-theme='light'] .cli-card,
html[data-theme='light'] .cli-stat,
html[data-theme='light'] .cli-quick {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 4px 14px rgba(15,23,42,.06);
}
html[data-theme='light'] .cli-card h5,
html[data-theme='light'] .cli-card-head h5,
html[data-theme='light'] .cli-stat strong,
html[data-theme='light'] .cli-quick strong {
  color: #0f172a !important;
}
html[data-theme='light'] .cli-empty,
html[data-theme='light'] .cli-stat small,
html[data-theme='light'] .cli-quick small {
  color: #64748b !important;
}

/* Carrito y checkout */
html[data-theme='light'] .cart-summary,
html[data-theme='light'] .checkout-card,
html[data-theme='light'] .order-card {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
}

/* Mvv card, team card text */
html[data-theme='light'] .mvv-card p,
html[data-theme='light'] .mvv-card li,
html[data-theme='light'] .team-card .team-bio,
html[data-theme='light'] .team-card .team-role {
  color: #475569 !important;
}

/* Stat cards */
html[data-theme='light'] .stat-card .stat-label {
  color: #64748b !important;
}

/* Filtros / tabs */
html[data-theme='light'] .pub-filters-section {
  background: rgba(255,255,255,.95) !important;
}
html[data-theme='light'] .nav-link {
  color: #475569;
}

/* WhatsApp widget: NO tocar (siempre verde) */

/* Loader inicial: en light también */
html[data-theme='light'] .page-loader { background: #f4f6fb !important; }

/* Containers de admin (si visualiza el modo claro) */
html[data-theme='light'] .adm-card h5,
html[data-theme='light'] .adm-card h6,
html[data-theme='light'] .adm-card strong {
  color: #0f172a !important;
}
html[data-theme='light'] .form-label { color: #0f172a !important; }

html[data-theme="light"] .timeline-line { background: #e2e8f0 !important; }
html[data-theme="light"] .t-circle {
  background: #f1f5f9 !important;
  border-color: var(--th-border) !important;
  color: #94a3b2 !important;
}
html[data-theme="light"] .t-label { color: #64748b !important; }
html[data-theme="light"] .t-step.done .t-label { color: var(--th-title) !important; }

/* Track-table totales */
html[data-theme="light"] .track-table .total-row td {
  border-color: var(--th-border) !important;
}
html[data-theme="light"] .prod-row {
  background: #ffffff !important;
  border-color: var(--th-border) !important;
}

/* Admin sidebar */
html[data-theme="light"] .adm-sidebar {
  background: #ffffff !important;
  border-right: 1px solid var(--th-border) !important;
}
html[data-theme="light"] .adm-sidebar .menu a {
  color: #475569 !important;
}
html[data-theme="light"] .adm-sidebar .menu a:hover,
html[data-theme="light"] .adm-sidebar .menu a.active {
  background: #f1f5f9 !important;
  color: var(--th-btn-primary-bg) !important;
}
html[data-theme="light"] .adm-sidebar .section {
  color: #94a3b2 !important;
}
html[data-theme="light"] .adm-topbar h1 { color: var(--th-title) !important; }

/* Hero swiper texto (queda blanco siempre porque está sobre imagen) */
.hero-slide-content h1, .hero-slide-content p { color: #fff !important; }

/* ====================================================
   BOTÓN FLOTANTE TOGGLE
   ==================================================== */
.theme-toggle {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 9990;
  box-shadow: 0 8px 26px rgba(10,132,255,.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .25s ease, box-shadow .25s ease, filter .25s ease;
  overflow: hidden;
}
.theme-toggle:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 14px 38px rgba(10,132,255,.6);
}
.theme-toggle .icon-wrap {
  position: relative; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
}
.theme-toggle .icon-sun, .theme-toggle .icon-moon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform .45s cubic-bezier(.5,1.6,.4,1), opacity .35s ease;
}
html[data-theme="dark"]  .theme-toggle .icon-sun  { transform: rotate(180deg) scale(0); opacity: 0; }
html[data-theme="dark"]  .theme-toggle .icon-moon { transform: rotate(0)      scale(1); opacity: 1; }
html[data-theme="light"] .theme-toggle .icon-sun  { transform: rotate(0)      scale(1); opacity: 1; }
html[data-theme="light"] .theme-toggle .icon-moon { transform: rotate(-180deg) scale(0); opacity: 0; }

html[data-theme="light"] .theme-toggle {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  box-shadow: 0 8px 26px rgba(245,158,11,.5);
}

.theme-toggle-tooltip {
  position: fixed;
  bottom: 90px; right: 24px;
  background: rgba(17,23,42,.95);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: .78rem;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  transform: translateY(6px);
  white-space: nowrap;
  z-index: 9989;
}
.theme-toggle:hover ~ .theme-toggle-tooltip { opacity: 1; transform: translateY(0); }

@media (max-width: 576px) {
  .theme-toggle { width: 50px; height: 50px; bottom: 16px; right: 16px; }
  .theme-toggle-tooltip { display: none; }
}

html.no-transition, html.no-transition * { transition: none !important; }
