:root {
    --color-bg-top: #D41E5E;
    --color-bg-glow: rgba(212, 30, 94, 0.45);
    --color-bg-bottom: #120f1e;
    --color-component: #CB809A;

    --bg-main: #07060c;
    --bg-surface: #0e0b17;
    --bg-card: rgba(18, 22, 34, 0.78);
    --border-glass: rgba(255, 255, 255, 0.08);

    --color-text-main: #ffffff;
    --color-text-secondary: #94a3b8;
    --color-text-muted: #64748b;
    --color-text-brand: #D41E5E;

    --topbar-height: 70px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    background-color: var(--bg-main);
    color: var(--color-text-main);
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === LUXURY INITIAL LOADER === */
.initial-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #07060c;
    position: relative;
}

.loader-pulse-ring {
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 30, 94, 0.4) 0%, transparent 70%);
    animation: pulseRing 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulseRing {
    0% { transform: scale(0.8); opacity: 0.8; }
    50% { transform: scale(1.4); opacity: 0.3; }
    100% { transform: scale(0.8); opacity: 0.8; }
}

.loader-badge {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 64, 129, 0.4);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(212, 30, 94, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 2;
    animation: floatBadge 3s ease-in-out infinite;
    overflow: hidden;
}

@keyframes floatBadge {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.loader-logo-img {
    width: 58px;
    height: 58px;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(255, 64, 129, 0.6));
}

.loader-logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.5px;
}

.loader-text {
    margin-top: 1.75rem;
    text-align: center;
    z-index: 2;
}

.loader-text h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: #fff;
}

.loader-text p {
    margin: 0.35rem 0 0 0;
    font-size: 0.85rem;
    color: #94a3b8;
}

/* === SCROLLBARS === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-bg-top);
}

/* =========================================================
   SISTEMA GLOBAL DE FORMULARIOS & INPUTS (DARK & LIGHT)
   ========================================================= */
input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
select,
textarea,
.form-control,
.form-select,
.custom-input,
.custom-search-input,
.custom-select,
.dark-input,
.form-input {
    width: 100%;
    background-color: rgba(18, 22, 36, 0.8);
    color: #f8fafc;
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.92rem;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    outline: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-select:focus,
.custom-input:focus,
.custom-search-input:focus,
.custom-select:focus,
.dark-input:focus,
.form-input:focus {
    border-color: #ff4081 !important;
    background-color: rgba(24, 28, 46, 0.95) !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(255, 64, 129, 0.25), inset 0 1px 2px rgba(0, 0, 0, 0.2) !important;
}

input::placeholder,
textarea::placeholder,
.form-control::placeholder,
.custom-input::placeholder,
.dark-input::placeholder,
.form-input::placeholder {
    color: #64748b;
    font-size: 0.88rem;
}

select option {
    background-color: #121420;
    color: #ffffff;
    padding: 8px 12px;
}

.form-label {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #cbd5e1;
    letter-spacing: -0.2px;
}

.font-bold, .fw-bold {
    font-weight: 700 !important;
}

/* Checkbox personalizado */
.form-check-input, input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #ff4081;
    cursor: pointer;
    vertical-align: middle;
}

.form-check-label {
    margin-left: 8px;
    font-size: 0.88rem;
    color: #cbd5e1;
    cursor: pointer;
    vertical-align: middle;
}

/* =========================================================
   INPUT GROUP UNIFICADO
   ========================================================= */
.input-group {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    position: relative;
}

.input-group > .form-control,
.input-group > .custom-input,
.input-group > input {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group > :not(:last-child) {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.input-group > :not(:first-child) {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    margin-left: -1px;
}

/* =========================================================
   BARRA DE FORMATO RÁPIDO (B, U, • Lista)
   ========================================================= */
.formatting-mini-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 6px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-fmt-xs {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1.3;
    transition: all 0.15s ease;
}

.btn-fmt-xs:hover {
    background: rgba(233, 30, 99, 0.3);
    border-color: #ff4081;
    color: #ffffff;
}

/* =========================================================
   SISTEMA DE BOTONES GLOBALES
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 9px 18px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
    text-decoration: none;
    box-sizing: border-box;
    line-height: 1.4;
}

.btn:active {
    transform: scale(0.98);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #ff4081 0%, #d41e5e 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(212, 30, 94, 0.35);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ff6097 0%, #e91e63 100%);
    box-shadow: 0 6px 20px rgba(212, 30, 94, 0.5);
    transform: translateY(-1px);
    color: #ffffff;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
    border: none;
}

.btn-success:hover {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    transform: translateY(-1px);
    color: #ffffff;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.35);
    border-color: #ef4444;
    color: #ffffff;
}

.btn-outline-primary {
    background: rgba(212, 30, 94, 0.12);
    border: 1px solid rgba(212, 30, 94, 0.45);
    color: #ff80ab;
}

.btn-outline-primary:hover {
    background: rgba(212, 30, 94, 0.25);
    border-color: #ff4081;
    color: #ffffff;
}

.btn-outline-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
}

.btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

.btn-outline-info {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #7dd3fc;
}

.btn-outline-info:hover {
    background: rgba(56, 189, 248, 0.25);
    color: #ffffff;
}

.btn-outline-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #ffffff;
}

/* =========================================================
   GRID & UTILIDADES RESPONSIVAS
   ========================================================= */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}

.row > * {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
    box-sizing: border-box;
}

.g-1 { margin-right: -0.25rem; margin-left: -0.25rem; }
.g-1 > * { padding-right: 0.25rem; padding-left: 0.25rem; }
.g-2 { margin-right: -0.5rem; margin-left: -0.5rem; }
.g-2 > * { padding-right: 0.5rem; padding-left: 0.5rem; }
.g-3 { margin-right: -0.75rem; margin-left: -0.75rem; }
.g-3 > * { padding-right: 0.75rem; padding-left: 0.75rem; margin-bottom: 1rem; }
.g-4 { margin-right: -1rem; margin-left: -1rem; }
.g-4 > * { padding-right: 1rem; padding-left: 1rem; margin-bottom: 1.25rem; }

.col-12 { flex: 0 0 100%; max-width: 100%; }

@media (min-width: 768px) {
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
}

.d-flex { display: flex !important; }
.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }
.align-items-start { align-items: flex-start !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-column { flex-direction: column !important; }
.w-100 { width: 100% !important; }

.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }

