:root {
    /* Light Theme (Default) */
    --bg-body: #f1f1f1;
    /* Slightly lighter/cleaner grey */
    --text-main: #343a40;
    /* Dark grey for better readability */
    --text-muted: #6c757d;
    --container-bg: #ffffff;
    --header-bg: #ffffff;
    --border-color: #dee2e6;

    --table-th-bg: #1f2937;
    /* Keep dark header as requested */
    --table-th-text: #ffffff;
    --table-th-border: #374151;

    --table-row-odd: #ffffff;
    --table-row-even: #f8f9fa;
    --table-hover: #e9ecef;

    --input-bg: #ffffff;
    --input-text: #495057;
    --input-border: #ced4da;

    --shadow-card: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --backdrop-blur: 0px;

    --scrollbar-track: #f1f1f1;
    --scrollbar-thumb: #888;

    --accent-color: #17a2b8;
    /* Cyan/Teal */
    --title-color: #0d4e58;
    /* Dark Teal for Titles */

    /* Nav Tabs */
    --nav-bg: #ffffff;
    /* White background for Nav items */
    --nav-text: #495057;
    --nav-active-bg: #ffc107;
    /* Gold/Yellow */
    --nav-active-text-color: #000000;
    --nav-border: #ffffff;
    /* Match bg to look seamless or subtle grey */
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-body: #1a1a2e;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --container-bg: rgba(255, 255, 255, 0.03);
    --header-bg: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.18);

    --table-th-bg: #000000;
    --table-th-text: #ffffff;
    --table-th-border: #444444;

    --table-row-odd: rgba(255, 255, 255, 0.03);
    --table-row-even: rgba(0, 0, 0, 0.2);
    --table-hover: rgba(0, 212, 255, 0.1);

    --input-bg: rgba(255, 255, 255, 0.1);
    --input-text: #ffffff;
    --input-border: rgba(255, 255, 255, 0.2);

    --shadow-card: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    --backdrop-blur: 10px;

    --scrollbar-track: rgba(255, 255, 255, 0.05);
    --scrollbar-thumb: #00bcd4;

    --nav-bg: rgba(255, 255, 255, 0.20);
    --nav-border: rgba(255, 255, 255, 0.20);
    --nav-text: #e7e6e6;
    --nav-active-bg: rgba(0, 212, 255, 0.2);
    /* Cyan tint for dark mode active */
    --nav-active-text-color: #fff;
    --title-color: #00d4ff;
    /* Cyan for Dark Mode Titles */
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
    font-family: 'Almarai', sans-serif;
}

button,
input,
select,
textarea,
.btn,
.nav-tab,
.control-btn,
.refresh-btn,
.search-box {
    font-family: 'Almarai', sans-serif !important;
}

.table-container {
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(var(--backdrop-blur));
}

header {
    background: var(--header-bg);
    backdrop-filter: blur(var(--backdrop-blur));
    position: relative;
    z-index: 1002;
}

th {
    background: var(--table-th-bg) !important;
    color: var(--table-th-text) !important;
    border: 1px solid var(--table-th-border) !important;
}

td {
    border-bottom: 1px solid var(--border-color) !important;
}

tbody tr:nth-child(odd) {
    background: var(--table-row-odd);
}

tbody tr:nth-child(even) {
    background: var(--table-row-even);
}

tr:hover {
    background: var(--table-hover) !important;
}

.search-box,
select,
input[type="text"] {
    background: var(--input-bg) !important;
    color: var(--input-text) !important;
    border: 1px solid var(--input-border) !important;
}

.nav-tab {
    background: var(--nav-bg);
    color: var(--nav-text);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    /* Rounded corners like image */
    padding: 8px 16px;
    font-weight: bold;
    text-decoration: none;
    transition: all 0.3s ease;
}

.nav-tab:hover {
    background: var(--table-hover);
    transform: translateY(-2px);
}

.nav-tab.active {
    background: var(--nav-active-bg) !important;
    color: var(--nav-active-text-color) !important;
    border-color: var(--nav-active-bg) !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Specific fix for H1 title color */
h1,
.page-title {
    color: var(--title-color) !important;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: var(--header-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
}

.theme-toggle-btn:hover {
    transform: scale(1.1);
    background: var(--table-hover);
}

/* Label styling for Filters/Search */
label,
.filter-label {
    color: #17a2b8;
    /* Cyan Blue Fixed Color or var if needed */
    font-weight: bold;
}

[data-theme="dark"] label,
[data-theme="dark"] .filter-label {
    color: #00d4ff;
    /* Lighter Cyan for Dark Mode */
}

/* ================= Custom Dropdown Styles ================= */
.custom-dropdown {
    position: relative;
    width: 320px;
    /* Fixed width matching previous select */
    font-family: 'Almarai', sans-serif;
    user-select: none;
    z-index: 1001;
    display: inline-block;
    vertical-align: middle;
}

.custom-dropdown .dropdown-selected {
    background: var(--input-bg);
    color: var(--input-text);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    transition: all 0.3s;
    height: 42px;
    /* Consistent height */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.custom-dropdown .dropdown-selected:hover {
    border-color: var(--accent-color);
}

.custom-dropdown .dropdown-options {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background: var(--bg-body);
    /* Use body bg for solid look */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    display: none;
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    /* Stronger shadow */
    /* Removed backdrop-filter to ensure readability if bg is solid */
    animation: fadeInDropdown 0.2s ease-out;
}

.custom-dropdown.open .dropdown-options {
    display: block;
}

.custom-dropdown .dropdown-option {
    padding: 12px 15px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.custom-dropdown .dropdown-option:hover {
    background: var(--table-hover);
    padding-right: 20px;
    /* Subtle movement */
}

.custom-dropdown .dropdown-option.selected {
    background: rgba(23, 162, 184, 0.1);
    color: var(--accent-color);
    border-left: 3px solid var(--accent-color);
}

/* Flag Image Styling */
.flag-icon {
    width: 24px;
    height: 18px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.arrow-icon {
    font-size: 0.8rem;
    transition: transform 0.3s;
    opacity: 0.7;
}

.custom-dropdown.open .arrow-icon {
    transform: rotate(180deg);
}

@keyframes fadeInDropdown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}