/* ===== PASTOR THEME - Clean Bootstrap Structure with Anthracite Colors ===== */


/* Global Reset and Full Width */
* {
    box-sizing: border-box;
}

html {
    height: 100% !important;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: white;
    min-height: 100% !important;
    color: #2d3748;
}

/* Text hierarchy for readability */
h1, h2, h3, h4, h5, h6 {
    color: #1a202c;
    font-weight: 700;
    margin-bottom: 15px;
}

h1 {
    color: #1a202c;
    font-size: 2.5rem;
}

h2 {
    color: #2d3748;
    font-size: 2rem;
}

h3 {
    color: #2d3748;
    font-size: 1.5rem;
}

h4, h5, h6 {
    color: #4a5568;
    font-size: 1.25rem;
}

/* Paragraph and general text */
p, div, span, td, th {
    color: #4a5568;
}

/* Strong text for emphasis */
strong, b {
    color: #2d3748;
    font-weight: 600;
}

/* Return/Back buttons - high z-index and black text */
.btn:contains("Volver"),
.btn:contains("volver"),
.btn:contains("Back"),
.btn:contains("back"),
.btn:contains("Return"),
.btn:contains("return"),
a[href*="back"],
a[href*="volver"],
.btn-secondary,
.btn-default,
button:contains("Volver"),
button:contains("volver"),
button:contains("Back"),
button:contains("back") {
    z-index: 1000 !important;
    color: #000 !important;
    background-color: #f8f9fa !important;
    border-color: #dee2e6 !important;
    position: relative !important;
    font-weight: 600 !important;
}

/* Additional styling for back/return buttons */
.btn-secondary:hover,
.btn-default:hover,
button:contains("Volver"):hover,
button:contains("volver"):hover {
    background-color: #e9ecef !important;
    color: #000 !important;
}

/* Links */
a {
    color: #2c3e50;
    text-decoration: none;
}

a:hover {
    color: #34495e;
    text-decoration: underline;
}

/* Container inside main-menu - anthracite background */
#main-menu .container,
#main-menu .container-fluid {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
}

/* Content containers - centered at screen middle */
#main-content .container,
#main-content .container-fluid {
    width: 100% !important;
    max-width: 100% !important;
    height: calc(100vh - 400px) !important;
    margin: auto !important;
    padding: 20px !important;
    background: rgba(255,255,255,0.95) !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    border-radius: 15px !important;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1) !important;
}

/* Content inside the container - 95% width */
#main-content .container > *,
#main-content .container-fluid > * {
    width: 95% !important;
    max-width: 95% !important;
}

/* Other containers - clean styling */
.container,
.container-fluid {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Page wrapper - Contenedor principal */
#page-wrapper {
    width: 100% !important;
    min-height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Main body structure - Max width 1400px centered */
#main-body {
    width: 100% !important;
    max-width: 1400px !important;
    margin: 0 auto;
    padding: 0;
    min-height: calc(100vh - 60px) !important; /* Viewport menos footer exacto */
    overflow: visible !important; /* Permitir que los dropdowns se vean */
}

/* ===== NAVBAR STRUCTURE ===== */

/* Main menu container - Max width 1400px centered */
#main-menu {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    margin-bottom: 0 !important; /* No margin bottom to connect with submenu */
    padding: 0;
    padding-bottom: 0 !important; /* No padding bottom */
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    box-shadow: 0 4px 15px rgba(44, 62, 80, 0.4);
    z-index: 1000 !important; /* Alto z-index para navbar */
    position: relative !important;
}

/* Navbar header flex container */
.navbar-header {
    display: flex !important;
    justify-content: flex-start !important; /* Start from left */
    align-items: center !important;
    width: 100% !important;
    padding: 0 !important; /* Remove padding to reach edges */
}

.navbar-header-left {
    display: flex !important;
    align-items: center !important;
    padding-left: 15px !important; /* Padding on the left edge */
}

.navbar-header-right {
    display: flex !important;
    align-items: center !important;
    gap: 20px !important;
    color: white !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    margin-left: auto !important; /* Push to the far right */
    padding-right: 15px !important; /* Padding on the right edge */
}

.navbar-user,
.navbar-credit {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    color: white !important;
}

.navbar-user .glyphicon,
.navbar-credit .glyphicon {
    color: white !important;
    margin-right: 5px !important;
}

#navbar-credit-show {
    color: #4CAF50 !important; /* Green for credit */
    font-weight: bold !important;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    margin-bottom: 0 !important; /* Ensure no bottom margin */
    padding: 0 !important;
    padding-bottom: 0 !important; /* Ensure no bottom padding */
    z-index: 1000 !important;
    position: relative;
    min-height: 60px;
    width: 100%;
    overflow: visible !important; /* Permitir dropdowns visibles */
}

