/* Dropdown Menu Styles */
.dropdown {
    position: relative;
    display: inline-block;
    z-index: 1000;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem;
    cursor: pointer;
    color: var(--header-text-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
}

.dropdown-toggle::before {
    content: '\f107';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    right: 0.8rem;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: transform 0.3s ease, opacity 0.3s ease, color 0.3s ease;
}

.dropdown:hover .dropdown-toggle::before,
.dropdown.active .dropdown-toggle::before {
    transform: rotate(180deg);
    opacity: 1;
}

/* เปลี่ยนเส้นขีดด้านข้างเป็นเส้นใต้ข้อความ */
.dropdown-toggle::after {
    content: '';
    display: block;
    width: 0;
    height: 2px;
    background: var(--header-text-color);
    transition: width 0.3s ease;
    margin: 0 auto;
    position: absolute;
    bottom: 1.2rem;
    left: 0;
    right: 0;
    opacity: 0;
}

.dropdown:hover .dropdown-toggle::after,
.dropdown.active .dropdown-toggle::after {
    opacity: 1;
    width: 70%;
    height: 2px;
}

/* Dark theme */
body.dark-theme .dropdown-toggle::after {
    background: var(--header-text-color-dark);
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: rgba(255, 255, 255, 0.95);
    min-width: 220px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    display: none;
    z-index: 10000;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transform: translateY(10px);
    opacity: 0;
    pointer-events: none; /* Prevent clicks when hidden */
}

/* Desktop hover behavior */
@media (min-width: 769px) {
    .dropdown:hover .dropdown-content {
        display: block;
        transform: translateY(0);
        opacity: 1;
        animation: fadeIn 0.3s ease forwards;
        pointer-events: auto; /* Allow clicks when visible */
    }
}

/* Active state for both desktop and mobile */
.dropdown.active .dropdown-content {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
    z-index: 1000 !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    font-weight: 400;
    font-size: 0.95rem;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
    transform: translateX(5px);
}

.dropdown-item i {
    margin-right: 0.75rem;
    color: var(--secondary-color);
    font-size: 1rem;
    width: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.dropdown-item:hover i {
    color: var(--primary-color);
}

/* Dark Theme Styles */
body.dark-theme .dropdown-toggle {
    color: var(--header-text-color-dark);
}

body.dark-theme .dropdown-toggle:hover,
body.dark-theme .dropdown.active .dropdown-toggle {
    background-color: rgba(0, 0, 0, 0.3);
}

body.dark-theme .dropdown-content {
    background-color: rgba(40, 40, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

body.dark-theme .dropdown-item {
    color: var(--text-color-dark);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark-theme .dropdown-item i {
    color: var(--secondary-color-light);
}

body.dark-theme .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .dropdown-item:hover i {
    color: var(--primary-color-light);
}

/* Add rotation for dropdown toggle in mobile active state */
.dropdown.active .dropdown-toggle::before {
    transform: rotate(180deg);
}

/* Add transition effect for dropdown items */
.dropdown-item {
    transform: translateX(0);
    opacity: 1;
    transition: transform 0.3s ease, opacity 0.3s ease, background-color 0.3s ease;
}

.dropdown.active .dropdown-item {
    transform: translateX(0);
    opacity: 1;
}

/* Stagger animation for dropdown items */
.dropdown.active .dropdown-item:nth-child(1) {
    transition-delay: 0.05s;
}

.dropdown.active .dropdown-item:nth-child(2) {
    transition-delay: 0.1s;
}

.dropdown.active .dropdown-item:nth-child(3) {
    transition-delay: 0.15s;
}

.dropdown.active .dropdown-item:nth-child(4) {
    transition-delay: 0.2s;
}

.dropdown.active .dropdown-item:nth-child(5) {
    transition-delay: 0.25s;
}

.dropdown:hover .dropdown-toggle,
.dropdown.active .dropdown-toggle {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--header-text-color);
}

body.dark-theme .dropdown:hover .dropdown-toggle,
body.dark-theme .dropdown.active .dropdown-toggle {
    background-color: rgba(0, 0, 0, 0.3);
    color: var(--header-text-color-dark);
}

/* Mobile Dropdown Styles - Override hover behavior on mobile */
@media (max-width: 768px) {
    /* Disable hover effects on mobile */
    .dropdown:hover .dropdown-content {
        display: none !important;
        transform: none !important;
        opacity: 0 !important;
        animation: none !important;
        pointer-events: none !important;
    }
    
    /* Remove conflicting styles */
    .dropdown-content {
        position: static !important;
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        max-height: 0 !important;
        overflow: hidden !important;
        transition: none !important;
    }
    
    /* Improved styling for dropdown items on mobile */
    .dropdown-item {
        opacity: 1 !important;
        transform: translateY(0) !important;
        display: flex !important;
        width: 100% !important;
        padding: 0.75rem 1rem !important;
        font-size: 1rem !important;
        margin: 0.3rem 0 !important;
        text-align: left !important;
        justify-content: flex-start !important;
        align-items: center !important;
        background-color: rgba(255, 255, 255, 0.1) !important;
        border-radius: 8px !important;
        color: white !important;
        border: none !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
        transition: transform 0.3s ease, background-color 0.3s ease !important;
    }
    
    .dropdown-item:hover, 
    .dropdown-item:active {
        background-color: rgba(255, 255, 255, 0.2) !important;
        transform: scale(1.02) !important;
    }
    
    .dropdown-item i {
        margin-right: 0.75rem !important;
        font-size: 1rem !important;
        color: rgba(255, 255, 255, 0.9) !important;
    }
    
    /* Remove close button and title for dropdown */
    .dropdown-content::before,
    .dropdown-content::after {
        display: none !important;
    }
    
    /* Stagger animation for dropdown items */
    .dropdown.active .dropdown-item {
        animation: fadeIn 0.3s forwards;
        opacity: 0;
    }
    
    .dropdown.active .dropdown-item:nth-child(1) {
        animation-delay: 0.05s;
    }
    
    .dropdown.active .dropdown-item:nth-child(2) {
        animation-delay: 0.1s;
    }
    
    .dropdown.active .dropdown-item:nth-child(3) {
        animation-delay: 0.15s;
    }
    
    .dropdown.active .dropdown-item:nth-child(4) {
        animation-delay: 0.2s;
    }
    
    .dropdown.active .dropdown-item:nth-child(5) {
        animation-delay: 0.25s;
    }
    
    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateY(5px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* Remove conflicting iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    .dropdown-content {
        /* Fix for iOS Safari */
        -webkit-backdrop-filter: blur(5px);
        backdrop-filter: blur(5px);
    }
    
    /* Remove fixed positioning */
    .dropdown.active .dropdown-content {
        -webkit-transform: none !important;
        transform: none !important;
    }
    
    /* Fix for iOS touch events */
    .dropdown-toggle {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Remove conflicting iOS device styles */
.ios-device .dropdown-toggle {
    /* Ensure touch events work correctly */
    cursor: pointer;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Remove conflicting dropdown active styles */
body.dropdown-active .dropdown.active .dropdown-content {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Remove conflicting mobile styles */
@media (max-width: 768px) {
    body.dropdown-active .dropdown.active .dropdown-content {
        position: static !important;
    }
    
    .dropdown-content {
        transition: none !important;
    }
}

/* Additional styles for when a dropdown is active */
body.dropdown-active .dropdown.active .dropdown-content {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 1000 !important;
}

/* Add backdrop for mobile dropdown */
.dropdown-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.1); /* Further reduced opacity */
    z-index: 990; /* Lower z-index to not interfere with content */
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: auto; /* Ensure clicks are captured */
}

.dropdown-backdrop.active {
    opacity: 1;
}

@media (max-width: 768px) {
    body.dropdown-active .dropdown.active .dropdown-content {
        position: fixed !important;
        top: 60px !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
    }
}

/* Mobile specific styles */
@media (max-width: 768px) {
    .dropdown-content {
        transition: all 0.3s ease !important;
    }
    
    .dropdown.active .dropdown-content {
        max-height: 1000px !important; /* Ensure enough height for all items */
    }
    
    .dropdown-item {
        width: 100%;
        box-sizing: border-box;
    }
} 