/**
 * RMPowerTech - Sistema Integral de Temas (Dual Theme: Light / Dark)
 * Diseñado para garantizar contraste perfecto (WCAG AAA) en ambos modos.
 * Versión: 3.5.0
 */

/* =========================================================
   1. DEFINICIÓN DE TOKENS Y VARIABLES DE COLOR
   ========================================================= */

/* TEMA CLARO (Default / Light Agency SaaS) */
:root,
html[data-theme="light"] {
    --theme-mode: light;

    /* Superficies y Fondos */
    --bg-body: #faf8ff;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --bg-section-alt: #f3eefc;
    --bg-section-light: #ffffff;
    --bg-hero: #0f172a; /* Hero siempre con video / oscuro */

    /* Bordes y Líneas */
    --border-color: #e2e8f0;
    --border-card: rgba(226, 232, 240, 0.85);
    --border-hover: rgba(124, 58, 237, 0.35);

    /* Textos y Tipografía */
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-heading: #0f172a;
    --text-title: #180d2e;
    --text-body: #334155;
    --text-muted: #64748b;
    --text-on-dark: #ffffff;

    /* Navegación y Header */
    --nav-bg: rgba(255, 255, 255, 0.95);
    --nav-border: rgba(226, 232, 240, 0.85);
    --nav-link: #1e293b;
    --nav-link-hover: #7c3aed;
    --nav-link-active-bg: rgba(124, 58, 237, 0.1);

    /* Menú Desplegable (Dropdown) */
    --dropdown-bg: #ffffff;
    --dropdown-border: #e2e8f0;
    --dropdown-title: #0f172a;
    --dropdown-sub: #64748b;
    --dropdown-hover: #f5f3ff;
    --dropdown-shadow: 0 20px 45px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(0, 0, 0, 0.04);

    /* Tarjetas y Sombras */
    --card-shadow: 0 10px 30px -5px rgba(124, 58, 237, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
    --card-hover-shadow: 0 22px 40px -8px rgba(124, 58, 237, 0.18), 0 8px 16px -4px rgba(0, 0, 0, 0.05);

    /* Inputs, Selects y Formularios */
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --input-text: #0f172a;
    --input-placeholder: #94a3b8;
    --input-focus-border: #7c3aed;

    /* Botón Toggle de Tema */
    --theme-toggle-bg: #f1f5f9;
    --theme-toggle-border: #e2e8f0;
    --theme-toggle-color: #f59e0b;
    --theme-toggle-hover: #ede9fe;

    /* Píldora de Idioma */
    --lang-pill-bg: #f1f5f9;
    --lang-pill-border: #e2e8f0;
    --lang-pill-text: #64748b;
}

/* TEMA OSCURO (Estilo SynergyPower - Clean Zinc / Slate Dark) */
html[data-theme="dark"] {
    --theme-mode: dark;

    /* Superficies y Fondos */
    --bg-body: #09090b;        /* Zinc 950 */
    --bg-surface: #18181b;     /* Zinc 900 */
    --bg-card: #18181b;        /* Zinc 900 */
    --bg-card-hover: #27272a;  /* Zinc 800 */
    --bg-section-alt: #121215;
    --bg-section-light: #09090b;
    --bg-hero: #09090b;

    /* Bordes y Líneas */
    --border-color: rgba(255, 255, 255, 0.12);
    --border-card: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(6, 182, 212, 0.4);

    /* Textos y Tipografía */
    --text-primary: #fafafa;   /* Zinc 50 */
    --text-secondary: #d4d4d8; /* Zinc 300 */
    --text-heading: #ffffff;
    --text-title: #ffffff;
    --text-body: #d4d4d8;
    --text-muted: #a1a1aa;     /* Zinc 400 */
    --text-on-dark: #ffffff;

    /* Navegación y Header */
    --nav-bg: rgba(9, 9, 11, 0.95);
    --nav-border: rgba(255, 255, 255, 0.1);
    --nav-link: #f4f4f5;
    --nav-link-hover: #38bdf8;
    --nav-link-active-bg: rgba(56, 189, 248, 0.12);

    /* Menú Desplegable (Dropdown) */
    --dropdown-bg: #18181b;
    --dropdown-border: rgba(255, 255, 255, 0.15);
    --dropdown-title: #ffffff;
    --dropdown-sub: #a1a1aa;
    --dropdown-hover: rgba(56, 189, 248, 0.12);
    --dropdown-shadow: 0 20px 45px rgba(0, 0, 0, 0.7);

    /* Tarjetas y Sombras */
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 1px rgba(255, 255, 255, 0.1);
    --card-hover-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);

    /* Inputs, Selects y Formularios */
    --input-bg: #18181b;
    --input-border: #3f3f46;
    --input-text: #fafafa;
    --input-placeholder: #71717a;
    --input-focus-border: #38bdf8;

    /* Botón Toggle de Tema */
    --theme-toggle-bg: #27272a;
    --theme-toggle-border: rgba(255, 255, 255, 0.18);
    --theme-toggle-color: #38bdf8;
    --theme-toggle-hover: #3f3f46;

    /* Píldora de Idioma */
    --lang-pill-bg: #27272a;
    --lang-pill-border: rgba(255, 255, 255, 0.15);
    --lang-pill-text: #d4d4d8;
}