.navbar-inner {
    width: 100% !important;
    padding: 0 15px !important;
    margin: 0 !important;
}

/* Navbar Header */
.navbar-header {
    width: 100%;
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    z-index: 1000;
    position: relative;
    min-height: 60px;
}

/* Brand */
.navbar-brand {
    color: white !important;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    margin: 0;
    padding: 15px 20px;
    text-decoration: none;
    flex-shrink: 0;
}

.navbar-brand:hover,
.navbar-brand:focus {
    color: rgba(255,255,255,0.8) !important;
    text-decoration: none;
}

/* Toggle button for mobile */
.navbar-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    padding: 9px 10px;
    margin: 8px 0;
}

.navbar-toggle .icon-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 1px;
    margin: 0 0 4px;
}

/* Navbar Collapse */
.navbar-collapse {
    display: flex !important;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 0;
    min-height: 60px;
}

/* Main Navigation */
.navbar-nav {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
    min-height: 60px;
}

.navbar-nav > li {
    display: flex;
    align-items: center;
    margin: 0;
    min-height: 60px;
}

.navbar-nav > li > a {
    color: rgba(255,255,255,0.9) !important;
    font-weight: 600;
    transition: all 0.3s ease;
    padding: 20px 15px;
    display: flex;
    align-items: center;
    text-decoration: none;
    min-height: 60px;
}

.navbar-nav > li > a:hover,
.navbar-nav > li > a:focus {
    color: white !important;
    background: rgba(255,255,255,0.1) !important;
    border-radius: 6px;
    text-decoration: none;
}

.navbar-nav > .active > a,
.navbar-nav > .active > a:hover,
.navbar-nav > .active > a:focus {
    background: rgba(255,255,255,0.2) !important;
    border-radius: 6px;
    color: white !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Navbar Right - Extended with credit info */
.navbar-right {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
    min-height: 60px;
    gap: 20px;
    margin-left: 20px;
    justify-content: flex-start;
    z-index: 1100 !important; /* Ensure visibility above other elements */
    position: relative !important;
}

/* Ensure logout/return link is visible */
.navbar-right > li > a[href*="logout"] {
    z-index: 1200 !important;
    position: relative !important;
    display: inline-block !important;
    visibility: visible !important;
}

.navbar-right > li > a[href*="logout"] span {
    z-index: 1200 !important;
    color: #ff6b47 !important;
    display: inline-block !important;
}

/* Credit and user info in navbar */
.navbar-credit-info {
    color: rgba(255,255,255,0.8);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 15px;
    text-align: left;
    margin-left: -20px;
}

/* User name - white text */
.navbar-credit-info .username,
.navbar-credit-info [class*="user"],
.navbar-credit-info span:first-child {
    color: #ffffff !important;
    font-weight: 600;
}

/* Credit amount - light gray text */
.navbar-credit-info .credit,
.navbar-credit-info [class*="credit"],
.navbar-credit-info span:last-child {
    color: rgba(255,255,255,0.6) !important;
    font-weight: 400;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.2);
}

#submenu-credit-show {
    color: rgba(255,255,255,0.9);
    font-weight: 600;
}

/* Dropdown Menus */
.dropdown-menu {
    background: rgba(255,255,255,0.95);
    border: none;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
    padding: 8px;
    margin-top: 5px !important; /* Small gap from trigger */
    z-index: 9999 !important; /* Alto z-index para estar encima de todo */
    position: absolute !important;
}

/* Asegurar que los dropdowns abiertos estén encima */
.dropdown.open,
.nav li.dropdown.open {
    z-index: 9998 !important;
}

.dropdown-menu > li > a {
    color: #4a5568;
    border-radius: 6px;
    margin: 2px 0;
    transition: all 0.3s ease;
    padding: 8px 15px;
}

.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    text-decoration: none;
}

.dropdown-menu .divider {
    height: 1px;
    margin: 8px 0;
    background: rgba(0,0,0,0.1);
}

/* ===== SUBMENU REMOVED - main-submenu no longer in use ===== */

/* Main-submenu styles removed - no longer in use */

/* Main-submenu logout styles removed - submenu no longer exists */

/* JavaScript for main-submenu removed - submenu no longer exists */
</style>
<script>

