/* ========================================
   PROFESSIONAL INTERFACE ENHANCEMENTS
   Sophisticated Design with Seamless Animations
======================================== */

/* ========================================
   FOUNDATION VARIABLES
======================================== */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-primary: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.15);
    --transition-fast: all 0.1s ease-out;
    --transition-smooth: all 0.15s ease-out;
    --transition-elegant: all 0.2s ease-out;
}

/* ========================================
   SIDEBAR BACKGROUND ENHANCEMENT
======================================== */
.sidebar-gradient {
    background: var(--primary-gradient);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

.sidebar-gradient::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

/* ========================================
   BASE TYPOGRAPHY & ELEMENTS
======================================== */
.sidebar-letter-white .nav-link {
    color: #ffffff !important;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 400;
    letter-spacing: 0.025em;
}

/* ========================================
   MAIN NAVIGATION ITEMS
   Elegant, sophisticated styling with text overflow handling
======================================== */
.nav-sidebar > .nav-item > .nav-link {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #ffffff !important;
    border-radius: 12px;
    margin: 2px 0;
    padding: 14px 18px !important;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: var(--transition-elegant);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: flex;
    align-items: center;
    min-height: 48px;
    /* Text overflow handling */
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
    box-shadow: none;
    outline: none;
    line-height: normal;
}

/* Subtle background animation */
.nav-sidebar > .nav-item > .nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: var(--transition-el255, 255egant);
}

.nav-sidebar > .nav-item > .nav-link:hover::before {
    left: 100%;
}

/* Main menu hover state - sophisticated effects without shifting */
.nav-sidebar > .nav-item > .nav-link:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--glass-border);
    box-shadow: none;
    color: #ffffff !important;
}

/* Main menu active state */
.nav-sidebar > .nav-item > .nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: none;
    transform: none;
}

/* Main menu when submenu is open - no additional spacing */
.nav-sidebar > .nav-item.menu-open > .nav-link {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.25);
    transform: none;
}

/* ========================================
   SUBMENU STYLING
   Refined hierarchy with elegant spacing
======================================== */

/* Submenu container - glass effect with zero padding/margin */
.nav-sidebar .nav-treeview {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 10px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    box-shadow: none;
    outline: none;
}

/* Submenu items - refined design with enhanced hierarchical indentation */
.nav-sidebar .nav-treeview > .nav-item > .nav-link {
    background: transparent;
    color: rgba(255, 255, 255, 0.85) !important;
    border-radius: 12px;
    margin: 2px 0;
    padding: 14px 18px 14px 38px !important;
    font-size: 14px;
    font-weight: 400;
    position: relative;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
    /* Enhanced text overflow handling with consistent dimensions */
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    white-space: normal;
    line-height: normal;
    min-height: 48px;
    max-width: 100%;
    box-shadow: none;
    outline: none;
}

/* Submenu visual differentiation - subtle indentation indicator */
.nav-sidebar .nav-treeview > .nav-item > .nav-link::before {
    content: "";
    position: absolute;
    left: 28px;
    top: 50%;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: translateY(-50%);
    transition: var(--transition-fast);
}

/* Submenu hover state - consistent dimensions with subtle differentiation */
.nav-sidebar .nav-treeview > .nav-item > .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff !important;
    transform: none;
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

.nav-sidebar .nav-treeview > .nav-item > .nav-link:hover::before {
    background: #ffffff;
    transform: translateY(-50%) scale(1.1);
}

/* Submenu active state - consistent dimensions with visual differentiation */
.nav-sidebar .nav-treeview > .nav-item > .nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff !important;
    font-weight: 500;
    box-shadow: none;
}

.nav-sidebar .nav-treeview > .nav-item > .nav-link.active::before {
    content: "";
    background: #ffffff;
    transform: translateY(-50%) scale(1.2);
}

/* ========================================
   ANIMATION SYSTEM
   Sophisticated transitions
======================================== */

/* Optimized submenu slide animation - faster and more responsive */
.nav-treeview {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out;
    will-change: max-height;
}

.nav-item.menu-open > .nav-treeview {
    max-height: 600px;
}

/* ========================================
   NAVBAR ENHANCEMENTS
   Professional top navigation
======================================== */
.navbar {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.05);
}

.navbar-nav .nav-item .nav-link {
    color: #4a5568 !important;
    transition: var(--transition-smooth);
    border-radius: 8px;
    margin: 0 4px;
    padding: 10px 16px !important;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    /* Text overflow handling for navbar */
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 150px;
}