.m-0 { margin: 0 !important; }
.p-0 { padding: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 2rem !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-5 { padding-top: 2rem !important; padding-bottom: 2rem !important; }

.text-muted { color: #94a3b8 !important; }
.text-success { color: #34d399 !important; }
.text-danger { color: #f87171 !important; }
.text-center { text-align: center !important; }

/* =========================================================
   SISTEMA DE MODALES UNIFICADO (DARK GLASSMORPHISM)
   ========================================================= */
.modal-backdrop,
.modal-backdrop-custom {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 4, 10, 0.82) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    box-sizing: border-box;
}

.modal-card,
.modal-content,
.modal-content-custom,
.modal-dialog-custom .modal-card-box {
    background: rgba(18, 20, 32, 0.96) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 22px !important;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65) !important;
    color: #f8fafc !important;
    max-width: 680px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-sizing: border-box;
}

.modal-header,
.modal-header-custom,
.modal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.02) !important;
}

.modal-header h5,
.modal-header-custom strong,
.modal-card-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f8fafc;
}

.modal-body,
.modal-body-custom,
.modal-card-body {
    padding: 22px 24px !important;
    color: #cbd5e1;
}

.modal-footer,
.modal-footer-custom {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 16px 24px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.02) !important;
}

.btn-close-modal {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #f1f5f9 !important;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-close-modal:hover {
    background: rgba(239, 68, 68, 0.25) !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
}

/* =========================================================
   DESACTIVAR BARRA STICKY DUPLICADA EN SUBPÁGINAS
   ========================================================= */
.header-sticky {
    position: static !important;
    top: auto !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    padding: 0 0 16px 0 !important;
    min-height: auto !important;
    margin: 0 0 20px 0 !important;
}

.header-sticky .btn-back {
    display: none !important; /* Ocultar el botón Volver duplicado */
}

/* =========================================================
   MODO CLARO (LIGHT THEME) OVERRIDES PARA CONTROLES GLOBALES
   ========================================================= */
.theme-light input[type="text"],
.theme-light input[type="number"],
.theme-light input[type="password"],
.theme-light input[type="email"],
.theme-light input[type="search"],
.theme-light input[type="date"],
.theme-light input[type="datetime-local"],
.theme-light select,
.theme-light textarea,
.theme-light .form-control,
.theme-light .form-select,
.theme-light .custom-input,
.theme-light .custom-search-input,
.theme-light .custom-select,
.theme-light .dark-input,
.theme-light .form-input {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

.theme-light input:focus,
.theme-light select:focus,
.theme-light textarea:focus,
.theme-light .form-control:focus,
.theme-light .form-select:focus,
.theme-light .custom-input:focus,
.theme-light .custom-search-input:focus,
.theme-light .custom-select:focus,
.theme-light .dark-input:focus,
.theme-light .form-input:focus {
    border-color: #d41e5e !important;
    background-color: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(212, 30, 94, 0.15) !important;
}

.theme-light select option {
    background-color: #ffffff;
    color: #0f172a;
}

.theme-light .form-label {
    color: #334155 !important;
}

.theme-light .modal-card,
.theme-light .modal-content,
.theme-light .modal-content-custom,
.theme-light .modal-dialog-custom .modal-card-box {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15) !important;
    color: #0f172a !important;
}

.theme-light .modal-header,
.theme-light .modal-header-custom,
.theme-light .modal-card-header {
    background: #f8fafc !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}

.theme-light .modal-header h5,
.theme-light .modal-header-custom strong,
.theme-light .modal-card-header h3 {
    color: #0f172a !important;
}

.theme-light .modal-body,
.theme-light .modal-body-custom,
.theme-light .modal-card-body {
    color: #334155 !important;
}

.theme-light .modal-footer,
.theme-light .modal-footer-custom {
    background: #f8fafc !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
}

.theme-light .btn-close-modal {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: #0f172a !important;
}

/* === BLAZOR ERROR UI === */
#blazor-error-ui {
    background: #1e111a;
    color: #ff99bb;
    border-top: 2px solid #D41E5E;
    bottom: 0;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5);
    display: none;
    left: 0;
    padding: 0.85rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
    font-size: 0.9rem;
}

#blazor-error-ui .reload {
    color: #fff;
    margin-left: 1rem;
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1.5rem;
    top: 0.85rem;
    color: #fff;
}