/* =========================================================
   2. REGLAS GLOBALES VINCULADAS AL TEMA
   ========================================================= */

body {
    background-color: var(--bg-body) !important;
    color: var(--text-body) !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header principal */
.header-main-white {
    background: var(--nav-bg) !important;
    border-bottom: 1px solid var(--nav-border) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.header-main-white .nav-link {
    color: var(--nav-link) !important;
}

.header-main-white .nav-link:hover,
.header-main-white .nav-link.active {
    color: var(--nav-link-hover) !important;
    background: var(--nav-link-active-bg) !important;
}

/* Dropdown */
.dropdown-menu,
.nav-dropdown .dropdown-menu {
    background: var(--dropdown-bg) !important;
    border: 1px solid var(--dropdown-border) !important;
    box-shadow: var(--dropdown-shadow) !important;
    transition: background 0.25s ease, border-color 0.25s ease;
}

.dropdown-menu .dropdown-item,
.nav-dropdown .dropdown-menu .dropdown-item,
.dropdown-item {
    color: var(--dropdown-title) !important;
}

.dropdown-menu .dropdown-item strong,
.nav-dropdown .dropdown-menu .dropdown-item strong,
.dropdown-item strong {
    color: var(--dropdown-title) !important;
}

.dropdown-menu .dropdown-item small,
.nav-dropdown .dropdown-menu .dropdown-item small,
.dropdown-item small {
    color: var(--dropdown-sub) !important;
}

.dropdown-menu .dropdown-item:hover,
.nav-dropdown .dropdown-menu .dropdown-item:hover,
.dropdown-item:hover {
    background: var(--dropdown-hover) !important;
}

.dropdown-menu .dropdown-item:hover strong,
.nav-dropdown .dropdown-menu .dropdown-item:hover strong,
.dropdown-item:hover strong {
    color: var(--nav-link-hover) !important;
}

.dropdown-menu .dropdown-item:hover small,
.nav-dropdown .dropdown-menu .dropdown-item:hover small,
.dropdown-item:hover small {
    color: var(--nav-link-hover) !important;
}

/* Tarjetas */
.card,
.tool-card,
.product-card,
.service-card,
.qr-config-panel,
.qr-preview-panel,
.tool-workspace-card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-card) !important;
    box-shadow: var(--card-shadow) !important;
    color: var(--text-body) !important;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.card:hover,
.tool-card:hover,
.product-card:hover,
.service-card:hover {
    box-shadow: var(--card-hover-shadow) !important;
    border-color: var(--border-hover) !important;
}

.card h2,
.card h3,
.card h4,
.tool-card h3,
.product-title,
.panel-title {
    color: var(--text-heading) !important;
}

.card p,
.tool-card p,
.product-card p {
    color: var(--text-body) !important;
}

/* Secciones */
section.section {
    background: transparent !important;
    color: var(--text-body) !important;
}

section.section:nth-of-type(even) {
    background: var(--bg-section-alt) !important;
}

.section-title {
    color: var(--text-heading) !important;
}

.section-subtitle {
    color: var(--text-muted) !important;
}

/* Botón Outline */
.btn-outline {
    background: transparent !important;
    color: var(--text-heading) !important;
    border-color: var(--border-color) !important;
}

.btn-outline:hover {
    background: var(--dropdown-hover) !important;
    color: var(--nav-link-hover) !important;
    border-color: #7c3aed !important;
}

/* Inputs y Formularios */
.form-control,
.form-select,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
textarea,
select {
    background-color: var(--input-bg) !important;
    border: 1.5px solid var(--input-border) !important;
    color: var(--input-text) !important;
}

.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
    border-color: var(--input-focus-border) !important;
    outline: none !important;
}

