/* ============================================
   NAVBAR MÉDICO PROFESIONAL - TECSAS3
   Inspirado en GE Healthcare y Siemens Healthineers
   Alineado con sidebar moderno
   ============================================ */

/* NAVBAR PRINCIPAL (Header) */
.navbar.fixed-top,
.navbar.clean-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 90px;
    background: linear-gradient(135deg, rgba(19, 77, 109, 0.98) 0%, rgba(4, 42, 58, 0.98) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 
                0 2px 8px rgba(0, 0, 0, 0.1),
                inset 0 -1px 0 rgba(166, 218, 247, 0.1);
    border-bottom: 2px solid rgba(166, 218, 247, 0.3); /* Border más visible para separación */
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    z-index: 1000;
    padding: 0.75rem 1.5rem;
    margin-bottom: 0; /* Asegurar que no haya margen inferior */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* TOPBAR (Users Navbar - secundario) */
/* NOTA: Este navbar es OPCIONAL y debe usarse DENTRO del #content para herramientas específicas */
.navbar.topbar {
    position: relative;
    height: auto;
    min-height: 70px;
    background: linear-gradient(135deg, rgba(69, 139, 186, 0.15) 0%, rgba(108, 175, 221, 0.1) 100%);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(166, 218, 247, 0.2);
    margin: 0 0 20px 0; /* Margen inferior para separación del contenido */
    padding: 0.75rem 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   LOGO/BRAND
   ============================================ */
.navbar-brand {
    display: flex;
    align-items: center;
    padding: 0;
    margin-right: 2rem;
    /* Evitar transformaciones que causen temblor */
    transform: none !important;
    background: none !important;
    box-shadow: none !important;
}

.navbar-brand:hover,
.navbar-brand:focus,
.navbar-brand:active {
    /* Mantener estable, sin transformaciones */
    transform: none !important;
    background: none !important;
    box-shadow: none !important;
}

.navbar-brand:focus {
    outline: 2px solid var(--primary-color, #A6DAF7);
    outline-offset: 4px;
    border-radius: 8px;
}

.navbar-brand:focus:not(:focus-visible) {
    outline: none;
}

.tecsa-logo {
    height: 50px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: filter 0.3s ease, transform 0.3s ease;
}

.navbar-brand:hover .tecsa-logo {
    filter: drop-shadow(0 4px 8px rgba(166, 218, 247, 0.4));
    transform: scale(1.03);
}

/* ============================================
   NAVBAR NAV ITEMS
   ============================================ */
.navbar-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.nav-link i {
    font-size: 1.1rem;
    color: var(--primary-color);
    transition: all 0.3s ease;
}

.nav-link:hover,
.nav-link:focus {
    background: rgba(166, 218, 247, 0.1);
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(166, 218, 247, 0.15);
}

.nav-link:hover i,
.nav-link:focus i {
    color: #ffffff;
    transform: scale(1.1);
}

.nav-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ============================================
   BÚSQUEDA EN NAVBAR
   ============================================ */
.navbar-search {
    max-width: 400px;
}

.navbar-search .input-group {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.navbar-search .form-control {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(166, 218, 247, 0.3);
    border-right: none;
    color: #2c3e50;
    font-size: 0.875rem;
    padding: 0.625rem 1rem;
    transition: all 0.3s ease;
}

.navbar-search .form-control:focus {
    background: #ffffff;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(166, 218, 247, 0.2);
}

.navbar-search .form-control::placeholder {
    color: rgba(44, 62, 80, 0.5);
}

.navbar-search .btn {
    background: linear-gradient(135deg, var(--tertiary-color) 0%, var(--quaternary-color) 100%);
    border: 1px solid var(--tertiary-color);
    color: #ffffff;
    padding: 0.625rem 1.25rem;
    transition: all 0.3s ease;
}

.navbar-search .btn:hover {
    background: linear-gradient(135deg, var(--quaternary-color) 0%, var(--quinternary-color) 100%);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(69, 139, 186, 0.3);
}

/* ============================================
   NAVBAR TOGGLER (Mobile)
   ============================================ */
.navbar-toggler {
    border: 2px solid rgba(166, 218, 247, 0.5);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: rgba(166, 218, 247, 0.1);
    transition: all 0.3s ease;
}

.navbar-toggler:hover {
    background: rgba(166, 218, 247, 0.2);
    border-color: var(--primary-color);
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.25rem rgba(166, 218, 247, 0.3);
    outline: none;
    border-color: var(--primary-color);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(166, 218, 247, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    width: 1.5rem;
    height: 1.5rem;
}

/* ============================================
   DROPDOWNS
   ============================================ */
.dropdown-toggle::after {
    margin-left: 0.5rem;
    transition: transform 0.3s ease;
}

.dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

.dropdown-menu {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(166, 218, 247, 0.3);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
    margin-top: 0.5rem;
    min-width: 280px;
}

.dropdown-header {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--quaternary-color);
    padding: 0.75rem 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(166, 218, 247, 0.2);
}

.dropdown-item {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 0.25rem 0;
    color: #2c3e50;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: linear-gradient(135deg, rgba(166, 218, 247, 0.15) 0%, rgba(108, 175, 221, 0.1) 100%);
    color: var(--quaternary-color);
    transform: translateX(4px);
}

.dropdown-item i {
    width: 20px;
    text-align: center;
    color: var(--tertiary-color);
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-color: rgba(166, 218, 247, 0.2);
}


/* ============================================
   BADGES Y NOTIFICACIONES
   ============================================ */
.badge-counter {
    position: absolute;
    top: -5px;
    right: -8px;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
    background: linear-gradient(135deg, #FF6B6B 0%, #EE5A52 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.img-profile {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(166, 218, 247, 0.3);
    transition: all 0.3s ease;
}

.img-profile:hover {
    border-color: #ffffff;
    box-shadow: 0 4px 12px rgba(166, 218, 247, 0.5);
    transform: scale(1.05);
}

.topbar-divider {
    width: 1px;
    height: 2rem;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 1rem;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 991.98px) {
    .navbar.fixed-top,
    .navbar.clean-navbar {
        height: 70px;
        padding: 0.5rem 1rem;
    }
    
    .tecsa-logo {
        height: 40px;
    }

    .navbar-collapse {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        background: linear-gradient(180deg, rgba(19, 77, 109, 0.98) 0%, rgba(4, 42, 58, 0.98) 100%);
        backdrop-filter: blur(20px);
        padding: 1.5rem;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
        border-top: 1px solid rgba(166, 218, 247, 0.2);
        animation: slideDown 0.3s ease-out;
    }

    .navbar-nav {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .nav-item {
        width: 100%;
    }

    .nav-link {
        width: 100%;
        padding: 1rem !important;
        justify-content: flex-start;
    }

    .persona-image {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .persona-image img {
        width: 32px !important;
        height: 32px !important;
    }

    #logout {
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .navbar-search {
        max-width: 100%;
        margin-bottom: 1rem;
    }
    
    .topbar-divider {
        display: none;
    }
}

/* ============================================
   RESPONSIVE - DESKTOP
   ============================================ */
@media (min-width: 992px) {
    .navbar-collapse {
        justify-content: flex-end;
    }

    .navbar-nav {
        align-items: center;
        flex-direction: row;
    }

    .persona-image {
        margin-left: 0.75rem;
        padding-left: 0.75rem;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .dropdown-menu {
        position: absolute;
    }
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.navbar-collapse.collapsing,
.navbar-collapse.show {
    animation: slideDown 0.3s ease-out;
}

.dropdown-menu.show {
    animation: fadeIn 0.2s ease-out;
}

/* ============================================
   UTILIDADES
   ============================================ */
.navbar .container-fluid {
    max-width: 100%;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

/* Asegurar que el navbar no tape el contenido */
body {
    padding-top: 90px; /* Altura del navbar fixed */
}

@media (max-width: 991.98px) {
    body {
        padding-top: 70px;
    }
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */
.nav-link:focus-visible,
.navbar-toggler:focus-visible,
.dropdown-item:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Mejorar contraste para lectores de pantalla */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   ESTADOS HOVER MEJORADOS
   ============================================ */
.nav-item.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu {
    margin-top: 0;
}

/* Efecto ripple en clicks */
@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.nav-link:active::after,
.dropdown-item:active::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: ripple 0.6s ease-out;
}
