/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
header {
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 1rem 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #091435;
}

.logo img {
    height: 70px;
    width: auto;
    max-width: 280px;
    object-fit: contain;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-links a:hover {
    color: #3E5CAA;
}

/* Dropdown Styles */
.dropdown {
    position: relative;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.dropdown-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.dropdown:hover .dropdown-icon,
.dropdown.active .dropdown-icon {
    transform: rotate(180deg);
}

/* Standard dropdown for regular navigation items */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 280px;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    border: 1px solid rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
}

/* Mega menu for Properties and More dropdowns */
.dropdown.mega .dropdown-menu {
    min-width: 800px;
    max-width: min(1200px, 95vw);
    width: max-content;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem;
    position: absolute;
    z-index: 9999;
    box-sizing: border-box;
}

.dropdown.mega:hover .dropdown-menu,
.dropdown.mega.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Ensure mega menu stays within viewport */
@media (max-width: 1200px) {
    .dropdown.mega .dropdown-menu {
        min-width: 700px;
        max-width: 90vw;
        left: 50%;
        transform: translateX(-50%) translateY(-10px);
        width: 90vw !important;
    }

    .dropdown.mega:hover .dropdown-menu,
    .dropdown.mega.active .dropdown-menu {
        transform: translateX(-50%) translateY(0);
    }
}

@media (max-width: 900px) {
    .dropdown.mega .dropdown-menu {
        min-width: 600px;
        max-width: 85vw;
    }
}

.dropdown:hover .dropdown-menu,
.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Mega menu grid layout */
.mega-menu-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 3rem;
    width: 100%;
    min-width: 0;
}

