/* Modern Glassmorphism Navbar Styles */
.glass-navbar {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: 1200px;
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0);
    border-radius: 20px;
    height: auto;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0),
        0 8px 48px rgba(0, 0, 0, 0),
        inset 0 1px 0 rgba(255, 255, 255, 0);
}

.glass-island {
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
}

.glass-island::before {
    display: none;
}

.glass-island:hover {
    transform: none;
}

/* Modern Logo Circle Island */
.logo-circle-island {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(249, 249, 249, 0.15));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    padding: 0;
    margin-left: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 4px 16px rgba(59, 130, 246, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.logo-circle-island::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 1px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.4), rgba(147, 51, 234, 0.4));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.logo-circle-island:hover::before {
    opacity: 1;
}

.logo-circle-island:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(147, 51, 234, 0.25));
    transform: scale(1.05) translateY(-2px);
    box-shadow:
        0 8px 24px rgba(59, 130, 246, 0.35),
        0 4px 12px rgba(147, 51, 234, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.logo-circle-island:active {
    transform: scale(0.98);
}

/* Brand Name Island */
.logo-island {
    min-width: 120px;
}

.logo-island a {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    position: relative;
    z-index: 1;
}

.logo-island span {
    background: linear-gradient(135deg, #fff, #f0f0f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Modern Navigation Island */
.nav-island {
    flex: 1;
    max-width: 600px;
    padding: 0;
    background: transparent;
    display: flex;
    justify-content: center;
}

.nav-island ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-island li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: -0.01em;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    white-space: nowrap;
    background: transparent;
}

.nav-island li a::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(147, 51, 234, 0.2));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-island li a:hover::before {
    opacity: 1;
}

.nav-island li a:hover {
    color: white;
    transform: translateY(-1px);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all 0.3s ease;
}

.nav-island li a:hover {
    color: white;
    transform: translateY(-1px);
}

.nav-island li a.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(147, 51, 234, 0.3));
    color: white;
    box-shadow:
        0 2px 12px rgba(59, 130, 246, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-island li a.active::before {
    opacity: 0;
}

/* Modern User Island */
.user-island {
    min-width: auto;
    position: relative;
    display: flex;
    align-items: center;
    padding: 0;
    background: transparent;
}

.user-island::before {
    display: none;
}

.user-island:hover {
    background: transparent;
    box-shadow: none;
    transform: none;
}

/* Modern User Setup Button */
.user-setup-container {
    position: relative;
    /* Ensure z-index is handled for stacking context */
    z-index: 51;
}

.user-setup-btn {
    height: 56px;
    border: none;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(147, 51, 234, 0.15));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 20px 6px 6px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
    box-shadow:
        0 4px 16px rgba(59, 130, 246, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    outline: none;
}





.user-setup-btn:active {
    transform: translateY(0);
}

/* Profile Avatar with Online Indicator */
.profile-avatar {
    position: relative;
    flex-shrink: 0;
}

.user-setup-btn img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
    border: 2px solid rgba(255, 255, 255, 0.25);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}



.user-setup-btn .user-name {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    position: relative;
    z-index: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
}



.user-setup-btn .dropdown-arrow {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.65);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    transform-origin: center;
}



.user-setup-btn.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* Auto-hide navbar on scroll */
#navbar.glass-navbar {
    transform: translateX(-50%);
}

#navbar.glass-navbar.hidden {
    transform: translateX(-50%) translateY(-100px);
    opacity: 0.95;
}

/* Modern User Setup Menu */
.user-setup-menu {
    position: absolute;
    top: 68px;
    right: 0;
    min-width: 280px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 20px 0;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.4),
        0 8px 24px rgba(59, 130, 246, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-12px) scale(0.96);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
}

.user-setup-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Menu Header with User Info */
.menu-header {
    padding: 0 20px 16px 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.user-display-name {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.user-email {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.8rem;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

/* Account Type Badge */
.account-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-top: 4px;
    transition: all 0.2s ease;
}

.account-type-icon {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

/* Hospital Badge - Blue */
.account-type-hospital {
    background-color: rgb(30, 64, 175);
    color: rgb(191, 219, 254);
}

/* Service Provider Badge - Green */
.account-type-service_provider {
    background-color: rgb(21, 128, 61);
    color: rgb(187, 247, 208);
}

/* Manufacturer Badge - Purple */
.account-type-manufacturer {
    background-color: rgb(107, 33, 168);
    color: rgb(233, 213, 255);
}

/* Menu Divider */
.menu-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    margin: 14px 20px;
}

/* Modern Menu Items */
.menu-item {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.925rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    margin: 0 10px;
    border-radius: 14px;
    gap: 12px;
}

.menu-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(147, 51, 234, 0.15));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-item:hover::before {
    opacity: 1;
}

.menu-item:hover {
    color: white;
    transform: translateX(4px);
}

.menu-item.admin-item {
    color: rgba(59, 130, 246, 0.9);
}

.menu-item.admin-item::before {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.2));
}

