/* =============================================================
   Tema compartido: fondo fractal de hojas + glassmorphism
   Se aplica cuando el body tiene la clase .sp-themed
   Trabaja por encima de estilos.css (sobreescribe selectores)
   ============================================================= */

/* Animated conic angle property */
@property --a {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

/* ---------- Fondo base y canvas de hojas ---------- */
body.sp-body.sp-themed {
    min-height: 100vh;
    overflow-x: hidden;
    color: #eaf4ff;
    background:
        radial-gradient(1200px 600px at 15% -10%, rgba(54, 129, 96, 0.35), transparent 60%),
        radial-gradient(900px 600px at 110% 10%, rgba(255, 178, 71, 0.22), transparent 65%),
        radial-gradient(1000px 700px at 50% 110%, rgba(70, 27, 120, 0.35), transparent 60%),
        linear-gradient(160deg, #061a2e 0%, #0b2d4a 45%, #07203a 100%);
    background-attachment: fixed;
}

body.sp-body.sp-themed::before,
body.sp-body.sp-themed::after { display: none !important; }

#sp-leaf-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

.sp-themed .sp-container {
    position: relative;
    z-index: 2;
    max-width: 1280px;
    padding: 34px 26px 60px;
}

/* ---------- Hero encabezado compartido ---------- */
.sp-hero {
    text-align: center;
    color: #eaf4ff;
    padding: 6px 8px 0;
    margin-bottom: 22px;
}

.sp-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #d6ecff;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
    margin-bottom: 14px;
}

.sp-hero-badge .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #9ff6c9, #2ecc71 70%);
    box-shadow: 0 0 12px #2ecc71;
}

.sp-hero-title,
.sp-hero h1.sp-hero-title {
    font-size: clamp(1.8rem, 1.3rem + 2.2vw, 3.1rem);
    line-height: 1.05;
    font-weight: 800;
    margin: 0 0 10px;
    background: linear-gradient(90deg, #ffffff 0%, #9edcff 45%, #ffd27a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.5px;
}

.sp-hero-sub {
    color: #bcd4ee;
    font-size: clamp(0.95rem, 0.85rem + 0.3vw, 1.05rem);
    max-width: 700px;
    margin: 0 auto;
}

.sp-hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 16px;
}

/* ---------- Overrides para convertir sp-card en glass oscuro ---------- */
.sp-themed .sp-card {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.11) 0%, rgba(255, 255, 255, 0.04) 100%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #eaf4ff;
    border-radius: 26px;
    padding: 26px;
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    box-shadow:
        0 30px 60px rgba(2, 10, 24, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
    animation: spFloatT 7s ease-in-out infinite;
    margin-bottom: 22px;
}

.sp-themed .sp-card:nth-child(even) { animation-duration: 8.5s; animation-delay: 0.6s; }

.sp-themed .sp-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;
    background: conic-gradient(from var(--a, 0deg),
        rgba(70, 200, 140, 0.0), rgba(70, 200, 140, 0.75),
        rgba(255, 188, 71, 0.75), rgba(255, 110, 140, 0.65),
        rgba(90, 140, 255, 0.75), rgba(70, 200, 140, 0.0));
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    animation: spSpinT 11s linear infinite;
    opacity: 0.7;
    z-index: -1;
    pointer-events: none;
}

@supports not (background: conic-gradient(from 0deg, red, blue)) {
    .sp-themed .sp-card::before { display: none; }
}