// Force dashboard visibility
document.addEventListener('DOMContentLoaded', function() {
    setTimeout(function() {
        // Force dashboard elements to be visible
        var dashboardWrapper = document.querySelector('#graf, .dashboard-wrapper');
        var dashboardContainer = document.querySelector('#dashboard-container');
        var chartsContainer = document.querySelector('#charts-container, .charts-container');
        
        if (dashboardWrapper) {
            dashboardWrapper.style.setProperty('display', 'flex', 'important');
            dashboardWrapper.style.setProperty('visibility', 'visible', 'important');
            dashboardWrapper.style.setProperty('opacity', '1', 'important');
            dashboardWrapper.style.setProperty('position', 'fixed', 'important');
            dashboardWrapper.style.setProperty('top', '53px', 'important'); /* Just below menu */
            dashboardWrapper.style.setProperty('left', '50%', 'important');
            dashboardWrapper.style.setProperty('transform', 'translateX(-50%)', 'important');
            dashboardWrapper.style.setProperty('height', 'calc(100vh - 113px)', 'important');
            dashboardWrapper.style.setProperty('width', '90%', 'important');
            dashboardWrapper.style.setProperty('max-width', '1260px', 'important');
            dashboardWrapper.style.setProperty('flex-direction', 'column', 'important');
            dashboardWrapper.style.setProperty('z-index', '100', 'important');
            dashboardWrapper.style.setProperty('background', 'white', 'important');
            dashboardWrapper.style.setProperty('padding', '20px', 'important');
            dashboardWrapper.style.setProperty('box-sizing', 'border-box', 'important');
        }
        
        if (dashboardContainer) {
            dashboardContainer.style.display = 'block';
            dashboardContainer.style.visibility = 'visible';
            dashboardContainer.style.opacity = '1';
            dashboardContainer.style.height = 'auto';
            dashboardContainer.style.minHeight = '400px';
        }
        
        if (chartsContainer) {
            chartsContainer.style.display = 'block';
            chartsContainer.style.visibility = 'visible';
            chartsContainer.style.opacity = '1';
            chartsContainer.style.height = 'auto';
            chartsContainer.style.minHeight = '400px';
        }
        
        // Only make the active chart slide visible
        var chartSlides = document.querySelectorAll('.chart-slide');
        chartSlides.forEach(function(slide) {
            if (slide.classList.contains('active')) {
                slide.style.setProperty('display', 'flex', 'important');
                slide.style.setProperty('visibility', 'visible', 'important');
            } else {
                slide.style.setProperty('display', 'none', 'important');
                slide.style.setProperty('visibility', 'hidden', 'important');
            }
        });
        
        // Force any canvas elements to be visible
        var canvases = document.querySelectorAll('canvas[id*="chart"], canvas[id*="canvas"]');
        canvases.forEach(function(canvas) {
            canvas.style.setProperty('display', 'block', 'important');
            canvas.style.setProperty('visibility', 'visible', 'important');
        });
        
        console.log('Dashboard visibility forced - Elements found:', {
            wrapper: !!dashboardWrapper,
            container: !!dashboardContainer, 
            charts: !!chartsContainer,
            slides: chartSlides.length,
            canvases: canvases.length
        });
    }, 100);
    
    // Also try after longer delays
    setTimeout(function() {
        var allElements = document.querySelectorAll('.dashboard-wrapper, #dashboard-container, .charts-container, .chart-slide, canvas[id*="chart"]');
        allElements.forEach(function(el) {
            el.style.setProperty('display', el.tagName === 'CANVAS' ? 'block' : 'flex', 'important');
            el.style.setProperty('visibility', 'visible', 'important');
            el.style.setProperty('opacity', '1', 'important');
        });
        console.log('Second dashboard visibility pass - Elements forced:', allElements.length);
    }, 1000);
    
    // Force logout button color
    function forceLogoutColor() {
        var logoutLinks = document.querySelectorAll('a[href*="logout"], .logout, .sign-out');
        logoutLinks.forEach(function(link) {
            link.style.setProperty('color', '#ff6b47', 'important');
            var icon = link.querySelector('i');
            if (icon) {
                icon.style.setProperty('color', '#ff6b47', 'important');
            }
        });
        
        // Also target specific icon classes
        var logoutIcons = document.querySelectorAll('.fa-sign-out, .fa-sign-out-alt, .glyphicon-log-out, i[class*="logout"], i[class*="sign-out"]');
        logoutIcons.forEach(function(icon) {
            icon.style.setProperty('color', '#ff6b47', 'important');
        });
    }
    
    // Apply logout color multiple times
    forceLogoutColor();
    setTimeout(forceLogoutColor, 500);
    setTimeout(forceLogoutColor, 1000);
});
</script>
<style>

/* ===== DASHBOARD/WELCOME PAGE FIXES ===== */

