﻿/* Import modern fonts */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');
/* Root variables for theming - Dark theme as default */
:root {
    --bg-light: #f5f5f5;
    --bg-dark: #181818;
    --card-light: #fff;
    --card-dark: #282828;
    --text-light: #030303;
    --text-dark: #f1f1f1;
    --accent: #ff0000;
    --hover: rgba(255, 255, 255, 0.05);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --background: var(--bg-dark);
    --card: var(--card-dark);
    --text: var(--text-dark);
}

/* Force dark theme for light-preferring devices */
@media (prefers-color-scheme: light) {
    :root {
        --background: var(--bg-dark);
        --card: var(--card-dark);
        --text: var(--text-dark);
        --hover: rgba(255, 255, 255, 0.05);
    }
}

/* Light mode override */
.light-mode {
    --background: var(--bg-light);
    --card: var(--card-light);
    --text: var(--text-light);
    --hover: rgba(0, 0, 0, 0.05);
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
    background: var(--card);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
}

/* Header top wrapper */
.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* Logo */
.logo {
    font-family: 'Roboto', sans-serif;
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.logo-hidden {
    opacity: 0.6;
    font-style: italic;
    color: var(--text);
}

.logo-meme {
    margin-left: 2px;
    color: var(--accent);
}

/* Navbar toggle button (hidden on desktop) */
.navbar-toggle-btn {
    display: none;
    background: none;
    border: none;
    padding: 0;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    border-radius: 4px;
}

    .navbar-toggle-btn:hover {
        background: var(--hover);
    }

/* Search toggle button (hidden on desktop) */
.search-toggle-btn {
    display: none;
    background: none;
    border: none;
    padding: 0;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    border-radius: 4px;
}

    .search-toggle-btn:hover {
        background: var(--hover);
    }

/* Search container */
.search-container {
    flex: 1;
    max-width: 600px;
    margin: 0 24px;
}

    .search-container form {
        display: flex;
        align-items: center;
    }

    .search-container input[type="search"] {
        width: 100%;
        padding: 8px 16px;
        border: 1px solid #444;
        border-radius: 24px 0 0 24px;
        font-size: 14px;
        outline: none;
        background: #121212;
        color: var(--text);
    }

.light-mode .search-container input[type="search"] {
    background: var(--card);
    border-color: #ccc;
}

.search-container button {
    padding: 8px 16px;
    border: 1px solid #444;
    border-left: none;
    border-radius: 0 24px 24px 0;
    background: #333;
    cursor: pointer;
}

.light-mode .search-container button {
    background: #f8f8f8;
    border-color: #ccc;
}

/* Header right grouping */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Standardized icon buttons (excluding theme toggle) */
.upload-btn,
.menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    padding: 0;
    color: var(--text); /* Use theme-aware text color instead of hard-coded white */
    font-size: 20px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s ease, color 0.3s ease;
}

    .upload-btn:hover,
    .menu-btn:hover {
        background: var(--hover);
    }

    /* Upload button specific */
    .upload-btn:hover {
        color: var(--accent);
    }


/* Menu button dropdown logic */
.menu-btn:hover + .dropdown,
.dropdown:hover {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0s linear;
}

.dropdown {
    display: block;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card);
    border-radius: 8px;
    border: 1px solid #444;
    box-shadow: var(--shadow);
    min-width: 180px;
    padding: 8px 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s linear 0.3s;
    overflow: visible;
}

.light-mode .dropdown {
    border-color: #ccc;
}

.dropdown a {
    display: block;
    padding: 10px 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    transition: background 0.2s ease;
}

    .dropdown a:hover {
        background: var(--hover);
        color: var(--accent);
    }

/* Nested dropdown for Admin Stats */
.dropdown-parent {
    position: relative;
    z-index: 1000;
}

.dropdown-toggle {
    display: block;
    padding: 10px 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    transition: background 0.2s ease;
}

    .dropdown-toggle:hover {
        background: var(--hover);
        color: var(--accent);
    }

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%; /* Below parent */
    left: 0; /* Aligned with parent */
    background: var(--card);
    border-radius: 8px;
    border: 1px solid #444;
    box-shadow: var(--shadow);
    min-width: 200px;
    padding: 8px 0;
    z-index: 10000;
    visibility: visible;
    opacity: 1;
}

.light-mode .dropdown-menu {
    border-color: #ccc;
}

.dropdown-menu a {
    display: block;
    padding: 10px 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s ease;
}

    .dropdown-menu a:hover {
        background: var(--hover);
        color: var(--accent);
    }

/* Enhanced Mobile Responsiveness */
@media (max-width: 900px) {
    .search-container {
        display: none;
    }

    .navbar-toggle-btn,
    .search-toggle-btn {
        display: flex;
    }
}

@media (max-width: 600px) {
    .search-container {
        display: none;
    }

    .navbar-toggle-btn,
    .search-toggle-btn {
        display: flex;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0 10px;
    }

    .logo {
        font-size: 18px;
    }

    .navbar-toggle-btn,
    .search-toggle-btn,
    .themetogglebutton,
    .upload-btn,
    .menu-btn {
        width: 28px;
        height: 28px;
        font-size: 18px;
    }
}

@media (max-width: 360px) {
    .header {
        padding: 0 5px;
    }

    .logo {
        font-size: 18px;
    }

    .navbar-toggle-btn,
    .search-toggle-btn,
    .themetogglebutton,
    .upload-btn,
    .menu-btn {
        width: 28px;
        height: 28px;
        font-size: 18px;
    }
}
