/* ERP BL Plugin Styles */

/* Reset específico para el plugin */
#erp-bl-container {
    position: relative;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    overflow: hidden;
    box-sizing: border-box;
    max-width: none !important;
}

#erp-bl-container *,
#erp-bl-container *::before,
#erp-bl-container *::after {
    box-sizing: border-box;
}

/* Contenedor principal de la aplicación */
.erp-bl-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    position: relative;
    margin: 0 !important;
    padding: 0 !important;
}

/* Header */
.erp-header {
    background: linear-gradient(135deg, #4a0f1f 0%, #2d0a12 100%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 1000;
}

.erp-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 70px;
    max-width: 100%;
    min-height: 70px;
    position: relative;
}

/* Logo */
.erp-logo {
    display: flex;
    flex-direction: column;
    color: white;
    min-width: 200px;
}

.erp-logo h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1;
}

.erp-subtitle {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.9;
    margin-top: 2px;
    line-height: 1;
}

/* Navegación */
.erp-nav {
    display: flex;
    gap: 8px;
    flex: 1;
    justify-content: center;
    max-width: 800px;
    margin: 0 20px;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 60px;
    padding: 0 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.erp-nav::-webkit-scrollbar {
    display: none;
}

.erp-nav-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    min-width: 120px;
    backdrop-filter: blur(10px);
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0;
    justify-content: center;
    text-align: center;
}

.erp-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.erp-nav-btn.active {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.erp-nav-btn:active {
    transform: translateY(0);
    transition: transform 0.1s ease;
}

.erp-nav-btn i {
    font-size: 16px;
    margin-right: 6px;
}

.erp-nav-btn span {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.2;
}

/* Acciones del header */
.erp-header-actions {
    display: flex;
    gap: 8px;
    min-width: 260px;
    justify-content: flex-end;
    align-items: center;
}

/* Información del usuario */
.erp-user-info {
    display: flex;
    align-items: center;
    margin-right: 16px;
    padding: 4px 8px;
    order: 0;
}

.erp-username {
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
}

.erp-action-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.erp-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.erp-action-btn.logout-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.erp-action-btn.logout-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: scale(1.05);
}



.erp-action-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

.erp-action-btn i {
    font-size: 16px;
}

/* Orden de botones */
#erp-refresh-btn {
    order: 2;
}

#erp-fullscreen-btn {
    order: 3;
}

#erp-logout-btn {
    order: 4;
}

/* Contenido principal */
.erp-main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    height: calc(100% - 70px - 32px); /* Altura total menos header y status bar */
}

.erp-iframe-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: white;
}

#erp-main-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    transition: opacity 0.3s ease;
}

/* Contenedor para shortcodes */
.erp-shortcode-content {
    width: 100%;
    height: 100%;
    padding: 20px;
    background: white;
    overflow-y: auto;
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
}

.erp-shortcode-content.active {
    display: block !important;
}

/* Estilos para mensajes de error en shortcodes */
.erp-shortcode-content .error {
    background: #fee;
    border: 1px solid #fbb;
    border-radius: 8px;
    padding: 20px;
    margin: 20px;
    text-align: center;
}

.erp-shortcode-content .error p {
    color: #d63031;
    margin: 0;
    font-weight: 500;
}

/* Loading */
.erp-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.erp-loading.show {
    opacity: 1;
    visibility: visible;
}

.erp-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: erp-spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes erp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.erp-loading p {
    color: #64748b;
    font-weight: 500;
    margin: 0;
}

/* Barra de estado */
.erp-status-bar {
    background: #1e293b;
    color: #cbd5e1;
    padding: 8px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    height: 32px;
    flex-shrink: 0;
}

.erp-status-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.erp-separator {
    opacity: 0.5;
}

.erp-timestamp {
    font-family: monospace;
    opacity: 0.7;
}

/* Estados de carga */
.erp-iframe-container.loading #erp-main-frame {
    opacity: 0.7;
}

/* Efectos visuales adicionales */
.erp-header {
    position: relative;
}

.erp-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

/* Responsive */
@media (max-width: 768px) {
    .erp-header-content {
        padding: 0 16px;
        height: 60px;
    }
    
    /* Ocultar el logo desktop por completo en móvil */
    .erp-logo {
        display: none !important;
    }
    
    .erp-logo h1 {
        font-size: 20px;
    }
    
    .erp-subtitle {
        font-size: 10px;
    }
    
    .erp-nav {
        gap: 4px;
        margin: 0 10px;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0 5px;
        min-height: 50px;
    }
    
    .erp-nav-btn {
        padding: 8px 12px;
        min-width: 80px;
        font-size: 12px;
        flex-shrink: 0;
    }
    
    .erp-nav-btn i {
        font-size: 16px;
    }
    
    .erp-nav-btn span {
        font-size: 10px;
    }
    
    .erp-status-bar {
        padding: 6px 16px;
        font-size: 11px;
    }
    
    .erp-main-content {
        height: calc(100% - 60px - 32px);
    }
}