.mega-menu-section {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mega-menu-section h4 {
    color: #3E5CAA;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f0f0f0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mega-menu-items {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.mega-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.mega-menu-section:first-child .mega-menu-items {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.mega-menu-section:nth-child(2) .mega-menu-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

/* Responsive adjustments for mega menu content */
@media (max-width: 1200px) {
    .mega-menu-content {
        grid-template-columns: 250px 1fr;
        gap: 2rem;
    }

    .mega-menu-section:nth-child(2) .mega-menu-items {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (max-width: 900px) {
    .mega-menu-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .mega-menu-section:nth-child(2) .mega-menu-items {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}

.mega-menu-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.mega-menu-item:hover {
    background: #f8f9fa;
    border-color: #e9ecef;
    color: #3E5CAA;
    transform: translateX(4px);
}

.mega-menu-item.featured {
    background: linear-gradient(135deg, #3E5CAA, #091435);
    color: white;
    font-weight: 600;
    border: none;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mega-menu-item.featured:hover {
    background: linear-gradient(135deg, #091435, #3E5CAA);
    color: white;
    transform: translateX(4px) translateY(-1px);
    box-shadow: 0 4px 15px rgba(62, 92, 170, 0.3);
}

.mega-menu-item .item-icon {
    color: #3E5CAA;
    font-size: 1.1rem;
    grid-column: 1;
}

.mega-menu-item.featured .item-icon {
    color: white;
    margin-right: 0.75rem;
}

.mega-menu-item .item-icon {
    margin-right: 0.75rem;
}

.mega-menu-item .area-name {
    grid-column: 2;
    font-weight: 500;
}

/* Property count styling for mega menu */
.mega-menu-item .property-count {
    color: #666;
    font-size: 0.85rem;
    font-weight: 600;
    background: #f0f0f0;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    grid-column: 3;
    text-align: center;
    min-width: 40px;
}

.mega-menu-item:hover .property-count {
    background: #3E5CAA;
    color: white;
}

.mega-menu-item.featured .property-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    margin-left: auto;
}

.mega-menu-item.featured:hover .property-count {
    background: white;
    color: #3E5CAA;
}

/* Selected area styling - red highlighting for user's default area */
.mega-menu-item.user-selected-area {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    font-weight: 600;
    border: none;
}

.mega-menu-item.user-selected-area .item-icon {
    color: white;
}

.mega-menu-item.user-selected-area .property-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.mega-menu-item.user-selected-area:hover {
    background: linear-gradient(135deg, #c82333, #dc3545);
    color: white;
    transform: translateX(4px) translateY(-1px);
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

.mega-menu-item.user-selected-area:hover .property-count {
    background: white;
    color: #dc3545;
}

/* Mega Menu Benefits Section - Desktop Only */
.mega-menu-benefits {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
    transition: all 0.3s ease;
}

.mega-menu-benefits:hover {
    border-color: #3E5CAA;
    box-shadow: 0 4px 15px rgba(62, 92, 170, 0.1);
}

.benefits-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    color: #3E5CAA;
    font-weight: 700;
    font-size: 1.1rem;
}

.benefits-header i {
    font-size: 1.3rem;
    color: #3E5CAA;
}

.benefits-intro {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.benefits-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
}

.benefits-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    color: #555;
    font-size: 0.85rem;
    line-height: 1.3;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.benefits-list li:last-child {
    border-bottom: none;
}

.benefits-list i {
    color: #3E5CAA;
    font-size: 0.9rem;
    width: 16px;
    text-align: center;
}

.benefits-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Logged-in User Info Styles */
.mega-menu-benefits.logged-in-user {
    background: linear-gradient(135deg, #e8f5e8 0%, #f0f8ff 100%);
    border-color: #28a745;
}

.mega-menu-benefits.logged-in-user:hover {
    border-color: #28a745;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.15);
}

.mega-menu-benefits.logged-in-user .benefits-header {
    color: #28a745;
}

.mega-menu-benefits.logged-in-user .benefits-header i {
    color: #28a745;
}

.user-info-grid {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.user-info-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #333;
    font-size: 0.9rem;
    line-height: 1.4;
}

.user-info-item i {
    color: #28a745;
    font-size: 0.85rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.user-info-item span {
    font-weight: 500;
}

.benefits-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.benefits-btn.login {
    background: #3E5CAA;
    color: white;
    border: 2px solid #3E5CAA;
}

.benefits-btn.login:hover {
    background: #091435;
    border-color: #091435;
    transform: translateY(-1px);
}

.benefits-btn.register {
    background: white;
    color: #3E5CAA;
    border: 2px solid #3E5CAA;
}

.benefits-btn.register:hover {
    background: #3E5CAA;
    color: white;
    transform: translateY(-1px);
}

.benefits-btn.dashboard {
    background: #28a745;
    color: white;
    border: none;
    flex: 1;
    text-align: center;
    gap: 0.5rem;
}

.benefits-btn.logout {
    background: #dc3545;
    color: white;
    border: none;
    flex: 1;
    text-align: center;
    gap: 0.5rem;
}

.benefits-btn.logout:hover {
    background: #c82333;
    color: white;
    transform: translateY(-1px);
}

/* Hide benefits section on mobile */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

/* Legacy dropdown styles for non-mega menus */
.dropdown-header {
    padding: 1rem 1.5rem 0.5rem;
    font-weight: 600;
    color: #3E5CAA;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 0.5rem;
}

.dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.dropdown-item:hover {
    background: #f8f9fa;
    border-left-color: #3E5CAA;
    color: #3E5CAA;
}

.dropdown-item.featured {
    background: linear-gradient(135deg, #3E5CAA, #091435);
    color: white;
    font-weight: 600;
    margin: 0.5rem;
    border-radius: 8px;
    border-left: none;
}

.dropdown-item.featured:hover {
    background: linear-gradient(135deg, #091435, #3E5CAA);
    color: white;
    transform: translateY(-1px);
}

.area-name {
    font-weight: 500;
}

.property-count {
    color: #666;
    font-size: 0.9rem;
    font-weight: 600;
    background: #f0f0f0;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
}

.dropdown-divider {
    height: 1px;
    background: #e9ecef;
    margin: 0.5rem 1rem;
}

.dropdown-item.disabled {
    color: #999;
    cursor: not-allowed;
}

.dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.dropdown-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Mega menu scrollbar styling */
.dropdown.mega .dropdown-menu::-webkit-scrollbar {
    width: 8px;
}

.dropdown.mega .dropdown-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
    margin: 0.5rem 0;
}

.dropdown.mega .dropdown-menu::-webkit-scrollbar-thumb {
    background: #3E5CAA;
    border-radius: 4px;
}

.dropdown.mega .dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #091435;
}

/* Ensure scrolling is smooth */
.dropdown.mega .dropdown-menu {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #3E5CAA #f1f1f1;
}

/* Add visual indicator when content is scrollable */
.dropdown.mega .dropdown-menu::before {
    content: '';
    position: sticky;
    top: 0;
    height: 0;
    background: linear-gradient(180deg, white 0%, transparent 100%);
    z-index: 1;
    pointer-events: none;
}

.dropdown.mega .dropdown-menu::after {
    content: '';
    position: sticky;
    bottom: 0;
    height: 0;
    background: linear-gradient(0deg, white 0%, transparent 100%);
    z-index: 1;
    pointer-events: none;
}

.back-link {
    color: #666;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.back-link:hover {
    color: #3E5CAA;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #091435;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.3s ease;
    z-index: 1000;
    position: relative;
}

.mobile-menu-btn:hover {
    color: #3E5CAA;
}

/* Active states for mobile */
.dropdown:hover .dropdown-menu,
.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown:hover .dropdown-icon,
.dropdown.active .dropdown-icon {
    transform: rotate(180deg);
}

/* Force mobile menu button to always be visible on small screens */
@media (max-width: 768px) {
    /* Hide map view on mobile devices */
    .dropdown-menu .dropdown-item[href*="map.php"] {
        display: none !important;
    }
    .dropdown-menu .dropdown-item[href*="map.php"] + .dropdown-divider {
        display: none !important;
    }

    /* Hide desktop nav links on mobile */
    .nav-links {
        display: none !important;
    }

    /* Show mobile menu button */
    .mobile-menu-btn {
        display: block !important;
        background: none !important;
        border: none !important;
        font-size: 1.5rem !important;
        color: #091435 !important;
        cursor: pointer !important;
        padding: 0.5rem !important;
        position: relative !important;
        z-index: 1000 !important;
    }

    /* Mobile mega menu adjustments */
    .dropdown.mega .dropdown-menu {
        position: fixed !important;
        top: 70px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        min-width: 100vw !important;
        max-width: 100vw !important;
        transform: translateY(-10px) !important;
        padding: 1rem !important;
        max-height: calc(100vh - 150px) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        background: white !important;
        z-index: 10000 !important;
        border-radius: 0 !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
        bottom: 70px !important;
    }

    .mega-menu-section:nth-child(2) .mega-menu-items {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
        gap: 0.5rem !important;
    }

    .dropdown.mega:hover .dropdown-menu,
    .dropdown.mega.active .dropdown-menu {
        transform: translateY(0) !important;
    }

    /* Ensure mega menu items are properly sized on mobile */
    .mega-menu-item {
        padding: 1rem !important;
        font-size: 0.9rem !important;
        min-height: auto !important;
    }

    .mega-menu-item .area-name {
        font-size: 0.9rem !important;
        line-height: 1.2 !important;
    }

    .mega-menu-item .property-count {
        font-size: 0.8rem !important;
        padding: 0.25rem 0.5rem !important;
    }

    .mega-menu-content {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        width: 100% !important;
    }

    .mega-menu-section {
        width: 100% !important;
    }

    .mega-menu-section h4 {
        font-size: 1rem !important;
        margin-bottom: 1.5rem !important;
    }

    .mega-menu-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 1.2rem 1rem !important;
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
        border: 1px solid #e9ecef !important;
        border-radius: 8px !important;
        gap: 0.5rem !important;
    }

    .mega-menu-item:not(.featured) .item-icon {
        display: none !important;
    }

    .mega-menu-item .area-name {
        font-weight: 600 !important;
        font-size: 1rem !important;
    }

    .mega-menu-item .property-count {
        font-size: 0.8rem !important;
        padding: 0.2rem 0.5rem !important;
        align-self: flex-start !important;
        margin: 0 !important;
    }

    /* Special handling for Vancouver Island Overview - ensure it appears above area pages on mobile */
    .mega-menu-section:nth-child(2) .mega-menu-items {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .mega-menu-section:nth-child(2) .mega-menu-item.featured {
        order: -10 !important;
        margin-bottom: 1.5rem !important;
        width: 100% !important;
    }

    .mega-menu-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        width: 100% !important;
        order: 10 !important;
    }

    /* Ensure all area links come after the featured Vancouver Island Overview */
    .mega-menu-grid .mega-menu-item {
        order: 20 !important;
    }

    /* Prevent background scrolling when mega menu is open */
    body.mega-menu-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
    }

    /* Mobile nav links styling */
    .nav-links.mobile-active {
        display: flex !important;
        flex-direction: column !important;
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        background: white !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
        border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
        z-index: 10000 !important;
        gap: 0 !important;
        max-height: calc(100vh - 150px) !important;
        overflow-y: auto !important;
        bottom: auto !important;
    }

    .nav-links.mobile-active li {
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    .nav-links.mobile-active li:last-child {
        border-bottom: none;
    }

    .nav-links.mobile-active a {
        padding: 1rem 1.5rem;
        display: block;
        width: 100%;
    }
}

    .back-link {
        display: none;
    }
}

/* User Dashboard Navigation */
.user-dashboard-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.dashboard-link {
    background: linear-gradient(135deg, #004CCC 0%, #0066FF 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.dashboard-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 76, 204, 0.3);
}

.user-menu {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.user-greeting {
    color: #091435;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logout-link {
    color: #dc3545;
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.logout-link:hover {
    background: rgba(220, 53, 69, 0.1);
}

/* Auth button styles are defined in auth.css to avoid conflicts */

@media (max-width: 768px) {
    .user-dashboard-nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    .user-menu {
        gap: 0.5rem;
        font-size: 0.9rem;
    }
}

    .nav-selected-agent {
        margin-left: 0.5rem;
    }

    .nav-agent-photo-container {
        width: 35px !important;
        height: 35px !important;
        border: 2px solid #3E5CAA !important;
    }
}

/* Selected Agent Photo in Navigation */
.nav-selected-agent {
    margin-left: 1rem;
    flex-shrink: 0;
}

.nav-agent-photo-container {
    width: 45px !important;
    height: 45px !important;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #3E5CAA;
    transition: all 0.3s ease;
}

.nav-agent-photo-container:hover {
    transform: scale(1.05);
    border-color: #091435;
}

.nav-agent-photo-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.3s ease;
}