.navbar-nav .nav-item .nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary-gradient);
    transition: var(--transition-smooth);
    transform: translateX(-50%);
}

.navbar-nav .nav-item .nav-link:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea !important;
    transform: translateY(-1px);
    /* Eliminado border-radius para mejor consistencia visual */
}

.navbar-nav .nav-item .nav-link:hover::before {
    width: 80%;
}

.navbar-nav .nav-item .nav-link.active {
    background: rgba(102, 126, 234, 0.15);
    color: #667eea !important;
    font-weight: 600;
}

.navbar-nav .nav-item .nav-link.active::before {
    width: 80%;
}

/* ========================================
   SEARCH BAR REFINEMENT
   Glass morphism design
======================================== */
.form-control-sidebar {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    color: #ffffff;
    border-radius: 25px;
    padding: 12px 20px 12px 45px;
    font-size: 14px;
    transition: var(--transition-smooth);
    width: 100%;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.form-control-sidebar::placeholder {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 300;
}

.form-control-sidebar:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1), 
                inset 0 2px 10px rgba(0, 0, 0, 0.1);
    color: #ffffff;
    outline: none;
}

/* Search icon positioning */
.sidebar-menu-search {
    position: relative;
}

.sidebar-menu-search::before {
    content: '🔍';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
}

/* ========================================
   BUTTON ENHANCEMENTS
   Professional interaction design
======================================== */
.btn-sidebar {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #ffffff;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 10px 16px;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.btn-sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: var(--transition-elegant);
}

.btn-sidebar:hover::before {
    left: 100%;
}

.btn-sidebar:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: none;
    box-shadow: none;
    color: #ffffff;
}

/* ========================================
   DROPDOWN ENHANCEMENTS
   Elegant popup design
======================================== */
.nav-item .dropdown-menu {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 0px 0;
    color: #4a5568;
    box-shadow: var(--shadow-hover);
    animation: dropdownSlide 0.15s ease-out;
    will-change: transform, opacity;
    transform: translateZ(0);
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.nav-item .dropdown-menu .dropdown-item {
    color: #4a5568;
    padding: 12px 20px;
    transition: var(--transition-fast);
    position: relative;
    font-weight: 400;
}

.nav-item .dropdown-menu .dropdown-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-gradient);
    transform: scaleY(0);
    transition: var(--transition-fast);
}

.nav-item .dropdown-menu .dropdown-item:hover {
    background: rgba(102, 126, 234, 0.08);
    color: #667eea;
    transform: translateX(4px);
}

.nav-item .dropdown-menu .dropdown-item:hover::before {
    transform: scaleY(1);
}

/* ========================================
   LOGO ENHANCEMENT
   Sophisticated typography
======================================== */
.logo-importadora {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.025em;
}

.logo-miranda {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.025em;
}

/* ========================================
   RESPONSIVE OPTIMIZATION
   Mobile-first sophisticated design with enhanced text handling
======================================== */
@media (max-width: 768px) {
    .nav-sidebar > .nav-item > .nav-link {
        font-size: 13px;
        padding: 12px 16px !important;
        margin: 2px 0;
        /* Enhanced text handling for mobile */
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: normal;
        min-height: 44px;
    }
    
    .nav-sidebar .nav-treeview > .nav-item > .nav-link {
        font-size: 13px;
        padding: 12px 16px 12px 36px !important;
        margin: 2px 0;
        /* Consistent dimensions with enhanced hierarchical indentation */
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: normal;
        min-height: 44px;
    }
    
    .nav-sidebar .nav-treeview {
        margin: 0;
        padding: 0;
    }
    
    .form-control-sidebar {
        padding: 10px 16px 10px 40px;
        font-size: 13px;
    }
    
    .navbar-nav .nav-item .nav-link {
        /* Allow text wrapping on mobile */
        white-space: normal;
        max-width: none;
        padding: 8px 12px !important;
    }
}

@media (max-width: 480px) {
    .nav-sidebar > .nav-item > .nav-link {
        font-size: 12px;
        padding: 10px 14px !important;
        margin: 2px 0;
        /* Compact text handling for very small screens */
        line-height: normal;
        min-height: 40px;
    }
    
    .nav-sidebar .nav-treeview > .nav-item > .nav-link {
        font-size: 12px;
        padding: 10px 14px 10px 34px !important;
        margin: 2px 0;
        /* Consistent dimensions with enhanced hierarchical indentation */
        line-height: normal;
        min-height: 40px;
    }
    
    /* Enhanced text overflow prevention for very long menu items */
    .nav-sidebar .nav-link {
        position: relative;
    }
    
    .nav-sidebar .nav-link .nav-text {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: calc(100% - 30px); /* Account for icon space */
    }
}