@media (max-width: 480px) {
    .erp-header-content {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
    }
    
    .erp-logo {
        width: 100%;
        text-align: center;
        margin-bottom: 12px;
        min-width: auto;
    }
    
    .erp-nav {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: nowrap;
        margin: 0;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0 5px;
    }
    
    .erp-header-actions {
        position: absolute;
        top: 12px;
        right: 16px;
        min-width: 220px;
        gap: 6px;
    }
    
    .erp-main-content {
        height: calc(100% - 90px - 32px);
    }
}

/* Integración con WordPress */
.erp-bl-app {
    font-size: 14px;
    line-height: 1.4;
}

/* Sobrescribir estilos de WordPress que puedan interferir */
#erp-bl-container button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
    outline: inherit;
}

#erp-bl-container h1 {
    margin: 0;
    padding: 0;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    color: inherit;
}

/* Forzar ancho completo */
.post #erp-bl-container,
.single #erp-bl-container,
article #erp-bl-container,
.entry-content #erp-bl-container,
.site-content #erp-bl-container,
.content-area #erp-bl-container,
.page #erp-bl-container,
.entry #erp-bl-container {
    width: 100vw !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
}

/* Override de temas que puedan limitar el ancho */
.container #erp-bl-container,
.wrapper #erp-bl-container,
.content #erp-bl-container,
.main #erp-bl-container {
    width: 100vw !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    position: relative !important;
}

/* Asegurar que el contenedor no sea afectado por estilos del theme */
#erp-bl-container {
    all: initial;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    position: relative !important;
    width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: #f8fafc;
    color: #1e293b;
    overflow: hidden;
    box-sizing: border-box;
    display: block;
    max-width: none !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
}

/* Forzar que los elementos padre no restrinjan el ancho */
*:has(#erp-bl-container) {
    max-width: none !important;
}

/* Estilos para hacer el contenedor verdaderamente full-width */
.erp-fullwidth-force {
    position: relative !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    width: 100vw !important;
    max-width: 100vw !important;
}

/* Centrado específico para WordPress */
.wp-site-blocks #erp-bl-container,
.has-global-padding #erp-bl-container,
.wp-block-group #erp-bl-container {
    width: 100vw !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    position: relative !important;
}

/* Eliminar cualquier padding de contenedores padre */
#erp-bl-container {
    transform: translateX(0) !important;
}

/* Forzar posicionamiento absoluto si es necesario */
.erp-force-center {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
}

