/* Core Styles - Reset, Base, Menu, Buttons, Forms, Notifications */

/* =============== Reset and Base Styles =============== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* =============== Scrollbar Styles =============== */
/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--theme-scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--theme-scrollbar-thumb-hover);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--theme-scrollbar-thumb) transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Background controlled by colorSchemeManager.js */
    height: 100vh;
    overflow: hidden;
}

/* =============== Menu Bar =============== */
.menu-bar {
    /* Background controlled by colorSchemeManager.js */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.menu-container {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    padding: 0 20px;
    height: 40px;
    min-height: 40px;
    max-height: 40px;
    position: relative;
    overflow: visible;
}

.logo {
    margin-right: 0;
    display: flex;
    align-items: center;
    min-width: 150px; /* Prevent layout shift while image loads */
}

.logo-image {
    height: 38px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

.menu-items {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    flex: 1;
    overflow: hidden; /* Prevent overflow */
    justify-content: flex-start; /* Pack items to the left */
    position: relative; /* Allow absolute positioning of children */
}

.menu-spacer {
    flex: 1; /* Take up available space, pushing Login to the right */
}

.menu-right-section {
    display: flex;
    gap: 0;
    align-items: center;
    /* Removed fixed min-width to allow flexible sizing based on visible items */
    justify-content: flex-start;
}

.menu-user-group {
    display: flex;
    gap: 0;
    min-width: 140px; /* Reserve space for Profile + Login/Logout */
    justify-content: flex-end; /* Align items to the right */
}

.menu-left {
    display: flex;
    gap: 0;
}

/* Menu-center no longer used - Store, Cart, Contact moved to main menu-items */

.menu-right {
    display: flex;
    gap: 0;
}

/* =============== Unified Menu Base Class =============== */
.menu-base {
    /* Element behavior */
    text-decoration: none;
    cursor: pointer;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;

    /* Layout */
    display: inline-flex;
    align-items: center;

    /* Spacing - consistent across all menus */
    padding: 0 4px;

    /* Typography */
    font-size: 14px;
    line-height: 1.4;
    font-weight: 500;

    /* Colors controlled by colorSchemeManager.js - do NOT set here */

    /* Animation */
    transition: color 0.2s ease, background-color 0.2s ease;
}

/* Reset button styling when used with .menu-base */
button.menu-base {
    border: none;
    background: none;
    font-family: inherit;
}

.menu-base:hover,
.menu-base.active {
    background-color: transparent;
    text-decoration: none; /* Override global a:hover underline */
    /* Color controlled by colorSchemeManager.js - do NOT set here */
}

/* =============== Unified Text Wrapper =============== */
.menu-text {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

/* Single underline definition for ALL menus */
.menu-text::before {
    content: '';
    position: absolute;
    bottom: -2px; /* Moved down 2px to ensure visibility */
    left: 0px;
    right: 0px;
    height: 2px; /* Made thicker for visibility */
    background: currentColor;
    transform: scale3d(0, 1, 1);
    transform-origin: left center;
    transition: transform 0.3s ease;
}

/* Show on hover/active for ALL menu types */
.menu-base:hover .menu-text::before,
.menu-base.active .menu-text::before {
    transform: scale3d(1, 1, 1);
}

/* =============== Nav Menu Item =============== */
.menu-item {
    /* Inherits from .menu-base */
    /* Color and text-shadow controlled by colorSchemeManager.js */
    border-radius: 4px;
    height: 32px;
    flex-shrink: 0; /* Don't shrink menu items by default */
    flex-grow: 0; /* Don't grow menu items */
    white-space: nowrap; /* Prevent text wrapping */
    opacity: 1 !important; /* Ensure full opacity - no graying out */
}

/* Menu items for non-logged-in users - show normally, prompt login on click */
.menu-item-hidden {
    display: inline-flex !important; /* Force visibility and flex for vertical centering */
    visibility: visible !important; /* Override any hidden */
    width: auto !important; /* Override width: 0 */
    align-items: center !important; /* Vertically center content */
    cursor: pointer !important;
    pointer-events: auto !important;
    opacity: 1 !important; /* Ensure full opacity - no graying out */
    /* No special styling - appears same as logged-in menu items */
}


/* Profile menu item - no special styling needed since it always shows "Profile" */

/* Store and Cart - fixed position in menu */
.menu-item[href="#store"],
.menu-item[href="#cart"] {
    position: absolute;
    left: 50%;
    opacity: 1 !important; /* Ensure full opacity - no graying out */
}

.menu-item[href="#store"] {
    transform: translateX(-133px); /* Position Store to left of center */
}

.menu-item[href="#cart"] {
    transform: translateX(-63px); /* Position Cart to right of center */
}

/* Admin menu item - still hide completely when hidden (admin is special) */
.menu-item[href="#admin"].menu-item-hidden {
    display: none !important;
}

/* Logout link in header (right side, under profile) */
.header-logout-link {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%) translateY(-40px);
    opacity: 0;
    transition: all 0.3s ease 1s;
    pointer-events: auto;
    min-width: 60px;
    text-align: right;
    visibility: hidden;
    z-index: 1000;
}

/* Show Logout/Login when hovering over Profile */
body:has(.menu-item[href="#profile"]:hover) .header-logout-link {
    transform: translateY(-50%) translateY(-5px);
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

/* Keep visible when hovering logout itself */
.header-logout-link:hover {
    transform: translateY(-50%) translateY(-5px) !important;
    opacity: 1 !important;
    visibility: visible !important;
    transition-delay: 0s !important;
}

/* Support menu item styling - REMOVED to match other menu items */
/* The support menu item now uses default menu item styling */

/* All menu unread counters - consistent styling */
.menu-item[href="#forum"] .tab-counter,
.menu-item[href="#messages"] .tab-counter,
.menu-item[href="#support"] .tab-counter,
.menu-item[href="#cart"] .tab-counter {
    position: relative;
    z-index: 15;
}

/* Ensure active menu items don't cover their counters */
.menu-item.active {
    z-index: 1;
}

/* General menu counter positioning */
.menu-item .tab-counter {
    z-index: 20;
    position: relative;
}

/* =============== Mobile Hamburger =============== */
.hamburger {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-right: 12px; /* Space between hamburger and logo */
    order: -1; /* Ensure hamburger stays first in flex order */
}

.hamburger span {
    width: 20px;
    height: 2px;
    background: var(--theme-text-primary);
    margin: 2px 0;
    transition: 0.3s;
}

/* =============== Mobile Menu =============== */
.mobile-menu {
    display: none;
    flex-direction: column;
    background: var(--theme-bg-primary);
    border-top: 1px solid var(--theme-border-light);
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: calc(100vh - 40px); /* Limit to viewport height minus menu bar */
    overflow-y: auto; /* Enable vertical scrolling when content exceeds max-height */
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

.mobile-menu-item {
    text-decoration: none;
    color: var(--theme-text-primary);
    padding: 8px 20px;
    border-bottom: 1px solid var(--theme-border-light);
}

.mobile-menu-item:hover {
    background-color: var(--theme-menu-hover-bg); /* Light blue tint for better visibility */
}

.mobile-menu-item.active {
    background-color: var(--theme-btn-primary-bg);
    color: var(--theme-text-on-primary);
}

/* Mobile menu items for non-logged-in users - show normally, prompt login on click */
.mobile-menu-item.menu-item-hidden {
    display: block !important; /* Force visibility */
    visibility: visible !important; /* Override any hidden */
    cursor: pointer !important;
    pointer-events: auto !important;
    /* No special styling - appears same as logged-in menu items */
}

/* =============== Header Bar =============== */
.header-bar {
    background: var(--theme-header-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--theme-header-border);
    position: fixed;
    top: 40px;
    left: 0;
    right: 0;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    /* Color and text-shadow controlled by colorSchemeManager.js */
    padding: 0;
    margin: 0;
    line-height: 1;
    margin-left: -10px;
}

/* Contact link in header (left side, under logo/Home) */
.header-contact-link {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%) translateY(-40px);
    opacity: 0;
    transition: all 0.3s ease 1s;
    pointer-events: auto;
    text-align: left;
    visibility: hidden;
    z-index: 1000;
}

/* Show Contact link when hovering over logo or Home menu item */
body:has(.logo:hover) .header-contact-link,
body:has(.menu-item[href="#home"]:hover) .header-contact-link {
    transform: translateY(-50%) translateY(-5px);
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

/* Keep visible when hovering Contact itself */
.header-contact-link:hover {
    transform: translateY(-50%) translateY(-5px) !important;
    opacity: 1 !important;
    visibility: visible !important;
    transition-delay: 0s !important;
}

/* Animate underline when Contact link appears */
body:has(.logo:hover) .header-contact-link::before,
body:has(.menu-item[href="#home"]:hover) .header-contact-link::before,
.header-contact-link:hover::before {
    transform: scale3d(1, 1, 1);
    transition: transform 0.3s ease 0.2s;
}

/* =============== Content Section =============== */
.content-section {
    position: fixed;
    top: 64px; /* CONTENT SECTION (Start: 64px) */
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0 40px 20px 40px; /* Unified padding: top, right, bottom, left */
    overflow-y: auto;
    box-sizing: border-box;
}

.page-content {
    /* width removed - let it naturally fill parent's padded area */
    max-width: none;
    margin: 0;
}

/* =============== Button Styles =============== */
/* ========================================
   LEGACY BUTTON STYLES - REMOVED
   All button styles now in components/buttons.css
======================================== */

/* Legacy .primary-button and .secondary-button removed - use .btn .btn-primary and .btn .btn-secondary instead */

.btn-small {
    padding: 4px 12px !important;
    font-size: 13px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* =============== Form Elements =============== */
/* .form-input, .form-input:focus, .form-group - MOVED TO components/forms.css */

/* =============== Notifications =============== */
.notification {
    position: fixed;
    top: 41px;
    right: 75px;
    background: var(--theme-btn-primary-bg);
    color: var(--theme-text-on-primary);
    padding: 1px 3px;
    border-radius: 4px;
    z-index: 1001;
    animation: fadeIn 0.3s ease-in;
    transition: top 0.3s ease;
}

.notification.success {
    background: var(--theme-btn-success-bg);
}

.notification.error {
    background: var(--theme-btn-danger-bg);
}

.notification.warning {
    background: var(--theme-btn-warning-bg);
    color: var(--theme-text-primary);
}

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

/* =============== Responsive Design =============== */
@media (max-width: 900px) {
    .menu-items {
        display: none;
    }

    .menu-center {
        display: none;
    }

    .hamburger {
        display: flex;
    }

    .mobile-menu.show {
        display: flex;
    }

    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
}

/* =============== Landscape Mobile Menu Optimization =============== */
/* Optimize mobile menu for landscape orientation (short viewport height) */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    .mobile-menu {
        max-height: calc(100vh - 40px); /* Even more important in landscape */
    }

    .mobile-menu-item {
        padding: 6px 20px; /* Reduce vertical padding to fit more items */
    }
}

/* Very short landscape screens */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 400px) {
    .mobile-menu-item {
        padding: 4px 20px; /* Further reduce padding for very short screens */
        font-size: 14px; /* Slightly smaller font */
    }
}