.menu-item.admin-item:hover {
    color: rgb(96, 165, 250);
}

.menu-item.logout-item {
    color: rgba(248, 113, 113, 0.9);
}

.menu-item.logout-item::before {
    background: rgba(239, 68, 68, 0.15);
}

.menu-item.logout-item:hover {
    color: rgb(248, 113, 113);
}

.menu-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.arrow-right {
    width: 16px;
    height: 16px;
    margin-left: auto;
    opacity: 0;
    transform: translateX(-6px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.menu-item:hover .arrow-right {
    opacity: 0.8;
    transform: translateX(0);
}

/* Modern Auth Links */
.auth-links {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-links a {
    padding: 10px 18px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    letter-spacing: -0.01em;
}

.auth-links .login-link {
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Menu Header with User Info */
.menu-header {
    padding: 0 20px 16px 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.user-display-name {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.user-email {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.8rem;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

/* Account Type Badge */
.account-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-top: 4px;
    transition: all 0.2s ease;
}

.account-type-icon {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

/* Hospital Badge - Blue */
.account-type-hospital {
    background-color: rgb(30, 64, 175);
    color: rgb(191, 219, 254);
}

/* Service Provider Badge - Green */
.account-type-service_provider {
    background-color: rgb(21, 128, 61);
    color: rgb(187, 247, 208);
}

/* Manufacturer Badge - Purple */
.account-type-manufacturer {
    background-color: rgb(107, 33, 168);
    color: rgb(233, 213, 255);
}

/* Menu Divider */
.menu-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    margin: 14px 20px;
}

/* Modern Menu Items */
.menu-item {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.925rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    margin: 0 10px;
    border-radius: 14px;
    gap: 12px;
}

.menu-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(147, 51, 234, 0.15));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-item:hover::before {
    opacity: 1;
}

.menu-item:hover {
    color: white;
    transform: translateX(4px);
}

.menu-item.admin-item {
    color: rgba(59, 130, 246, 0.9);
}

.menu-item.admin-item::before {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.2));
}

.menu-item.admin-item:hover {
    color: rgb(96, 165, 250);
}

.menu-item.logout-item {
    color: rgba(248, 113, 113, 0.9);
}

.menu-item.logout-item::before {
    background: rgba(239, 68, 68, 0.15);
}

.menu-item.logout-item:hover {
    color: rgb(248, 113, 113);
}

.menu-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.arrow-right {
    width: 16px;
    height: 16px;
    margin-left: auto;
    opacity: 0;
    transform: translateX(-6px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.menu-item:hover .arrow-right {
    opacity: 0.8;
    transform: translateX(0);
}

/* Modern Auth Links */
.auth-links {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-links a {
    padding: 10px 18px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    letter-spacing: -0.01em;
}

.auth-links .login-link {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-links .login-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.auth-links .signup-link {
    color: white;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.8), rgba(147, 51, 234, 0.8));
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.auth-links .signup-link:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(147, 51, 234, 0.9));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    body {
        padding-top: 100px;
    }
}

/* Chat List Unread Indicators */
.chat-unread-badge {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatBadgePulse 2s infinite;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.chat-unread-indicator {
    background: #ef4444;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes chatBadgePulse {
    0% {
        box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3), 0 0 0 0 rgba(239, 68, 68, 0.5);
    }

    50% {
        box-shadow: 0 3px 6px rgba(239, 68, 68, 0.4), 0 0 0 4px rgba(239, 68, 68, 0.1);
    }

    100% {
        box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3), 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* HTMX Loading states for chat lists */
#recent-conversations.htmx-indicator,
#all-users-list.htmx-indicator {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

#recent-conversations.htmx-indicator::after,
#all-users-list.htmx-indicator::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1000;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    body {
        padding-top: 160px;
    }

    .chat-unread-badge {
        min-width: 16px;
        height: 16px;
        font-size: 9px;
    }
}

.mobile-hamburger.active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scale(0) rotate(180deg);
}

.mobile-hamburger.active .hamburger-line:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
    background: linear-gradient(90deg, rgba(239, 68, 68, 1), rgba(220, 38, 38, 1));
}

/* Prevent body scroll when menu is open */
body.mobile-menu-open {
    overflow: hidden;
}