/* ==========================================
   ESTILOS BASE LUXURY (SAAS / APPLE AESTHETIC)
   ========================================== */
html,
body {
    height: 100%;
    background-color: #fcfcfd !important;
    /* Blanco roto premium */
    color: #0f172a;
    overflow: hidden;
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6,
.font-black,
.font-heading {
    font-family: 'Outfit', sans-serif !important;
    letter-spacing: -0.02em;
    /* Tipografía más compacta y moderna */
}

/* Scrollbar estilo macOS */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* Paneles de Cristal (Glassmorphism Sutil) */
.glass-panel {
    background: rgba(252, 252, 253, 0.85) !important;
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
}

.bg-white {
    background-color: #ffffff !important;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.03), 0 0 1px rgba(15, 23, 42, 0.06) !important;
    border: 1px solid rgba(226, 232, 240, 0.5) !important;
}

/* Transiciones Suaves Globales */
button,
a,
input,
select {
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

button.bg-slate-900:hover,
button.bg-primary-900:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px -4px rgba(15, 23, 42, 0.2);
}

/* Animaciones Fluidas */
.fade-in {
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.slide-up {
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.fade-in-up {
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Gestión de Vistas (SPA) */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

/* Contenedor de Alertas (Toasts) */
#toast-container {
    z-index: 999999;
    pointer-events: none;
}

.toast {
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateY(-20px);
    opacity: 0;
    pointer-events: auto;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Pantalla de Carga (Loader) */
#global-loader {
    z-index: 999999;
    background: #0f172a;
}

.spinner {
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 0.8s cubic-bezier(0.6, 0.2, 0.4, 0.8) infinite;
    width: 24px;
    height: 24px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Estilos del Login (Removida la imagen genérica, usamos un gradiente mesh sutil) */
.login-bg {
    background-color: #f8fafc;
    background-image:
        radial-gradient(at 0% 0%, hsla(220, 30%, 95%, 1) 0, transparent 50%),
        radial-gradient(at 100% 100%, hsla(220, 30%, 90%, 1) 0, transparent 50%);
}

.login-glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.08), 0 0 1px rgba(15, 23, 42, 0.05);
}

/* Sidebar Móvil */
.sidebar-overlay {
    display: none;
    background: rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    position: fixed;
    inset: 0;
    z-index: 40;
}

.sidebar-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    .mobile-sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 50;
    }

    .mobile-sidebar.open {
        transform: translateX(0);
    }
}

/* Pestañas de Control Segmentado (Estilo iOS Premium) */
.tabs-container {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-btn:hover {
    color: #0f172a;
}

.tab-btn.active {
    background-color: #ffffff !important;
    color: #0f172a !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02) !important;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================
   UX/UI REFINEMENTS
   ========================================== */
html {
    scroll-behavior: smooth;
}

/* Etiquetas de estado inquebrantables */
td span.uppercase {
    white-space: nowrap !important;
    display: inline-block !important;
    margin-bottom: 2px;
}

/* Ajustes de Tipografía Global */
.font-black {
    font-weight: 700 !important;
}

.tracking-widest {
    letter-spacing: 0.06em !important;
}

/* Bordes unificados ultra finos */
.border,
.border-b,
.border-t,
.border-l,
.border-r {
    border-color: rgba(226, 232, 240, 0.6) !important;
}

/* Form inputs estilo Apple */
input:focus,
select:focus,
textarea:focus {
    box-shadow: 0 0 0 2px rgba(226, 232, 240, 1), 0 4px 12px rgba(15, 23, 42, 0.03) !important;
    border-color: transparent !important;
}

/* Optimizaciones Móviles (< 768px) */
@media (max-width: 768px) {

    button,
    select,
    input,
    textarea,
    .tab-btn {
        min-height: 44px !important;
    }

    .modal-mobile-safe {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        height: -webkit-fill-available !important;
        max-height: -webkit-fill-available !important;
        border-radius: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ==========================================
   NUEVOS ESTILOS PROFESIONALES (B2B SWITCH)
   ========================================== */

/* Switch estilo iOS (Profesional y sutil) */
.b2b-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}

.b2b-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.b2b-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(148, 163, 184, 0.3);
    transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 34px;
}

.b2b-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

input:checked+.b2b-slider {
    background-color: #0f172a;
}

input:checked+.b2b-slider:before {
    transform: translateX(14px);
}

/* Estado bloqueado de inputs en Master Panel */
#master-aliado-info-fields input[readonly] {
    background-color: #fcfcfd !important;
    border-color: rgba(226, 232, 240, 0.5) !important;
    cursor: default;
    box-shadow: none !important;
}