/* Ocultar completamente elementos de WordPress cuando ERP está activo */
body:has(#erp-bl-container) header:not(.erp-header),
body:has(#erp-bl-container) .site-header,
body:has(#erp-bl-container) footer:not(.erp-status-bar),
body:has(#erp-bl-container) .site-footer,
body:has(#erp-bl-container) nav:not(.erp-nav),
body:has(#erp-bl-container) .navigation:not(.erp-nav),
body:has(#erp-bl-container) aside,
body:has(#erp-bl-container) .sidebar,
body:has(#erp-bl-container) .breadcrumb,
body:has(#erp-bl-container) .entry-title,
body:has(#erp-bl-container) .page-title {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Forzar contenido principal a pantalla completa cuando ERP está presente */
body:has(#erp-bl-container) {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    height: 100vh !important;
}

body:has(#erp-bl-container) #primary,
body:has(#erp-bl-container) .site-main,
body:has(#erp-bl-container) #main,
body:has(#erp-bl-container) .content-area,
body:has(#erp-bl-container) .site-content,
body:has(#erp-bl-container) .entry-content,
body:has(#erp-bl-container) .page-content {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 100vh !important;
}

/* Asegurar que admin bar esté oculta */
html:has(#erp-bl-container) {
    margin-top: 0 !important;
}

#wpadminbar {
    display: none !important;
}

.admin-bar body:has(#erp-bl-container) {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* =====================================
   RESPONSIVE DESIGN - MOBILE STYLES
   ===================================== */

/* Mobile Menu Lines - Integradas en el header */
.erp-mobile-menu-lines {
    display: none;
    flex-direction: column;
    width: 20px;
    height: 14px;
    justify-content: space-between;
    cursor: pointer;
    padding: 2px 0;
    transition: all 0.3s ease;
    z-index: 1001;
    position: relative;
}

/* Logo móvil - Oculto por defecto */
.erp-logo-mobile {
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1002;
}

.erp-logo-mobile i {
    font-size: 18px;
    color: #f59e0b;
}

.erp-logo-mobile span {
    font-weight: 600;
    color: white;
}

.erp-mobile-menu-lines span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: white;
    border-radius: 1px;
    transition: all 0.3s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.erp-mobile-menu-lines:hover span {
    background-color: #f59e0b;
    box-shadow: 0 1px 6px rgba(245, 158, 11, 0.4);
}

/* Animación del hamburguesa cuando está activo */
.erp-mobile-menu-lines.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
    background-color: #f59e0b;
}

.erp-mobile-menu-lines.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.erp-mobile-menu-lines.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
    background-color: #f59e0b;
}

.erp-mobile-menu-lines.active:hover span:nth-child(1),
.erp-mobile-menu-lines.active:hover span:nth-child(3) {
    background-color: #fbbf24;
}

/* Mobile Navigation Overlay */
.erp-mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.erp-mobile-nav.active {
    opacity: 1;
    visibility: visible;
}

.erp-mobile-nav-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: linear-gradient(135deg, #4a0f1f 0%, #2d0a12 100%);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.erp-mobile-nav.active .erp-mobile-nav-content {
    transform: translateX(0);
}

.erp-mobile-nav-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.erp-mobile-logo {
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.erp-mobile-logo i {
    font-size: 24px;
    color: #f59e0b;
}

.erp-mobile-logo span {
    font-size: 18px;
    font-weight: 600;
}

.erp-mobile-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

.erp-mobile-nav-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.erp-mobile-nav-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.erp-mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    transition: all 0.2s ease;
}

.erp-mobile-nav-link:hover,
.erp-mobile-nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.erp-mobile-nav-link i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.erp-mobile-nav-link span {
    font-weight: 500;
}

.erp-mobile-user-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.erp-mobile-username {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    margin-bottom: 10px;
}

.erp-mobile-actions {
    display: flex;
    gap: 10px;
}

.erp-mobile-action-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-align: center;
    transition: all 0.2s ease;
}

.erp-mobile-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Media Queries */
@media (max-width: 768px) {
    /* Header móvil compacto */
    .erp-header-content {
        height: 50px;
        padding: 0 16px;
        min-height: 50px;
        position: relative;
        z-index: 1001;
    }
    
    /* Ocultar logo desktop en móvil */
    .erp-logo {
        display: none !important;
    }
    
    /* Mostrar logo móvil */
    .erp-logo-mobile {
        display: flex !important;
    }
    
    /* Ocultar navegación desktop */
    .erp-nav {
        display: none;
    }
    
    /* Ocultar acciones desktop */
    .erp-header-actions {
        display: none;
    }
    
    /* Mostrar líneas de menú móvil */
    .erp-mobile-menu-lines {
        display: flex !important;
        position: absolute !important;
        left: 16px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }
    
    /* Mostrar navegación móvil */
    .erp-mobile-nav {
        display: block !important;
    }
    
    /* Ajustar contenido principal */
    .erp-main-content {
        height: calc(100vh - 50px);
    }
    
    .erp-iframe-container {
        height: 100%;
    }
    
    #erp-main-frame {
        height: 100%;
    }
    
    /* Ocultar barra de estado en móvil */
    .erp-status-bar {
        display: none;
    }
    
    /* Ajustar loading */
    .erp-loading {
        top: 50px;
        height: calc(100vh - 50px);
    }
}

@media (max-width: 480px) {
    /* Header aún más compacto */
    .erp-header-content {
        height: 45px;
        padding: 0 12px;
        min-height: 45px;
    }
    
    .erp-main-content {
        height: calc(100vh - 45px);
    }
    
    .erp-loading {
        top: 45px;
        height: calc(100vh - 45px);
    }
    
    /* Menú móvil más estrecho */
    .erp-mobile-nav-content {
        width: 250px;
    }
}

/* Prevenir scroll cuando menú móvil está abierto */
body.mobile-menu-open {
    overflow: hidden !important;
    height: 100vh !important;
}

/* Optimizaciones adicionales para dispositivos móviles */
.erp-mobile-device .erp-iframe-container {
    -webkit-overflow-scrolling: touch;
}

.erp-mobile-device #erp-main-frame {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
}

/* Animaciones más suaves en móvil */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    .erp-mobile-nav-link:active {
        background: rgba(255, 255, 255, 0.15) !important;
    }
    
    .erp-mobile-action-btn:active {
        background: rgba(255, 255, 255, 0.25) !important;
    }
}
