/* Dark mode wrapper */
.fd-dark-wrapper.dark-mode { 
    background-color: #333333 !important; 
}

/* Only change text color to white when background is dark */
.fd-dark-wrapper.dark-mode,
.fd-dark-wrapper.dark-mode [style*="background-color: #333"],
.fd-dark-wrapper.dark-mode [style*="background-color: #333333"],
.fd-dark-wrapper.dark-mode [style*="background-color: #222"],
.fd-dark-wrapper.dark-mode [style*="background-color: #000"],
.fd-dark-wrapper.dark-mode [style*="background-color: #1a1a1a"],
.fd-dark-wrapper.dark-mode [style*="background-color: #2d2d2d"],
.fd-dark-wrapper.dark-mode [style*="background-color: #444"],
.fd-dark-wrapper.dark-mode [style*="background-color: #555"] {
    color: #ffffff !important;
}

/* Logo inversion */
.fd-dark-wrapper.dark-mode header a img { 
    filter: brightness(0) invert(1); 
}

/* Links and headings - only on dark backgrounds */
.fd-dark-wrapper.dark-mode a:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode h1:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode h2:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode h3:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode h4:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode h5:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode h6:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]) { 
    color: #ffffff !important; 
}

/* All text, inputs, labels, tables - only on dark backgrounds */
.fd-dark-wrapper.dark-mode p:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode li:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode span:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode div:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode td:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode th:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]),
.fd-dark-wrapper.dark-mode label:not([style*="background-color: #fff"]):not([style*="background-color: white"]):not([style*="background-color: #eee"]):not([style*="background-color: #eeeeee"]) { 
    color: #ffffff !important; 
    border-color: #666 !important; 
}

/* Input backgrounds */
.fd-dark-wrapper.dark-mode input,
.fd-dark-wrapper.dark-mode textarea,
.fd-dark-wrapper.dark-mode select { 
    background-color: #333 !important; 
    color: #ffffff !important; 
    border-color: #666 !important; 
}

/* Mobile dropdown menu fixes */
.fd-dark-wrapper.dark-mode .menu-toggle,
.fd-dark-wrapper.dark-mode .mobile-menu,
.fd-dark-wrapper.dark-mode .sub-menu,
.fd-dark-wrapper.dark-mode .dropdown-menu,
.fd-dark-wrapper.dark-mode .nav-menu,
.fd-dark-wrapper.dark-mode .main-navigation div,
.fd-dark-wrapper.dark-mode #mobile-menu,
.fd-dark-wrapper.dark-mode #main-menu,
.fd-dark-wrapper.dark-mode [class*="menu"] { 
    background-color: #333 !important; 
    border-color: #333 !important; 
    color: #ffffff !important;
}

/* Menu items */
.fd-dark-wrapper.dark-mode .menu-item,
.fd-dark-wrapper.dark-mode .nav-item,
.fd-dark-wrapper.dark-mode .menu-toggle,
.fd-dark-wrapper.dark-mode li a { 
    background-color: #333 !important; 
    color: #ffffff !important; 
    border-color: #333 !important; 
}

/* Menu item hover states */
.fd-dark-wrapper.dark-mode .menu-item:hover,
.fd-dark-wrapper.dark-mode .nav-item:hover,
.fd-dark-wrapper.dark-mode li a:hover,
.fd-dark-wrapper.dark-mode .menu-toggle:hover { 
    background-color: #555 !important; 
    color: #ffffff !important; 
}

/* Sub-menus and dropdowns */
.fd-dark-wrapper.dark-mode .sub-menu,
.fd-dark-wrapper.dark-mode .dropdown-menu { 
    background-color: #555 !important; 
}
.fd-dark-wrapper.dark-mode .sub-menu li,
.fd-dark-wrapper.dark-mode .dropdown-menu li { 
    background-color: #555 !important; 
}
.fd-dark-wrapper.dark-mode .sub-menu li a,
.fd-dark-wrapper.dark-mode .dropdown-menu li a { 
    background-color: #555 !important; 
    color: #ffffff !important; 
}

/* Toggle wrapper */
.fd-toggle-wrap { 
    position: fixed; 
    bottom: 20px; 
    right: 20px; 
    z-index: 9999; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    font-family: sans-serif; 
    font-size: 14px; 
    color: #333; 
    padding: 6px 10px; 
    border-radius: 20px; 
    background: rgba(255, 255, 255, 0.9); 
    border: 1px solid #333; 
    box-shadow: 0 0 5px rgba(0, 0, 0, .15); 
}

/* Dark mode toggle wrapper */
.fd-dark-wrapper.dark-mode + .fd-toggle-wrap .fd-toggle-label { 
    color: #fff !important; 
}
.fd-dark-wrapper.dark-mode + .fd-toggle-wrap { 
    border: 1px solid #fff; 
    background: rgba(51, 51, 51, 0.9); 
}

/* Switch styles */
.fd-switch { 
    position: relative; 
    display: inline-block; 
    width: 50px; 
    height: 28px; 
}
.fd-switch input { 
    opacity: 0; 
    width: 0; 
    height: 0; 
}
.fd-slider { 
    position: absolute; 
    cursor: pointer; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    background-color: #ccc; 
    transition: .4s; 
    border-radius: 28px; 
}
.fd-slider:before { 
    position: absolute; 
    content: ""; 
    height: 22px; 
    width: 22px; 
    left: 3px; 
    bottom: 3px; 
    background-color: white; 
    transition: .4s; 
    border-radius: 50%; 
}
.fd-switch input:checked + .fd-slider { 
    background-color: #4caf50; 
}
.fd-switch input:checked + .fd-slider:before { 
    transform: translateX(22px); 
}