/* Dashboard wrapper adjustments for Pastor theme - TOP OF SCREEN */
#graf {
    position: fixed !important;
    top: 53px !important; /* Just below the menu */
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 90% !important;
    max-width: 1260px !important;
    height: calc(100vh - 113px) !important; /* Full height minus menu and footer */
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 100 !important;
    background: white !important;
    padding: 20px !important;
    padding-bottom: 80px !important; /* Extra padding for controls */
    box-sizing: border-box !important;
}

/* Fallback for dashboard-wrapper class */
body .dashboard-wrapper,
html .dashboard-wrapper,
.dashboard-wrapper,
div[class*="dashboard-wrapper"],
*[class*="dashboard-wrapper"] {
    position: fixed !important;
    top: 53px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    overflow: visible !important;
    margin: 0 !important;
    height: calc(100vh - 113px) !important;
    min-height: calc(100vh - 113px) !important;
    width: 90% !important;
    max-width: 1260px !important;
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 100 !important;
}

/* Dashboard container visibility */
#dashboard-container {
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 10 !important;
    height: 100% !important;
    min-height: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 20px !important;
    flex-grow: 1 !important;
}

.dashboard-flex {
    height: 100% !important;
    width: 100% !important;
    flex-grow: 1 !important;
}

.charts-layer {
    height: 100% !important;
    width: 100% !important;
    min-height: 100% !important;
    flex-grow: 1 !important;
}

/* Charts container visibility and positioning */
.charts-container,
#charts-container {
    display: block !important;
    visibility: visible !important;
    height: 400px !important;
    min-height: 400px !important;
    width: 100% !important;
    position: relative !important; /* Essential for absolute positioned slides */
    overflow: hidden !important; /* Hide non-active slides */
    flex-grow: 1 !important;
}

/* Chart slides visibility */
.chart-slide {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1 !important;
}

.chart-slide.active {
    display: flex !important;
    visibility: visible !important;
    z-index: 10 !important;
}

/* Ensure Toast UI charts fill their container */
.chart-slide > div[id^="toast-chart"] {
    width: 100% !important;
    height: 100% !important;
}

/* Welcome page specific adjustments */
body.home .dashboard-wrapper,
[data-page="home"] .dashboard-wrapper,
.page-home .dashboard-wrapper {
    position: relative !important;
    top: 0 !important;
    left: auto !important;
    right: auto !important;
    margin: 0 auto !important;
    padding-top: 0 !important;
    height: calc(100vh - 120px) !important;
    width: 90% !important; /* 90% of available width */
    max-width: 1260px !important; /* 90% of 1400px */
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    transform: none !important;
}

/* Override any inline styles from welcome template */
.dashboard-wrapper[style*="position"],
.dashboard-wrapper[style*="top"],
.dashboard-wrapper[style*="bottom"] {
    position: static !important;
    top: auto !important;
    bottom: auto !important;
    height: auto !important;
}

/* Force all dashboard elements visible regardless of source */
*[class*="dashboard"],
*[id*="dashboard"],
*[class*="chart"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

canvas[id*="chart"],
canvas[id*="canvas"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 300px !important;
}

/* Fix the dashboard inner div */
.dashboard-wrapper .h-100.d-flex.flex-column,
.dashboard-wrapper > div:first-child {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    min-height: 100% !important;
    height: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 20px !important;
}

.dashboard-wrapper .row.flex-grow-1,
.dashboard-wrapper .row {
    flex-grow: 1 !important;
    width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.dashboard-wrapper .col-md-12.d-flex,
.dashboard-wrapper .col-md-12 {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
}

/* ===== DASHBOARD CHART CONTROLS - INSIDE GRAF ===== */

#dashboard-chart-controls,
.dashboard-chart-controls {
    position: absolute !important;
    bottom: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    height: 14px !important;
    width: 200px !important; /* Fixed width of 200px */
    display: flex !important;
    justify-content: space-between !important; /* Distribute items across full width */
    align-items: center !important;
    padding: 5px 15px !important; /* Adjusted padding */
    background: rgba(255, 255, 255, 0.95) !important;
    border-radius: 50px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    z-index: 150 !important;
    box-sizing: border-box !important;
}

/* Make chart-indicators flex container to spread indicators */
#dashboard-chart-controls .chart-indicators,
.dashboard-chart-controls .chart-indicators {
    display: flex !important;
    flex: 1 !important; /* Take available space between buttons */
    justify-content: space-evenly !important; /* Distribute indicators evenly */
    align-items: center !important;
    margin: 0 10px !important;
}

#graf #dashboard-chart-controls {
    position: absolute !important;
    bottom: 27px !important; /* Raised 7px from 20px */
    height: 14px !important;
}

/* Logo cliente below charts - centered on home page */
#logocliente {
    position: relative !important;
    margin: 20px auto !important;
    text-align: center !important;
    width: 100% !important;
    max-width: 1400px !important;
    display: block !important;
}

