/* ══════════════════════════════════════════════════════════════════════════
   KidsLearns (KidsLearns) — estilos globales + tokens de tema (claro/oscuro)
   Regla heredada de RGCLOUDS: toda la paleta vive en variables --rg-*.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
    --rg-grape: #845ef7;
    --rg-sky: #4cc3ff;
    --rg-grass: #51cf66;
    --rg-sun: #ffd43b;
    --rg-berry: #ff6b9d;
}

[data-mode="light"] {
    --rg-bg-page: #f4f7fb;
    --rg-bg-card: #ffffff;
    --rg-bg-input: #ffffff;
    --rg-bg-hover: #f1f5f9;
    --rg-bg-subtle: #f8fafc;
    --rg-border: #e2e8f0;
    --rg-text-primary: #243b53;
    --rg-text-secondary: #475569;
    --rg-text-muted: #94a3b8;
    --rg-primary: #845ef7;
    --rg-accent: #4cc3ff;
    --rg-success: #16a34a;
    --rg-warning: #d97706;
    --rg-danger: #dc2626;
    --rg-info: #2563eb;
}

[data-mode="dark"] {
    --rg-bg-page: #0f172a;
    --rg-bg-card: #1e293b;
    --rg-bg-input: #1e293b;
    --rg-bg-hover: #334155;
    --rg-bg-subtle: #273449;
    --rg-border: #334155;
    --rg-text-primary: #e2e8f0;
    --rg-text-secondary: #cbd5e1;
    --rg-text-muted: #94a3b8;
    --rg-primary: #a78bfa;
    --rg-accent: #67d3ff;
    --rg-success: #4ade80;
    --rg-warning: #fbbf24;
    --rg-danger: #f87171;
    --rg-info: #93c5fd;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--rg-bg-page);
    color: var(--rg-text-primary);
}

a { color: var(--rg-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { color: var(--rg-text-primary); margin: 0; }

/* ── Botones estándar ──────────────────────────────────────────────────── */
.btn-rg {
    border: none;
    border-radius: 0.6rem;
    padding: 0.55rem 0.95rem;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: filter 0.15s, background 0.15s;
    background: var(--rg-primary);
    color: #fff;
}
.btn-rg:hover { filter: brightness(1.05); }
.btn-rg:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-rg.out { background: transparent; color: var(--rg-primary); border: 1.5px solid var(--rg-primary); }
.btn-rg.ghost { background: var(--rg-bg-subtle); color: var(--rg-text-primary); }
.btn-rg.danger { background: var(--rg-danger); }
.btn-rg.sm { padding: 0.35rem 0.6rem; font-size: 0.8rem; }

/* ── Cards / grid ──────────────────────────────────────────────────────── */
.rg-card {
    background: var(--rg-bg-card);
    border: 1px solid var(--rg-border);
    border-radius: 1rem;
    padding: 1.1rem;
    box-shadow: 0 4px 14px rgba(36, 59, 83, 0.05);
}
.rg-card h3 { font-size: 0.95rem; color: var(--rg-text-primary); margin-bottom: 0.7rem; display: flex; align-items: center; gap: 0.4rem; }
.rg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .rg-grid { grid-template-columns: 1fr; } }

.kpi { font-size: 1.9rem; font-weight: 800; color: var(--rg-text-primary); }
.kpi small { font-size: 0.9rem; color: var(--rg-text-muted); font-weight: 600; }

.bar { height: 12px; border-radius: 7px; background: var(--rg-bg-subtle); overflow: hidden; margin: 0.5rem 0; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--rg-grass), var(--rg-sky)); }

.muted { color: var(--rg-text-muted); font-size: 0.82rem; }

/* ── Tablas ────────────────────────────────────────────────────────────── */
.rg-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.rg-table th { text-align: left; color: var(--rg-text-muted); font-size: 0.7rem; text-transform: uppercase; padding: 0.45rem 0.5rem; border-bottom: 2px solid var(--rg-border); background: var(--rg-bg-subtle); }
.rg-table td { padding: 0.5rem; border-bottom: 1px solid var(--rg-border); color: var(--rg-text-secondary); }
.rg-table tr:hover td { background: var(--rg-bg-hover); }

/* ── Inputs ────────────────────────────────────────────────────────────── */
.rg-input, .rg-select {
    width: 100%;
    background: var(--rg-bg-input);
    color: var(--rg-text-primary);
    border: 1px solid var(--rg-border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.65rem;
    font: inherit;
}
.rg-input:focus, .rg-select:focus { outline: none; border-color: var(--rg-primary); box-shadow: 0 0 0 3px rgba(132, 94, 247, 0.15); }

/* Ocultar spinners numéricos (regla RGCLOUDS) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* ── Pills / badges ────────────────────────────────────────────────────── */
.pill { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.12rem 0.55rem; border-radius: 1rem; }
.pill.ok { background: rgba(81, 207, 102, 0.15); color: var(--rg-success); }
.pill.warn { background: rgba(255, 212, 59, 0.2); color: var(--rg-warning); }
.pill.danger { background: rgba(220, 38, 38, 0.12); color: var(--rg-danger); }

/* ── Alertas ───────────────────────────────────────────────────────────── */
.rg-alert { border-radius: 0.6rem; padding: 0.7rem 0.9rem; font-size: 0.85rem; display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.rg-alert.warn { background: rgba(255, 212, 59, 0.15); color: var(--rg-warning); border: 1px solid rgba(255, 212, 59, 0.4); }
.rg-alert.danger { background: rgba(220, 38, 38, 0.1); color: var(--rg-danger); border: 1px solid rgba(220, 38, 38, 0.3); }
.rg-alert.ok { background: rgba(81, 207, 102, 0.12); color: var(--rg-success); border: 1px solid rgba(81, 207, 102, 0.3); }

.rg-anim { animation: rgSlideUp 0.35s ease; }
@keyframes rgSlideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Pantalla de arranque WASM + error UI ──────────────────────────────── */
.boot { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; background: linear-gradient(160deg,#eaf6ff,#f5ecff); }
.boot-emoji { font-size: 3rem; }
.boot-name { font-size: 1.4rem; font-weight: 800; color: #845ef7; }
.boot-spin { width: 36px; height: 36px; border: 4px solid #e3d9ff; border-top-color: #845ef7; border-radius: 50%; animation: bootspin 1s linear infinite; margin-top: .4rem; }
@keyframes bootspin { to { transform: rotate(360deg); } }
#blazor-error-ui { position: fixed; bottom: 0; left: 0; right: 0; display: none; background: #fff3cd; color: #664d03; padding: .7rem 1rem; box-shadow: 0 -2px 10px rgba(0,0,0,.1); z-index: 1100; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }
#blazor-error-ui .reload { color: #845ef7; font-weight: 700; }