@keyframes spSpinT { to { --a: 360deg; } }
@keyframes spFloatT {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Tipografia dentro de cards */
.sp-themed .sp-card h1,
.sp-themed .sp-card h2,
.sp-themed .sp-card h3 { color: #fff; }

.sp-themed .sp-muted { color: #b7cae2; }
.sp-themed .sp-card .sp-muted { color: #b7cae2; }

/* Listas dentro de card */
.sp-themed .sp-card ul li { color: #e0edfc; }

/* ---------- KPIs como chips glass ---------- */
.sp-themed .sp-kpis article {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.03) 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #eaf4ff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
    padding: 16px;
}
.sp-themed .sp-kpis strong {
    background: linear-gradient(90deg, #9edcff 0%, #ffd27a 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
}
.sp-themed .sp-kpis span { color: #c0d4ed; font-size: 14px; font-weight: 500; }

/* KPIs con icono al lado (dashboard) */
.sp-themed .sp-kpis-icons article {
    display: flex; align-items: center; gap: 14px;
}
.sp-themed .sp-kpis-icons .sp-kpi-ic {
    width: 48px; height: 48px; border-radius: 14px;
    display: grid; place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    flex-shrink: 0;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

/* ---------- Tabla: wrapper glass, tabla interna blanca para legibilidad ---------- */
.sp-themed .sp-table-wrap {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(10, 26, 52, 0.45);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.sp-themed .sp-table {
    background: rgba(255, 255, 255, 0.97);
    color: #1a3759;
    font-size: 15px;
}
.sp-themed .sp-table th {
    background: linear-gradient(180deg, #edf4ff 0%, #e2edff 100%);
    color: #244971;
    font-size: 13px;
    padding: 12px 11px;
}
.sp-themed .sp-table td {
    padding: 12px 11px;
    font-size: 14.5px;
}
.sp-themed .sp-table td small { font-size: 13px; color: #4a6a8f; }
.sp-themed .sp-table td strong { color: #1a3759; font-size: 14.8px; }

/* select dentro de tabla */
.sp-themed .sp-table select {
    background: #fff;
    color: #1a3759;
    border: 1px solid #bfd2ef;
    border-radius: 9px;
    padding: 6px 8px;
    font-weight: 600;
    box-shadow: none;
}

/* ---------- Formularios ---------- */
.sp-themed .sp-form label { color: #c8ddf6; font-weight: 600; font-size: 15px; }
.sp-themed .sp-form input,
.sp-themed .sp-form textarea,
.sp-themed .sp-form select {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
    font-size: 15.5px;
    padding: 12px 14px;
    border-radius: 12px;
}
.sp-themed .sp-form input::placeholder,
.sp-themed .sp-form textarea::placeholder { color: #8faecf; }
.sp-themed .sp-form input:focus,
.sp-themed .sp-form textarea:focus,
.sp-themed .sp-form select:focus {
    border-color: #60a5fa;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18);
}
.sp-themed .sp-form input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8) brightness(1.4);
    cursor: pointer;
}

.sp-themed .sp-check { color: #dbe8fa; font-size: 15px; line-height: 1.45; }

/* ---------- Condiciones ---------- */
.sp-themed .sp-conditions {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #e3edfc;
}
.sp-themed .sp-conditions h2,
.sp-themed .sp-conditions h3 { color: #fff; }

/* ---------- Botones ---------- */
.sp-themed .sp-btn.ghost,
.sp-themed button.ghost,
.sp-themed a.sp-btn.ghost {
    background: rgba(255, 255, 255, 0.09);
    color: #eaf4ff;
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255,255,255,0.12);
}
.sp-themed .sp-btn.ghost:hover { background: rgba(255, 255, 255, 0.15); }

/* Botones hero usables en cualquier pagina */
.sp-btn-hero {
    --bg: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 13px;
    font-weight: 700;
    text-decoration: none;
    border: none;
    color: #fff;
    background: var(--bg);
    box-shadow: 0 14px 30px rgba(34, 197, 94, 0.35), inset 0 1px 0 rgba(255,255,255,0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    cursor: pointer;
    font-size: 14.5px;
    letter-spacing: 0.2px;
}
.sp-btn-hero:hover { transform: translateY(-2px) scale(1.02); filter: brightness(1.06); }
.sp-btn-hero.sp-btn-outline {
    background: rgba(255, 255, 255, 0.06);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
    color: #f1f8ff;
}
.sp-btn-hero.sp-btn-outline:hover { background: rgba(255, 255, 255, 0.14); border-color: #fff; }
.sp-btn-hero.sp-btn-primary {
    --bg: linear-gradient(135deg, #3b82f6 0%, #6366f1 60%, #8b5cf6 100%);
    box-shadow: 0 14px 30px rgba(99, 102, 241, 0.45), inset 0 1px 0 rgba(255,255,255,0.25);
}
.sp-btn-hero.sp-btn-danger-soft {
    --bg: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    box-shadow: 0 14px 30px rgba(239, 68, 68, 0.35);
}

/* ---------- Alertas en fondo oscuro ---------- */
.sp-themed .sp-alert.ok {
    background: rgba(34, 197, 94, 0.15);
    color: #bbf7d0;
    border: 1px solid rgba(34, 197, 94, 0.35);
}
.sp-themed .sp-alert.error {
    background: rgba(239, 68, 68, 0.15);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

/* ---------- Charts y calendario: fondo claro legible ---------- */
.sp-themed .sp-chart-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
}
.sp-themed .sp-chart-card h3 { color: #1a3e6a; }
.sp-themed .sp-charts canvas {
    background: #fff;
    border: 1px solid #c8d8ef;
}

.sp-themed .sp-calendar-card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #1a3759;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
}
.sp-themed .sp-calendar-card h3 { color: #254972; }

/* Legenda visible sobre fondo oscuro */
.sp-themed .sp-legend { justify-content: flex-start; }

/* ---------- Links y url ---------- */
.sp-themed .sp-link,
.sp-themed a.sp-link { color: #9edcff; }
.sp-themed .sp-link:hover { color: #fff; }
.sp-themed .sp-url { color: #a8c5e6; word-break: break-all; }

/* ---------- Logos en cards oscuras: chip blanco ---------- */
.sp-themed .sp-logo-main,
.sp-themed .sp-logo-side,
.sp-themed .sp-logo-bottom {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
}

.sp-themed .sp-logo-bottom-wrap {
    border-top: 1px dashed rgba(255, 255, 255, 0.2);
}

/* ---------- Campo floating-label reutilizable ---------- */
.sp-field {
    position: relative;
    margin: 0;
}
.sp-field > input,
.sp-field > textarea,
.sp-field > select {
    width: 100%;
    padding: 22px 16px 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 13px;
    color: #fff;
    font-size: 16.5px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: none;
    line-height: 1.3;
}
.sp-field > textarea { min-height: 110px; resize: vertical; }
.sp-field > input::placeholder,
.sp-field > textarea::placeholder { color: transparent; }
.sp-field > label {
    position: absolute;
    left: 16px;
    top: 17px;
    color: #b2c9e4;
    font-size: 15.5px;
    pointer-events: none;
    transition: all 0.2s ease;
    background: transparent;
    max-width: calc(100% - 32px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.sp-field > input:focus,
.sp-field > textarea:focus,
.sp-field > select:focus,
.sp-field > input:not(:placeholder-shown),
.sp-field > textarea:not(:placeholder-shown) {
    border-color: #60a5fa;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18);
}
.sp-field > input:focus + label,
.sp-field > textarea:focus + label,
.sp-field > select:focus + label,
.sp-field > input:not(:placeholder-shown) + label,
.sp-field > textarea:not(:placeholder-shown) + label,
.sp-field.filled > label {
    top: 5px;
    font-size: 11.5px;
    color: #9edcff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

/* Hint secundario */
.sp-field-hint {
    display: block;
    font-size: 13.5px;
    color: #a8c0db;
    margin-top: 6px;
    margin-left: 4px;
    line-height: 1.4;
}

/* Grid 2 columnas responsive para formularios */
.sp-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 720px) {
    .sp-grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Fieldsets tipo mini glass ---------- */
.sp-fieldset {
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    padding: 22px 22px 24px;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
    margin: 0 0 18px;
}
.sp-fieldset legend {
    padding: 6px 14px;
    margin-left: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #9edcff;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ---------- Chips de fecha en registro ---------- */
.sp-date-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.sp-date-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 6px 12px;
    border-radius: 999px;
    background: rgba(70, 140, 250, 0.18);
    border: 1px solid rgba(96, 165, 250, 0.4);
    color: #dbeafe;
    font-size: 13px;
    font-weight: 600;
}
.sp-date-chip button {
    background: rgba(0, 0, 0, 0.2);
    border: none;
    color: #fecaca;
    width: 20px; height: 20px;
    border-radius: 50%;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    font-size: 13px;
    box-shadow: none;
    line-height: 1;
}
.sp-date-chip button:hover { background: rgba(239, 68, 68, 0.3); color: #fff; }

.sp-date-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.sp-date-row input[type="date"] {
    flex: 1 1 180px;
}

/* ---------- Topbar del dashboard refinado ---------- */
.sp-themed .sp-topbar {
    padding-bottom: 4px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
    margin-bottom: 14px;
}

/* ---------- Estados de eventos en calendario: mantener (son light) ---------- */
/* (ya estan bien en estilos.css, heredan igual) */

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .sp-themed .sp-container { padding: 20px 14px 40px; }
    .sp-themed .sp-card { padding: 18px; border-radius: 20px; }
    .sp-hero-title { font-size: clamp(1.5rem, 1.1rem + 2vw, 2.2rem); }
}