/* Buttons inside dashboard-chart-controls */
#dashboard-chart-controls .marquee-btn,
#dashboard-chart-controls button,
.dashboard-chart-controls .marquee-btn,
.dashboard-chart-controls button {
    height: 12px !important;
    width: 12px !important;
    padding: 0 !important;
    font-size: 10px !important;
    line-height: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background: #667eea !important;
    color: white !important;
    border: none !important;
}

/* Chart indicators inside dashboard-chart-controls */
#dashboard-chart-controls .chart-indicator,
.dashboard-chart-controls .chart-indicator {
    height: 8px !important;
    width: 8px !important;
    border-radius: 50% !important;
}

/* ===== LOGOUT BUTTON COLOR - AGGRESSIVE OVERRIDE ===== */

/* Logout button color - for navbar */
a[href*="logout"] {
    color: #ff6b47 !important;
    background: none !important;
}

a[href*="logout"] i {
    color: #ff6b47 !important;
}

/* Force logout icon color */
.fa-sign-out,
.fa-sign-out-alt,
.glyphicon-log-out,
i[class*="logout"],
i[class*="sign-out"] {
    color: #ff6b47 !important;
}

/* ===== MAIN CONTENT ===== */

/* Main-body flex container adjustments */
#main-body > .container {
    flex: 1 !important; /* Take all available space */
    display: flex !important;
    flex-direction: column !important;
    overflow: visible !important; /* Permitir dropdowns visibles */
}

/* Make main-content fill available space and position below main-menu */
#main-content {
    flex: 1 !important; /* Take remaining space in flex container */
    min-height: 0 !important; /* Allow flex shrinking */
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    margin-top: 0 !important; /* Sin margen para evitar scroll */
    margin-bottom: 0 !important; /* No margin bottom */
    padding-top: 10px !important; /* Espaciado con padding en lugar de margin */
    padding-bottom: 10px !important; /* Small padding at bottom */
    position: relative !important;
    top: 0 !important; /* Ensure no top offset */
    clear: both !important; /* Clear any floats */
    overflow-y: auto !important; /* Enable vertical scroll when needed */
    overflow-x: hidden !important; /* Hide horizontal scroll */
    scroll-behavior: smooth !important; /* Smooth scrolling */
    z-index: 1 !important; /* Bajo z-index para no tapar dropdowns */
}

/* User management tabs - estilo antracita elegante */
h2 + input.button,
input.button[onclick*="user_list"] {
    display: inline-block !important;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important; /* Fondo antracita */
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 10px 20px !important; /* Padding para que quede proporcionado */
    margin-right: 10px !important;
    margin-bottom: 15px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2) !important;
    vertical-align: middle !important;
    float: none !important;
    clear: none !important;
    width: auto !important; /* Ancho automático según contenido */
    white-space: nowrap !important; /* Texto en una línea */
}

/* Hover effect */
h2 + input.button:hover,
input.button[onclick*="user_list"]:hover:not([disabled]) {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%) !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
    transform: translateY(-1px) !important;
}

/* Active/Disabled tab - estilo diferente */
input.button[onclick*="user_list"][disabled] {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%) !important; /* Gris para activo */
    color: white !important;
    cursor: default !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2) !important;
    font-weight: 600 !important;
}

/* Contenedor de botones para alineación */
h2 ~ input.button {
    vertical-align: top !important; /* Alineación superior */
}

/* Específicos para los botones de gestión de usuarios */
input.button[value*="Administrators"],
input.button[value*="Administradores"],
input.button[value*="Users"],
input.button[value*="Usuarios"],
input.button[value*="Subusers"],
input.button[value*="Subusuarios"] {
    min-width: fit-content !important; /* Ancho mínimo según contenido */
}

/* Custom scrollbar for main-content */
#main-content::-webkit-scrollbar {
    width: 8px !important;
}

#main-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05) !important;
    border-radius: 4px !important;
}

#main-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2) !important;
    border-radius: 4px !important;
    transition: background 0.3s ease !important;
}

#main-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3) !important;
}

/* For home page, make main-content reach the footer */
body.home #main-content,
[data-page="home"] #main-content,
.page-home #main-content {
    min-height: calc(100vh - 110px) !important; /* Adjusted for home page header */
    padding-bottom: 10px !important;
    margin-top: 0 !important; /* Remove gap */
    padding-top: 0 !important; /* Remove gap */
}

