/* header-styles.css */

/* --- Variables (Dark Mode) --- */
:root {
    --bg-primary: #1e1e1e; /* Main background */
    --bg-secondary: #252526; /* Header/Card background */
    --text-primary: #f0f0f0; /* Main text color */
    --text-secondary: #cccccc; /* Secondary text/muted color */
    --accent-blue: #007acc; /* Highlight color for links/buttons */
    --accent-green: #4caf50; /* Admin link color */
    --border-color: #3f3f46; /* Border/divider color */
    --hover-bg: #3c3c3c; /* Hover background color */
}

/* ------------------------------------------------------------------
 * 1. GLOBAL & BODY (Prevent horizontal scroll/overflow)
 * ------------------------------------------------------------------ */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: Arial, sans-serif; 
    margin: 0;
    padding: 0;
    /* Essential: Prevents body content from overflowing the viewport */
    overflow-x: hidden; 
}

/* Ensure all elements within the body do not create overflow */
* {
    /* Ensures long words break to the next line instead of overflowing */
    word-wrap: break-word; 
    /* The box model determines total size including padding/border, which aids layout calculation */
    box-sizing: border-box; 
}

/* --- Action Banner --- */
.action-banner {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 10px 20px;
    text-align: center;
    font-size: 0.95rem;
    /* Ensure text within the banner wraps */
    word-break: break-word; 
    hyphens: auto; 
}


/* ------------------------------------------------------------------
 * 2. HEADER & LAYOUT
 * ------------------------------------------------------------------ */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 0;
    z-index: 1000;
    /* Ensure the header itself doesn't cause overflow */
    min-width: 100%; 
}

.header-left .header-logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    text-decoration: none;
}

.header-right {
    display: flex;
    align-items: center;
    /* Use flex-shrink to allow elements to shrink if space is tight */
    flex-shrink: 1; 
    gap: 15px; 
}

/* --- Icon Buttons --- */
.header-icon-btn {
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 8px;
    border-radius: 5px;
    transition: color 0.2s, background-color 0.2s;
}

.header-icon-btn:hover {
    color: var(--text-primary);
    background-color: var(--hover-bg);
}


/* ------------------------------------------------------------------
 * 3. PROFILE CARD & DROPDOWN (Contain long username)
 * ------------------------------------------------------------------ */
.profile-menu-container {
    position: relative; 
    /* Allows the container to shrink */
    flex-shrink: 1; 
    /* Sets a minimum size for the profile card area */
    min-width: 0; 
}

.profile-card {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    background-color: var(--bg-primary);
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid var(--border-color);
    /* Essential: Prevents the profile card from growing indefinitely */
    max-width: 100%; 
}

.profile-card:hover {
    background-color: var(--hover-bg);
}

.profile-pfp {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
}

.profile-username {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-right: 8px; /* Space before the caret */
    /* Force text to stay on one line, but overflow hidden/truncated */
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    /* Allows username to shrink when space runs out */
    flex-shrink: 1; 
    min-width: 20px; 
}

/* Caret Icon Style */
.profile-card .caret-icon {
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

/* Rotate caret when dropdown is active */
.profile-card.active .caret-icon {
    transform: rotate(180deg);
}

/* --- Dropdown Menu --- */
.header-style-dropdown {
    display: none; /* Hidden by default */
    position: absolute;
    top: 100%; /* Position below the profile card */
    right: 0;
    margin-top: 10px;
    width: 220px; /* Fixed width */
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1001;
    overflow: hidden; 
}

.header-style-dropdown a {
    display: block;
    padding: 10px 15px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    word-break: break-word; /* Ensure dropdown links wrap if too long */
}

.header-style-dropdown a:hover {
    background-color: var(--hover-bg);
}

.header-style-dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 5px 0;
}

.header-style-dropdown a.admin-link {
    color: var(--accent-green) !important;
    font-weight: bold;
}

/* --- Dropdown Activation (via JS) --- */
.header-style-dropdown.active {
    display: block;
}

/* ------------------------------------------------------------------
 * 4. MOBILE RESPONSIVENESS (Adjustments for small screens)
 * ------------------------------------------------------------------ */
@media (max-width: 600px) {
    .main-header {
        /* Reduce padding on very small screens */
        padding: 5px 10px; 
    }

    .header-right {
        /* Reduce gap for more space */
        gap: 8px; 
    }
    
    .header-icon-btn {
        /* Reduce padding on icons to save space */
        padding: 6px; 
    }

    /* Hide the username on smaller phones to save critical space */
    .profile-card .profile-username {
        display: none;
    }
}