/* ============================================================
   UI limpia (oct-2026) — las piezas de las páginas rehechas.
   Solo tokens de tokens.css; prefijo ui- para no pisar nada de style.css.
   Botón, segmentado, interruptor, píldora, tarjeta, campo, modal, panel lateral, tooltip.
   ============================================================ */

.ui-card { background: var(--bg); border-radius: var(--r-card); box-shadow: var(--shadow-card); }

/* ---- Botón ---- */
.ui-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 12px; border: 0; border-radius: var(--r-md);
    background: var(--bg); color: var(--ink); box-shadow: var(--shadow-ctl);
    font: var(--fw-med) 13px/1 var(--font); white-space: nowrap; text-decoration: none; cursor: pointer;
    transition: background var(--t), box-shadow var(--t), opacity var(--t);
}
.ui-btn:hover { background: var(--block); color: var(--ink); }
.ui-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ui-btn[disabled] { opacity: .5; cursor: default; pointer-events: none; }
.ui-btn svg { width: 15px; height: 15px; flex: none; }
.ui-btn-ink { background: var(--ink); color: #fff; box-shadow: none; }
.ui-btn-ink:hover { background: #3F3F46; color: #fff; }
.ui-btn-red { background: var(--alert); color: #fff; box-shadow: none; }
.ui-btn-red:hover { background: #B91C1C; color: #fff; }
.ui-btn-quiet { background: transparent; box-shadow: none; color: var(--ink-2); }
.ui-btn-quiet:hover { background: var(--hover-ctl); color: var(--ink); }
.ui-btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }

/* ---- Segmentado (Meta | Google, filtros) ---- */
.ui-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--block-2); }
.ui-seg > a, .ui-seg > button {
    display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border: 0; border-radius: 7px;
    background: none; color: var(--ink-2); font: var(--fw-med) 13px/1 var(--font); text-decoration: none; cursor: pointer;
    transition: background var(--t), color var(--t);
}
.ui-seg > a:hover, .ui-seg > button:hover { color: var(--ink); }
.ui-seg > .on { background: var(--bg); color: var(--ink); box-shadow: 0 0 0 1px var(--line-card), 0 1px 2px rgba(24, 24, 27, .06); }
.ui-seg > * > span { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ui-seg-sm > a, .ui-seg-sm > button { height: 24px; padding: 0 10px; font-size: 12.5px; }
.ui-seg-ico > button { padding: 0 7px; }
.ui-seg-ico svg { width: 15px; height: 15px; }

/* ---- Interruptor ---- */
.ui-sw {
    position: relative; flex: none; width: 30px; height: 18px; padding: 0; border: 0; border-radius: 999px;
    background: #D4D4D8; cursor: pointer; transition: background 140ms ease;
}
.ui-sw::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgba(24, 24, 27, .25); transition: transform 140ms ease;
}
.ui-sw.on { background: var(--accent); }
.ui-sw.on::after { transform: translateX(12px); }
.ui-sw:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ui-sw.busy { opacity: .5; pointer-events: none; }

/* ---- Píldora de estado ---- */
.ui-pill {
    display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-pill);
    font: var(--fw-med) 12px/1 var(--font); white-space: nowrap;
}
.ui-pill-gray   { background: var(--pill-gray-bg);   color: var(--pill-gray-tx); }
.ui-pill-green  { background: var(--pill-green-bg);  color: var(--pill-green-tx); }
.ui-pill-red    { background: var(--pill-red-bg);    color: var(--pill-red-tx); }
.ui-pill-yellow { background: var(--pill-yellow-bg); color: var(--pill-yellow-tx); }
.ui-pill-blue   { background: var(--pill-blue-bg);   color: var(--pill-blue-tx); }

/* ---- Campos ---- */
.ui-field { display: grid; gap: 6px; margin: 0; }
.ui-field > span, .ui-field > .ax-up-lab { font: var(--fw-med) 12.5px/1.2 var(--font); color: var(--ink-2); }
.ui-field input, .ui-field textarea, .ui-field select {
    width: 100%; box-sizing: border-box; margin: 0; padding: 8px 10px; border: 0; border-radius: var(--r-md);
    background: var(--bg); color: var(--ink); font: 13.5px/1.45 var(--font);
    box-shadow: 0 0 0 1px rgba(24, 24, 27, .13); outline: none; transition: box-shadow var(--t);
}
.ui-field textarea { resize: vertical; min-height: 96px; }
.ui-field input:focus, .ui-field textarea:focus, .ui-field select:focus {
    box-shadow: 0 0 0 1px var(--accent), 0 0 0 3px rgba(37, 99, 235, .15);
}
.ui-check { display: inline-flex; align-items: center; gap: 8px; font: 13px/1.3 var(--font); color: var(--ink-2); cursor: pointer; }
.ui-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--ink); }

/* ---- Cerrar ---- */
.ui-x {
    display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--r-md);
    background: none; color: var(--ink-2); cursor: pointer; flex: none;
}
.ui-x:hover { background: var(--hover-ctl); color: var(--ink); }
.ui-x svg { width: 17px; height: 17px; }
.ui-x-sm { width: 24px; height: 24px; }
.ui-x-sm svg { width: 13px; height: 13px; }

/* ---- Modal ---- */
.ui-modal {
    position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 24px 16px;
    background: rgba(24, 24, 27, .32); animation: ui-in 140ms ease-out;
}
.ui-modal-box {
    display: flex; flex-direction: column; width: min(860px, 100%); max-height: calc(100dvh - 48px);
    background: var(--bg); border-radius: 14px; box-shadow: var(--shadow-pop); overflow: hidden;
    animation: ui-up 180ms cubic-bezier(.2, .8, .2, 1);
}
.ui-modal-h { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px 14px; }
.ui-modal-h > div { flex: 1; min-width: 0; }
.ui-modal-h h2 { margin: 0; font: var(--fw-sb) 17px/1.3 var(--font); letter-spacing: -.01em; color: var(--ink); }
.ui-modal-h p { margin: 4px 0 0; font: 13px/1.45 var(--font); color: var(--ink-2); }
.ui-modal-f {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 24px;
    border-top: 1px solid var(--line); background: var(--bg);
}

/* ---- Panel lateral (detalle) ---- */
.ui-scrim { position: fixed; inset: 0; z-index: 1100; background: rgba(24, 24, 27, .16); animation: ui-in 140ms ease-out; }
.ui-drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 1101; width: min(620px, 100vw);
    display: flex; flex-direction: column; background: var(--bg); box-shadow: var(--shadow-drawer);
    transform: translateX(100%); transition: transform 220ms cubic-bezier(.2, .8, .2, 1);
}
.ui-drawer.open { transform: none; }

/* ---- Tooltip de gráficos (una capa en el body; los [data-tip] siguen con el de la app) ---- */
.ui-tip {
    position: fixed; z-index: 1300; pointer-events: none; padding: 8px 10px; border-radius: 8px;
    background: var(--ink); color: #fff; font: 12px/1.5 var(--font); box-shadow: var(--shadow-toast);
    white-space: nowrap; font-variant-numeric: tabular-nums;
}
.ui-tip b { font-weight: var(--fw-sb); }
.ui-tip i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; vertical-align: 0; }

@keyframes ui-in { from { opacity: 0; } }
@keyframes ui-up { from { opacity: 0; transform: translateY(8px) scale(.99); } }
@media (prefers-reduced-motion: reduce) {
    .ui-modal, .ui-modal-box, .ui-scrim { animation: none; }
    .ui-drawer, .ui-sw, .ui-sw::after { transition: none; }
}