.form-label {
    color: var(--text-heading) !important;
}

/* Píldora selector de idiomas */
.lang-switch-group {
    background: var(--lang-pill-bg) !important;
    border-color: var(--lang-pill-border) !important;
}

/* =========================================================
   3. BOTÓN TOGGLE DE TEMA (SOL / LUNA)
   ========================================================= */

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--theme-toggle-bg);
    border: 1.5px solid var(--theme-toggle-border);
    color: var(--theme-toggle-color);
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    padding: 0;
}

.theme-toggle-btn:hover {
    transform: rotate(15deg) scale(1.08);
    background: var(--theme-toggle-hover);
}

.theme-toggle-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

/* Mostrar icono Sol en modo oscuro y Luna en modo claro */
html[data-theme="light"] .theme-icon-sun {
    display: none;
}
html[data-theme="light"] .theme-icon-moon {
    display: block;
}

html[data-theme="dark"] .theme-icon-sun {
    display: block;
}
html[data-theme="dark"] .theme-icon-moon {
    display: none;
}

/* =========================================================
   4. CONTROL DEL LOGO SEGÚN TEMA
   ========================================================= */

html[data-theme="light"] .theme-logo-light {
    display: block !important;
}
html[data-theme="light"] .theme-logo-dark {
    display: none !important;
}

html[data-theme="dark"] .theme-logo-light {
    display: none !important;
}
html[data-theme="dark"] .theme-logo-dark {
    display: block !important;
}

/* =========================================================
   5. AJUSTES ESPECÍFICOS DE MODO OSCURO
   ========================================================= */

html[data-theme="dark"] .hero-title,
html[data-theme="dark"] .hero-subtitle {
    color: #ffffff !important;
}

html[data-theme="dark"] .qr-type-tabs {
    background: #0d1322 !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
}

html[data-theme="dark"] .tab-btn {
    background: #151d30 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .tab-btn:hover {
    background: #1e293b !important;
    border-color: #a78bfa !important;
    color: #a78bfa !important;
}