/* Remove any spacing that creates the gap */
#main-body {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Ensure main-content is positioned right after main-menu */
#main-menu + #main-content,
.main-menu + #main-content {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

#main-content {
    background: transparent;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    margin-top: 120px !important;
    padding-bottom: 20px;
    padding: 20px;
    position: relative;
    z-index: 20 !important;
    color: #2d3748;
}

/* ===== LOGIN INTEGRATION WITHIN MAIN-CONTENT ===== */

/* Login page background - anthracite */
body.login,
body[class*="login"],
body[class*="auth"],
.auth-page,
.login-page,
body:has(.login-page-wrapper),
body:has(.login-container) {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    min-height: 100vh !important;
}

/* Remove main-body padding on login pages */
body.login #main-body,
body[class*="login"] #main-body,
body[class*="auth"] #main-body,
.auth-page #main-body,
.login-page #main-body,
body:has(.login-page-wrapper) #main-body,
body:has(.login-container) #main-body {
    padding-bottom: 0 !important;
    min-height: 100vh !important;
}

/* Hide footer on login pages */
body.login #main-footer,
body[class*="login"] #main-footer,
body[class*="auth"] #main-footer,
.auth-page #main-footer,
.login-page #main-footer,
.login-page-wrapper #main-footer {
    display: none !important;
}

/* Alternative: Hide footer when login wrapper is present */
.login-page-wrapper ~ #main-footer,
.login-container ~ #main-footer {
    display: none !important;
}

/* Global rule: Hide footer if login form is present */
body:has(.login-page-wrapper) #main-footer,
body:has(.login-container) #main-footer,
body:has(form[action*="login"]) #main-footer {
    display: none !important;
}

/* Login forms positioned within main-content */
body.login #main-content,
body[class*="login"] #main-content,
.auth-page #main-content {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    margin-top: 80px !important;
    min-height: calc(100vh - 80px) !important;
}

