/* ==========================================================================
   APOLO · Temas (v3.0, Fase 18)
   Parte 1: cada tema define SOLO tokens. Se aplican con [data-theme="…"] tanto en <html>
   como en las miniaturas de la galería (.tp), así la vista previa es el tema real.
   Whitelabel (solo obsidian_brand): --brand, --brand-2, --brand-ink llegan en línea
   desde la base de datos (companies.ui_settings / users.ui_prefs).
   ========================================================================== */

:root {
    --brand: #3b82f6;
    --brand-2: #8b5cf6;
    --brand-ink: #ffffff;
    --radius: 8px;
    --radius-sm: 6px;
    --sbw: 248px;
    --sbw-collapsed: 64px;
    --tbh: 60px;
}

/* ───────────── 1. Obsidiana & Color de Marca (por defecto) ───────────── */
[data-theme="obsidian_brand"] {
    --bg: #0b0d12;
    --bg-2: #0f1218;
    --surface: #12151c;
    --surface-2: #171b24;
    --surface-3: #1d2230;
    --border: #232835;
    --border-strong: #2e3546;
    --text: #e8eaf0;
    --muted: #8b93a7;
    --muted-2: #626a7e;
    --accent: var(--brand);
    --accent-2: var(--brand-2);
    --accent-ink: var(--brand-ink);
    --accent-soft: color-mix(in srgb, var(--brand) 14%, transparent);
    --btn-bg: var(--brand);
    --btn-text: var(--brand-ink);
    --btn-border: var(--brand);
    --sb-bg: #090b10;
    --sb-text: #c6cbd8;
    --sb-muted: #5d6578;
    --sb-border: #1b1f2a;
    --sb-hover: rgba(255, 255, 255, .04);
    --sb-active-bg: color-mix(in srgb, var(--brand) 16%, transparent);
    --sb-active-text: #ffffff;
    --sb-active-bar: var(--brand);
    --tb-bg: rgba(11, 13, 18, .86);
    --good: #22c55e;
    --warn: #f59e0b;
    --bad: #ef4444;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: var(--font);
    --display-weight: 600;
    --shadow: 0 1px 0 rgba(255, 255, 255, .02), 0 10px 30px -18px rgba(0, 0, 0, .8);
    color-scheme: dark;
}
/* Menú teñido con el color de marca */
[data-theme="obsidian_brand"][data-sidebar="tinted"] {
    --sb-bg: linear-gradient(180deg, color-mix(in srgb, var(--brand) 34%, #0b0d12) 0%, color-mix(in srgb, var(--brand-2) 22%, #0b0d12) 100%);
    --sb-text: #f3f4f8;
    --sb-muted: color-mix(in srgb, #ffffff 55%, transparent);
    --sb-border: color-mix(in srgb, var(--brand) 30%, #0b0d12);
    --sb-hover: rgba(255, 255, 255, .07);
    --sb-active-bg: rgba(255, 255, 255, .14);
    --sb-active-bar: #ffffff;
}

/* ───────────── 2. Zafiro & Oro Imperial ───────────── */
[data-theme="sapphire_gold"] {
    --bg: #060c1a;
    --bg-2: #08112a;
    --surface: #0c1834;
    --surface-2: #10204a;
    --surface-3: #152a5c;
    --border: rgba(212, 175, 55, .18);
    --border-strong: rgba(212, 175, 55, .36);
    --text: #f4efe0;
    --muted: #a9b4cc;
    --muted-2: #74809c;
    --accent: #d4af37;
    --accent-2: #3d6fd6;
    --accent-ink: #060c1a;
    --accent-soft: rgba(212, 175, 55, .12);
    --btn-bg: linear-gradient(180deg, #e2c25a 0%, #d4af37 55%, #b8922a 100%);
    --btn-text: #060c1a;
    --btn-border: #b8922a;
    --sb-bg: linear-gradient(180deg, #08122b 0%, #050a17 100%);
    --sb-text: #dfe4f0;
    --sb-muted: #7f8ba8;
    --sb-border: rgba(212, 175, 55, .16);
    --sb-hover: rgba(212, 175, 55, .06);
    --sb-active-bg: rgba(212, 175, 55, .12);
    --sb-active-text: #f3e5ab;
    --sb-active-bar: #d4af37;
    --tb-bg: rgba(6, 12, 26, .86);
    --good: #34d399;
    --warn: #e9b949;
    --bad: #f87171;
    --font: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
    --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --display-weight: 600;
    --shadow: 0 1px 0 rgba(212, 175, 55, .05), 0 16px 40px -22px rgba(0, 0, 0, .9);
    color-scheme: dark;
}

/* ───────────── 3. Nude & Rose Gold ───────────── */
[data-theme="nude_rosegold"] {
    --bg: #f2ebe4;
    --bg-2: #ede4db;
    --surface: #fbf7f3;
    --surface-2: #f6efe8;
    --surface-3: #efe5db;
    --border: #e2d4c8;
    --border-strong: #d2bfb0;
    --text: #3d302b;
    --muted: #84726a;
    --muted-2: #a8968c;
    --accent: #b76e79;
    --accent-2: #c9a48e;
    --accent-ink: #2a1a16;
    --accent-soft: rgba(183, 110, 121, .12);
    --btn-bg: linear-gradient(180deg, #e0aaa6 0%, #cd8f92 100%);
    --btn-text: #2a1a16;   /* tinta moca: el blanco sobre oro rosa no alcanza el contraste */
    --btn-border: #b76e79;
    --sb-bg: #4a3c36;
    --sb-text: #ecdfd6;
    --sb-muted: #a48f84;
    --sb-border: #5a4a43;
    --sb-hover: rgba(236, 223, 214, .06);
    --sb-active-bg: rgba(219, 167, 160, .18);
    --sb-active-text: #f6d9d1;
    --sb-active-bar: #dba7a0;
    --tb-bg: rgba(242, 235, 228, .88);
    --good: #4d8f6e;
    --warn: #b9853a;
    --bad: #b5524c;
    --font: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
    --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
    --display-weight: 600;
    --shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 10px 26px -20px rgba(74, 60, 54, .45);
    color-scheme: light;
}

/* ───────────── 4. Perla & Oro Noir ───────────── */
[data-theme="pearl_noir"] {
    --bg: #f6f5f1;
    --bg-2: #efede7;
    --surface: #ffffff;
    --surface-2: #faf9f6;
    --surface-3: #f1efe9;
    --border: #e4e1d8;
    --border-strong: #cfcabd;
    --text: #141414;
    --muted: #6b6860;
    --muted-2: #9a968b;
    --accent: #b8974a;
    --accent-2: #141414;
    --accent-ink: #141414;
    --accent-soft: rgba(184, 151, 74, .12);
    --btn-bg: #141414;
    --btn-text: #e8cf8a;
    --btn-border: #141414;
    --sb-bg: #121212;
    --sb-text: #e9e6dd;
    --sb-muted: #7c786e;
    --sb-border: #222222;
    --sb-hover: rgba(255, 255, 255, .05);
    --sb-active-bg: rgba(200, 165, 85, .14);
    --sb-active-text: #e8cf8a;
    --sb-active-bar: #c8a555;
    --tb-bg: rgba(246, 245, 241, .9);
    --good: #2f7d56;
    --warn: #a77b1e;
    --bad: #b23b3b;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Inter', system-ui, sans-serif;
    --display-weight: 600;
    --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 12px 28px -22px rgba(20, 20, 20, .35);
    color-scheme: light;
}

/* ==========================================================================
   Parte 2 · Acabados por tema (Fase 18). Portado de tvci-themes.css de TVCI y traducido al vocabulario de APOLO
   (.sb, .tb, .card, .kpi, .btn--primary, .badge, .tbl, .field). Todo va con prefijo «html[data-theme]»: solo afecta
   a la aplicación; las miniaturas .tp de la galería usan únicamente los tokens de la Parte 1.
   ========================================================================== */

/* ───────────── 1. Obsidiana & Color de Marca: superficies planas, bordes de 1 px, sin brillos ───────────── */
html[data-theme="obsidian_brand"] .card,
html[data-theme="obsidian_brand"] .kpi { box-shadow: none; }
html[data-theme="obsidian_brand"] .card:hover { border-color: var(--border-strong); }
html[data-theme="obsidian_brand"] .btn--primary { border-color: transparent; }
html[data-theme="obsidian_brand"] .btn--primary:hover { filter: none; background: color-mix(in srgb, var(--brand) 88%, #ffffff); }
html[data-theme="obsidian_brand"] .tbl th { letter-spacing: .06em; }
html[data-theme="obsidian_brand"] .sb__link.is-active { box-shadow: inset 2px 0 0 var(--sb-active-bar); }
html[data-theme="obsidian_brand"] .sb__link.is-active .ic { color: var(--brand); }
html[data-theme="obsidian_brand"][data-sidebar="tinted"] .sb { background: color-mix(in srgb, var(--brand) 86%, #000000); border-right-color: rgba(255, 255, 255, .08); }
html[data-theme="obsidian_brand"][data-sidebar="tinted"] .sb__link.is-active .ic { color: #ffffff; }
html[data-theme="obsidian_brand"][data-sidebar="tinted"] .sb__title { color: rgba(255, 255, 255, .62); }

/* ───────────── 2. Zafiro & Oro Imperial: banca privada (cristal zafiro, oro champán, serif editorial) ───────────── */
html[data-theme="sapphire_gold"] {
    --gold: #d4af37;
    --gold-2: #f3e5ab;
    --gold-ink: #070d19;
    --champagne: rgba(212, 175, 55, .32);
    --glass: rgba(15, 27, 51, .84);
}
html[data-theme="sapphire_gold"] body {
    background:
        radial-gradient(1200px 620px at 88% -14%, rgba(212, 175, 55, .13), transparent 62%),
        radial-gradient(900px 700px at -12% 108%, rgba(56, 120, 214, .08), transparent 64%),
        linear-gradient(180deg, #0a1428 0%, #070f20 40%, #060c1a 100%);
    background-attachment: fixed;
    letter-spacing: .005em;
}
/* Serif SOLO en títulos principales y encabezados de tarjeta; cifras, tablas, formularios y botones en sans */
html[data-theme="sapphire_gold"] .content h1,
html[data-theme="sapphire_gold"] .content h2,
html[data-theme="sapphire_gold"] .card__head h2,
html[data-theme="sapphire_gold"] .tb__title h1,
html[data-theme="sapphire_gold"] .modal__box h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: .005em; text-rendering: optimizeLegibility; }
html[data-theme="sapphire_gold"] .kpi__value { font-family: var(--font); font-weight: 700; font-size: clamp(22px, 1.9vw, 30px); letter-spacing: -.01em; white-space: nowrap; font-variant-numeric: tabular-nums; }
html[data-theme="sapphire_gold"] .kpi__label,
html[data-theme="sapphire_gold"] .sb__title { text-transform: uppercase; letter-spacing: .14em; font-size: 10.5px; font-weight: 700; }
html[data-theme="sapphire_gold"] .sb { border-right-color: var(--champagne); box-shadow: 14px 0 40px -26px rgba(0, 0, 0, .9), inset -1px 0 0 rgba(243, 229, 171, .05); }
html[data-theme="sapphire_gold"][data-dock="right"] .sb { border-left-color: var(--champagne); box-shadow: -14px 0 40px -26px rgba(0, 0, 0, .9); }
html[data-theme="sapphire_gold"] .sb__brand { border-bottom-color: rgba(212, 175, 55, .16); }
html[data-theme="sapphire_gold"] .sb__logo { box-shadow: 0 0 0 1px rgba(212, 175, 55, .6), 0 6px 18px -8px rgba(212, 175, 55, .5); }
html[data-theme="sapphire_gold"] .sb__title { color: var(--gold); opacity: .85; }
html[data-theme="sapphire_gold"] .sb__link { border: 1px solid transparent; }
html[data-theme="sapphire_gold"] .sb__link:hover { border-color: rgba(212, 175, 55, .18); color: #ffffff; }
html[data-theme="sapphire_gold"] .sb__link.is-active {
    background: linear-gradient(180deg, #f3e5ab 0%, #d4af37 48%, #b8912a 100%);
    color: var(--gold-ink); font-weight: 700; border-color: transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 10px 24px -14px rgba(212, 175, 55, .8);
}
html[data-theme="sapphire_gold"] .sb__link.is-active::before { display: none; }
html[data-theme="sapphire_gold"] .tb { background: rgba(9, 18, 36, .72); border-bottom-color: rgba(212, 175, 55, .22); box-shadow: 0 1px 0 rgba(243, 229, 171, .05); }
html[data-theme="sapphire_gold"] .card,
html[data-theme="sapphire_gold"] .kpi {
    background: linear-gradient(180deg, rgba(20, 35, 64, .86), var(--glass));
    border-color: var(--champagne);
    box-shadow: inset 0 1px 0 rgba(243, 229, 171, .16), inset 0 -1px 0 rgba(0, 0, 0, .35), var(--shadow);
}
html[data-theme="sapphire_gold"] .card:hover { border-color: rgba(212, 175, 55, .45); }
html[data-theme="sapphire_gold"] .kpi { position: relative; overflow: hidden; }
html[data-theme="sapphire_gold"] .kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(243, 229, 171, .7), transparent); }
html[data-theme="sapphire_gold"] .tbl th { color: var(--gold); letter-spacing: .1em; }
html[data-theme="sapphire_gold"] .tbl tbody tr:hover td { background: rgba(212, 175, 55, .05); }
html[data-theme="sapphire_gold"] .field input,
html[data-theme="sapphire_gold"] .field select,
html[data-theme="sapphire_gold"] .field textarea { background: rgba(6, 11, 22, .7); border-color: rgba(212, 175, 55, .24); }
html[data-theme="sapphire_gold"] .field input:focus,
html[data-theme="sapphire_gold"] .field select:focus,
html[data-theme="sapphire_gold"] .field textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 175, 55, .18); }
html[data-theme="sapphire_gold"] .btn--primary { border-color: rgba(243, 229, 171, .6); font-weight: 700; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 10px 24px -14px rgba(212, 175, 55, .75); }
html[data-theme="sapphire_gold"] .btn--ghost { border-color: rgba(212, 175, 55, .35); color: var(--gold-2); }
html[data-theme="sapphire_gold"] .btn--ghost:hover { background: rgba(212, 175, 55, .08); border-color: var(--gold); }
html[data-theme="sapphire_gold"] .badge--accent { background: linear-gradient(180deg, #f3e5ab, #d4af37); color: var(--gold-ink); border-color: transparent; }
html[data-theme="sapphire_gold"] .icon-btn,
html[data-theme="sapphire_gold"] .tb__search { background: rgba(15, 27, 51, .7); border-color: rgba(212, 175, 55, .28); }
html[data-theme="sapphire_gold"] .modal__box,
html[data-theme="sapphire_gold"] .menu__pop { background: linear-gradient(180deg, rgba(20, 35, 64, .98), rgba(11, 21, 41, .98)); border-color: var(--champagne); }

/* ───────────── 3. Nude & Rose Gold: paleta ejecutiva cálida, bordes de 1 px, serif editorial en títulos ───────────── */
html[data-theme="nude_rosegold"] body { background: radial-gradient(900px 520px at 100% -10%, rgba(219, 167, 160, .22), transparent 62%), var(--bg); background-attachment: fixed; }
html[data-theme="nude_rosegold"] .card,
html[data-theme="nude_rosegold"] .kpi { background: linear-gradient(180deg, #fdfaf7, var(--surface)); border-color: #e0c9bc; }
html[data-theme="nude_rosegold"] .card:hover { border-color: #cfa89d; }
html[data-theme="nude_rosegold"] .tb { border-bottom-color: #e0c9bc; }
html[data-theme="nude_rosegold"] .sb { border-right-color: #6a554c; }
html[data-theme="nude_rosegold"] .sb__title { color: #dba7a0; }
html[data-theme="nude_rosegold"] .tbl th { color: #7a5f58; letter-spacing: .08em; }
html[data-theme="nude_rosegold"] .tbl tbody tr:hover td { background: rgba(219, 167, 160, .12); }
html[data-theme="nude_rosegold"] .btn--primary { font-weight: 600; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45); }
html[data-theme="nude_rosegold"] .btn--ghost { border-color: #d3b4a8; color: #7a4f55; }
html[data-theme="nude_rosegold"] .btn--ghost:hover { background: rgba(183, 110, 121, .10); border-color: #b76e79; }
html[data-theme="nude_rosegold"] .badge--accent { background: rgba(183, 110, 121, .16); color: #7a3f49; border-color: rgba(183, 110, 121, .35); }
html[data-theme="nude_rosegold"] .field input:focus,
html[data-theme="nude_rosegold"] .field select:focus,
html[data-theme="nude_rosegold"] .field textarea:focus { border-color: #b76e79; box-shadow: 0 0 0 3px rgba(183, 110, 121, .18); }

/* ───────────── 4. Perla & Oro Noir: modo claro de lujo (perla, champán, oro cepillado, estructura carbón) ───────────── */
html[data-theme="pearl_noir"] .card,
html[data-theme="pearl_noir"] .kpi { border-color: #e2d8bd; }
html[data-theme="pearl_noir"] .card:hover { border-color: #c8a555; }
html[data-theme="pearl_noir"] .tb { border-bottom-color: #e2d8bd; }
html[data-theme="pearl_noir"] .sb { border-right-color: #2a2a2a; }
html[data-theme="pearl_noir"] .sb__title { color: #c8a555; }
html[data-theme="pearl_noir"] .sb__link.is-active .ic { color: #c8a555; }
html[data-theme="pearl_noir"] .tbl th { color: #141414; letter-spacing: .1em; border-bottom-color: #c8a555; }
html[data-theme="pearl_noir"] .tbl tbody tr:hover td { background: rgba(200, 165, 85, .08); }
html[data-theme="pearl_noir"] .btn--primary { font-weight: 600; letter-spacing: .01em; }
html[data-theme="pearl_noir"] .btn--primary:hover { background: #2a2a2a; filter: none; }
html[data-theme="pearl_noir"] .btn--ghost { border-color: #cfc29a; }
html[data-theme="pearl_noir"] .btn--ghost:hover { background: rgba(200, 165, 85, .10); border-color: #c8a555; }
html[data-theme="pearl_noir"] .badge--accent { background: #141414; color: #e8cf8a; border-color: #141414; }
html[data-theme="pearl_noir"] .field input:focus,
html[data-theme="pearl_noir"] .field select:focus,
html[data-theme="pearl_noir"] .field textarea:focus { border-color: #b8974a; box-shadow: 0 0 0 3px rgba(184, 151, 74, .20); }

/* Tipografía editorial compartida por Nude y Perla (como Zafiro): serif SOLO en títulos principales */
html[data-theme="nude_rosegold"] .content h1,
html[data-theme="nude_rosegold"] .content h2,
html[data-theme="nude_rosegold"] .card__head h2,
html[data-theme="nude_rosegold"] .modal__box h2,
html[data-theme="pearl_noir"] .content h1,
html[data-theme="pearl_noir"] .content h2,
html[data-theme="pearl_noir"] .card__head h2,
html[data-theme="pearl_noir"] .modal__box h2 { font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif; font-weight: 700; letter-spacing: .005em; text-rendering: optimizeLegibility; }
html[data-theme="nude_rosegold"] .tb__title h1,
html[data-theme="pearl_noir"] .tb__title h1 { font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif; font-weight: 700; font-size: 22px; }
html[data-theme="nude_rosegold"] .card__head h2,
html[data-theme="pearl_noir"] .card__head h2 { font-size: 21px; }
html[data-theme="nude_rosegold"] .kpi__value,
html[data-theme="pearl_noir"] .kpi__value { font-family: var(--font); font-variant-numeric: tabular-nums; }
html[data-theme="nude_rosegold"] .kpi__label,
html[data-theme="pearl_noir"] .kpi__label { text-transform: uppercase; letter-spacing: .12em; font-size: 10.5px; font-weight: 700; }

/* Respeta a quien pide menos movimiento: sin fondos fijos ni desenfoques animados */
@media (prefers-reduced-motion: reduce) {
    html[data-theme] body { background-attachment: scroll; }
}