html[data-theme="dark"] .tab-btn.active {
    background: linear-gradient(135deg, #7c3aed 0%, #0ea5e9 100%) !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .service-section-item {
    background: var(--bg-body) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Chatbot en Modo Oscuro */
html[data-theme="dark"] .rm-chatbot-window {
    background: #111827 !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8) !important;
}

html[data-theme="dark"] .rm-chatbot-body {
    background: #0d1322 !important;
}

html[data-theme="dark"] .rm-chat-bubble-bot {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

html[data-theme="dark"] .rm-chat-service-card {
    background: #151d30 !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}

html[data-theme="dark"] .rm-chat-service-card:hover {
    background: rgba(124, 58, 237, 0.25) !important;
}

html[data-theme="dark"] .rm-chat-input-area {
    background: #111827 !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

html[data-theme="dark"] .rm-chat-input-area input {
    background: #0d1322 !important;
    color: #f8fafc !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
}

/* Tablas en Modo Oscuro */
html[data-theme="dark"] table th {
    background: #151d30 !important;
    color: #f8fafc !important;
}

html[data-theme="dark"] table td {
    border-color: rgba(255, 255, 255, 0.08) !important;
    color: #cbd5e1 !important;
}

/* =========================================================
   6. CORRECCIONES DE CONTRASTE DE BOTONES POR TEMA
   ========================================================= */

/* LIGHT MODE: botón outline con texto violeta visible */
html[data-theme="light"] .btn-outline,
html[data-theme="light"] a.btn-outline,
html[data-theme="light"] button.btn-outline {
    background: transparent !important;
    color: #7c3aed !important;
    border-color: rgba(124, 58, 237, 0.5) !important;
}

html[data-theme="light"] .btn-outline:hover,
html[data-theme="light"] a.btn-outline:hover,
html[data-theme="light"] button.btn-outline:hover {
    background: rgba(124, 58, 237, 0.08) !important;
    color: #6d28d9 !important;
    border-color: #7c3aed !important;
}

/* DARK MODE: botón outline con texto lila claro */
html[data-theme="dark"] .btn-outline,
html[data-theme="dark"] a.btn-outline,
html[data-theme="dark"] button.btn-outline {
    background: rgba(139, 92, 246, 0.08) !important;
    color: #c4b5fd !important;
    border-color: rgba(139, 92, 246, 0.5) !important;
}

html[data-theme="dark"] .btn-outline:hover,
html[data-theme="dark"] a.btn-outline:hover,
html[data-theme="dark"] button.btn-outline:hover {
    background: rgba(124, 58, 237, 0.2) !important;
    color: #ffffff !important;
    border-color: #a78bfa !important;
}

/* Botones de acción en herramientas */
html[data-theme="light"] .download-btn,
html[data-theme="light"] .action-btn {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

html[data-theme="dark"] .download-btn,
html[data-theme="dark"] .action-btn {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: rgba(255,255,255,0.15) !important;
}

/* Botones primarios y CTA: texto SIEMPRE blanco */
.btn-primary, a.btn-primary, button.btn-primary,
.btn-gradient, .nav-cta-btn, .theme-btn,
.btn-generate, input[type="submit"].btn-primary {
    color: #ffffff !important;
}

.nav-cta-btn {
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%) !important;
    color: #ffffff !important;
}

/* DARK MODE: nav links visibles y claros */
html[data-theme="dark"] .nav-link,
html[data-theme="dark"] .header .nav-link,
html[data-theme="dark"] #mainNav .nav-link,
html[data-theme="dark"] .header-main-white .nav-link {
    color: #f1f5f9 !important;
}

html[data-theme="dark"] .nav-link:hover,
html[data-theme="dark"] .nav-link.active,
html[data-theme="dark"] .header .nav-link:hover,
html[data-theme="dark"] .header-main-white .nav-link:hover,
html[data-theme="dark"] .header-main-white .nav-link.active {
    color: #c4b5fd !important;
    background: rgba(124, 58, 237, 0.22) !important;
}

html[data-theme="dark"] .nav-link svg,
html[data-theme="dark"] .header .nav-link svg,
html[data-theme="dark"] .header-main-white .nav-link svg {
    color: #a78bfa !important;
}

/* LIGHT MODE: nav SVG icons en violeta */
html[data-theme="light"] .nav-link svg,
html[data-theme="light"] .header .nav-link svg {
    color: #7c3aed !important;
}

/* Dropdown fuerte contraste en ambos modos */
html[data-theme="light"] .dropdown-item strong,
html[data-theme="light"] .dropdown-menu .dropdown-item strong {
    color: #0f172a !important;
    font-weight: 700 !important;
}
html[data-theme="light"] .dropdown-item small,
html[data-theme="light"] .dropdown-menu .dropdown-item small {
    color: #64748b !important;
}
html[data-theme="dark"] .dropdown-item strong,
html[data-theme="dark"] .dropdown-menu .dropdown-item strong {
    color: #f8fafc !important;
    font-weight: 700 !important;
}
html[data-theme="dark"] .dropdown-item small,
html[data-theme="dark"] .dropdown-menu .dropdown-item small {
    color: #94a3b8 !important;
}

/* Footer: texto siempre visible */
footer, .footer-dark,
html[data-theme="light"] footer,
html[data-theme="light"] .footer-dark {
    background: #0f172a !important;
}

footer *, .footer-dark *,
html[data-theme="light"] footer *,
html[data-theme="light"] .footer-dark * {
    color: #e2e8f0 !important;
}

footer a, .footer-dark a,
html[data-theme="light"] footer a:not([class*="btn"]),
html[data-theme="light"] .footer-dark a:not([class*="btn"]) {
    color: #94a3b8 !important;
}

footer a:hover, .footer-dark a:hover {
    color: #c4b5fd !important;
}