/* Login container styling */
body.login .login-container,
body.login .auth-container,
body.login form,
body[class*="login"] .login-container,
body[class*="login"] .auth-container,
body[class*="login"] form {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    padding: 40px;
    max-width: 450px;
    width: 100%;
    margin: 0 auto;
    position: relative;
    z-index: 100;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Login form elements */
body.login input[type="text"],
body.login input[type="password"],
body.login input[type="email"],
body.login .form-control,
body[class*="login"] input[type="text"],
body[class*="login"] input[type="password"],
body[class*="login"] input[type="email"],
body[class*="login"] .form-control {
    width: 100%;
    padding: 15px;
    margin-bottom: 20px;
    border: 2px solid rgba(44, 62, 80, 0.1);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}

body.login input:focus,
body[class*="login"] input:focus {
    border-color: #2c3e50;
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
    outline: none;
    background: white;
}

/* Login buttons */
body.login .btn,
body.login button,
body.login input[type="submit"],
body[class*="login"] .btn,
body[class*="login"] button,
body[class*="login"] input[type="submit"] {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

body.login .btn:hover,
body.login button:hover,
body[class*="login"] .btn:hover,
body[class*="login"] button:hover {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(44, 62, 80, 0.3);
}

/* Login labels and text */
body.login label,
body.login h1,
body.login h2,
body.login h3,
body[class*="login"] label,
body[class*="login"] h1,
body[class*="login"] h2,
body[class*="login"] h3 {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}

/* Login links */
body.login a,
body[class*="login"] a {
    color: #2c3e50;
    text-decoration: none;
    font-weight: 500;
}

body.login a:hover,
body[class*="login"] a:hover {
    color: #34495e;
    text-decoration: underline;
}

/* Responsive login */
@media (max-width: 768px) {
    body.login .login-container,
    body.login .auth-container,
    body.login form,
    body[class*="login"] .login-container,
    body[class*="login"] .auth-container,
    body[class*="login"] form {
        margin: 20px;
        padding: 30px 20px;
        max-width: calc(100% - 40px);
    }
    
    body.login #main-content,
    body[class*="login"] #main-content {
        margin-top: 60px !important;
        padding: 10px;
    }
}

/* ===== RESPONSIVE DESIGN ===== */

/* Copy responsive rules from default theme */
@media (max-width: 768px) {
    .playsms-responsive, input, select, option, textarea {
        width: 335px;
    }
    .label-sizer {
        width: 345px;
    }
    .dropdown-menu hr {
        display: none;
    }
    
    .navbar-toggle {
        display: block;
    }
    
    .navbar-collapse {
        flex-direction: column;
        width: 100%;
    }
    
    .navbar-nav {
        flex-direction: column;
        width: 100%;
    }
    
    .navbar-right {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .playsms-responsive, input, select, option, textarea {
        width: 251px;
    }
    .label-sizer {
        width: 261px;
    }
    .dropdown-menu hr {
        display: none;
    }
    .navbar-right { 
        float: left !important; 
    }
    .navbar-header:after { 
        clear: none; 
    }
    .navbar-nav.navbar-right > li { 
        float: left; 
    }
    .navbar-collapse:before { 
        clear: both; 
    }
    .navbar-collapse { 
        overflow-y: hidden; 
    }
    .navbar-collapse.in { 
        overflow-y: visible; 
    }
    .navbar-collapse.in > ul { 
        border-top: none; 
    }
}

@media (max-width: 480px) {
    .playsms-responsive, input, select, option, textarea {
        width: 200px;
    }
    .label-sizer {
        width: 210px;
    }
}

@media (max-width: 320px) {
    .playsms-responsive, input, select, option, textarea {
        width: 120px;
    }
    .label-sizer {
        width: 130px;
    }
}

@media (max-width: 240px) {
    .playsms-responsive, input, select, option, textarea {
        width: 75px;
    }
    .label-sizer {
        width: 85px;
    }
}

/* ===== MODERN STYLING ===== */

/* Forms */
.form-control, input[type="text"], input[type="email"], input[type="password"], select, textarea {
    border-radius: 6px;
    border: 2px solid rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    position: relative;
    z-index: 100 !important;
}

.form-control:focus, input:focus, select:focus, textarea:focus {
    border-color: #2c3e50;
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
    outline: none;
    z-index: 101 !important;
}

/* Login forms - ensure high z-index for interaction */
form, .form-group, .login-form, .auth-form {
    position: relative;
    z-index: 200 !important;
}

/* Login page specific inputs - HIGHEST PRIORITY */
body.login input, 
body.login form,
body.login .form-control,
body.login .btn,
body.login button,
.login-container input,
.login-container form,
.login-container .form-control,
.login-container .btn,
.login-container button,
[class*="login"] input,
[class*="login"] form,
[class*="login"] .form-control,
[class*="login"] .btn,
[class*="login"] button {
    z-index: 500 !important;
    position: relative !important;
    pointer-events: auto !important;
}

/* Login page body - ensure no blocking elements */
body.login,
body.login *,
.login-page,
.login-page *,
body[class*="login"],
body[class*="login"] *,
.auth-page,
.auth-page * {
    pointer-events: auto !important;
}

/* Override any blocking elements on login */
body.login .navbar-brand,
body.login #main-brand,
body[class*="login"] .navbar-brand,
body[class*="login"] #main-brand {
    pointer-events: auto !important;
}

/* Ensure main content area is interactive on login */
body.login #main-content,
body.login #main-content *,
body[class*="login"] #main-content,
body[class*="login"] #main-content * {
    pointer-events: auto !important;
    z-index: 300 !important;
}

/* ===== SYSTEM ALERTS STYLING ===== */

/* System Alerts Panels */
.system-alerts .panel,
[class*="system_alerts"] .panel {
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.9) 100%);
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    margin-bottom: 25px;
    overflow: hidden;
}

/* System Alerts Panel Headings */
.system-alerts .panel-heading,
[class*="system_alerts"] .panel-heading {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    color: white !important;
    border: none;
    padding: 20px;
    border-radius: 0;
}