/* ========================================
   LOADING & INTERACTION STATES
   Professional feedback system
======================================== */
.loading-shimmer {
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.1) 25%, 
        rgba(255, 255, 255, 0.2) 50%, 
        rgba(255, 255, 255, 0.1) 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Focus states for accessibility */
.nav-sidebar .nav-link:focus,
.form-control-sidebar:focus,
.btn-sidebar:focus {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .nav-sidebar .nav-treeview {
        background: rgba(0, 0, 0, 0.8);
        border-color: rgba(255, 255, 255, 0.3);
    }
    
    .nav-sidebar .nav-treeview > .nav-item > .nav-link {
        color: #ffffff !important;
        border-color: rgba(255, 255, 255, 0.4);
    }
}

/* ========================================
   ENHANCED TEXT HANDLING & PERFORMANCE
   Additional responsive solutions and optimizations
======================================== */

/* Text truncation with tooltip for overflow prevention */
.nav-sidebar .nav-link {
    position: relative;
}

.nav-sidebar .nav-text {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* Allow full text display on hover for truncated items */
@media (min-width: 769px) {
    .nav-sidebar .nav-item:hover .nav-text {
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* Reduced motion support for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Performance optimization - GPU acceleration for transforms */
.nav-sidebar .nav-link,
.nav-sidebar .nav-treeview,
.navbar-nav .nav-link {
    transform: translateZ(0);
    will-change: transform;
}

/* Enhanced focus management for keyboard navigation */
.nav-sidebar .nav-link:focus-visible,
.navbar-nav .nav-link:focus-visible {
    outline: 2px solid rgba(102, 126, 234, 0.8);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Text scaling support for accessibility */
@media (min-resolution: 120dpi) {
    .nav-sidebar > .nav-item > .nav-link {
        font-size: 15px; /* Slightly larger on high DPI displays */
    }
    
    .nav-sidebar .nav-treeview > .nav-item > .nav-link {
        font-size: 14px;
    }
}

/* Container query support for modern browsers */
@container (max-width: 300px) {
    .nav-sidebar > .nav-item > .nav-link {
        padding: 8px 12px !important;
        font-size: 12px;
    }
}

/* =======================================
   🔹 ICONOS RESPONSIVOS EN NAVBAR TOP
   ======================================= */

/* Ajuste base para todos los íconos del topnav */
.navbar-nav > .nav-item > .nav-link > i {
    font-size: 1.3rem; /* Tamaño base */
    padding: 6px;
    transition: all 0.3s ease;
    color: var(--primary, #4a00e0);
}

/* Hover suave */
.navbar-nav > .nav-item > .nav-link:hover > i {
    transform: scale(1.15);
    color: #3b78d8;
}

/* Margen y alineación más precisa */
.navbar-nav > .nav-item {
    margin: 0 0.25rem;
}

/* Asegura que los íconos no generen salto vertical */
.navbar-nav > .nav-item > .nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ====== Breakpoints responsivos ====== */

/* 📱 Pantallas pequeñas (móviles) */
@media (max-width: 576px) {
    .navbar-nav > .nav-item > .nav-link > i {
        font-size: 1rem; /* reduce tamaño */
        padding: 4px;
    }

    .navbar-nav > .nav-item {
        margin: 0 0.1rem;
    }

    .navbar-nav {
        flex-wrap: wrap; /* evita desbordes */
        justify-content: center;
    }
}

/* 📱 Pantallas medianas (tablets) */
@media (min-width: 577px) and (max-width: 1366px) {
   .navbar-nav > .nav-item > .nav-link > i {
        font-size: 1rem; /* reduce tamaño */
        padding: 4px;
    }

    .navbar-nav > .nav-item {
        margin: 0 0.1rem;
    }

    .navbar-nav {
        flex-wrap: wrap; /* evita desbordes */
        justify-content: center;
    }
}

/* 💻 Pantallas grandes (desktop) */
@media (min-width: 1367px) {
    .navbar-nav > .nav-item > .nav-link > i {
        font-size: 1.3rem;
    }
}

/* ====== Efecto de sombra ligera al tocar (opcional para móviles) ====== */
.navbar-nav > .nav-item > .nav-link:active > i {
    transform: scale(0.95);
    color: #2a65c8;
}

/* ====== Opcional: fondo circular suave en hover ====== */
.navbar-nav > .nav-item > .nav-link:hover {
    background-color: rgba(128, 0, 128, 0.08);
    border-radius: 50%;
}