.system-alerts .panel-title,
[class*="system_alerts"] .panel-title {
    color: white !important;
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Badge styling for alert count */
.system-alerts .badge,
[class*="system_alerts"] .badge {
    background: rgba(255,255,255,0.2);
    color: white;
    border-radius: 20px;
    padding: 5px 12px;
    font-weight: 500;
}

/* System Alerts Panel Body */
.system-alerts .panel-body,
[class*="system_alerts"] .panel-body {
    padding: 25px;
    background: rgba(255,255,255,0.95);
}

/* Service Status Display */
.system-alerts h4,
[class*="system_alerts"] h4 {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 15px;
}

/* System Alerts Buttons */
.system-alerts .btn,
[class*="system_alerts"] .btn {
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 500;
    border: none;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

.system-alerts .btn-warning,
[class*="system_alerts"] .btn-warning {
    background: linear-gradient(135deg, #ff9800 0%, #ff6b6b 100%);
    color: white;
}

.system-alerts .btn-warning:hover,
[class*="system_alerts"] .btn-warning:hover {
    background: linear-gradient(135deg, #e68900 0%, #ff5252 100%);
    transform: translateY(-2px);
}

.system-alerts .btn-info,
[class*="system_alerts"] .btn-info {
    background: linear-gradient(135deg, #2196f3 0%, #667eea 100%);
    color: white;
}

.system-alerts .btn-info:hover,
[class*="system_alerts"] .btn-info:hover {
    background: linear-gradient(135deg, #1976d2 0%, #5a67d8 100%);
    transform: translateY(-2px);
}

/* Alert Messages Styling */
.system-alerts .alert,
[class*="system_alerts"] .alert {
    border: none;
    border-radius: 10px;
    margin-bottom: 15px;
    padding: 20px;
    border-left: 4px solid;
    box-shadow: 0 3px 15px rgba(0,0,0,0.1);
}

.system-alerts .alert-success,
[class*="system_alerts"] .alert-success {
    background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
    border-left-color: #4caf50;
    color: #1e7e34;
}

.system-alerts .alert-warning,
[class*="system_alerts"] .alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-left-color: #ff9800;
    color: #856404;
}

.system-alerts .alert-danger,
[class*="system_alerts"] .alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #ffb3ba 100%);
    border-left-color: #e51c23;
    color: #721c24;
}

.system-alerts .alert-error,
[class*="system_alerts"] .alert-error {
    background: linear-gradient(135deg, #f8d7da 0%, #ffb3ba 100%);
    border-left-color: #e51c23;
    color: #721c24;
}

/* Labels in alerts */
.system-alerts .label,
[class*="system_alerts"] .label {
    border-radius: 20px;
    padding: 5px 12px;
    font-weight: 500;
    margin-right: 10px;
}

.system-alerts .label-default,
[class*="system_alerts"] .label-default {
    background: #6c757d;
    color: white;
}

.system-alerts .label-warning,
[class*="system_alerts"] .label-warning {
    background: #ff9800;
    color: white;
}

/* Alert close button */
.system-alerts .close,
[class*="system_alerts"] .close {
    opacity: 0.7;
    font-size: 20px;
    color: inherit;
}

.system-alerts .close:hover,
[class*="system_alerts"] .close:hover {
    opacity: 1;
}

/* Fixed notification styling */
.alert-fixed {
    border-radius: 12px !important;
    backdrop-filter: blur(10px);
    background: rgba(220, 53, 69, 0.95) !important;
    color: white !important;
    border: 1px solid rgba(255,255,255,0.2);
}

.alert-fixed .alert-link {
    color: white !important;
    text-decoration: underline;
    font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .system-alerts .btn,
    [class*="system_alerts"] .btn {
        margin-bottom: 10px;
        width: 100%;
    }
    
    .system-alerts .panel-body,
    [class*="system_alerts"] .panel-body {
        padding: 15px;
    }
}

/* Buttons */
.btn, .button, input[type="submit"], input[type="button"] {
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
}

.btn-primary, .button {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
}

.btn-primary:hover, .button:hover {
    background: linear-gradient(135deg, #34495e, #2c3e50);
    transform: translateY(-1px);
}

/* Tables */
.table, .playsms-table {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.table thead th, .playsms-table thead th {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    border: none;
    font-weight: 600;
}

/* Alerts */
.alert {
    border-radius: 8px;
    border: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.alert-success {
    background: linear-gradient(135deg, rgba(72, 187, 120, 0.1), rgba(56, 161, 105, 0.1));
    color: #38a169;
    border-left: 4px solid #48bb78;
}

.alert-danger {
    background: linear-gradient(135deg, rgba(245, 101, 101, 0.1), rgba(229, 62, 62, 0.1));
    color: #e53e3e;
    border-left: 4px solid #f56565;
}

/* Cards/Panels */
.panel, .card {
    background: white;
    border-radius: 8px;
    border: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-bottom: 20px;
}

.panel-heading, .card-header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    border: none;
    font-weight: 600;
}

/* ===== FOOTER STRUCTURE - Normal positioning ===== */

#main-footer {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    color: rgba(255,255,255,0.9);
    padding: 10px 0;
    margin: 0 auto;
    width: 100%;
    max-width: 1400px;
    border-top: 1px solid rgba(255,255,255,0.1);
    height: 60px !important;
    box-sizing: border-box;
}

/* Footer positioning for Home page - hereda del footer general */
/* Las reglas específicas de home ya no son necesarias con flexbox */

#main-footer .container {
    background: transparent !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    height: 100% !important;
    position: relative !important;
    padding: 0 !important;
}

#main-footer .container > div:first-child {
    position: absolute !important;
    left: 20px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
}

#main-footer .credit {
    color: rgba(255,255,255,0.7) !important;
    font-size: 11px !important;
    margin: 0 !important;
    text-align: center !important;
}
