/**
 * @fileoverview Layout Styles for Chahua Web Store Header and Footer
 * @description Global layout components including navigation, header, footer, and responsive design
 * @dependencies 
 *   - global.css (CSS variables and base styles)
 * @features
 *   - Responsive header with sticky navigation
 *   - Mobile hamburger menu system
 *   - Footer with company information
 *   - Dropdown navigation menus
 *   - User authentication state display
 * @responsive
 *   - Mobile-first design approach
 *   - Hamburger menu for mobile devices
 *   - Responsive navigation breakpoints
 *   - Touch-friendly mobile interactions
 * @performance 
 *   - Optimized for sticky header performance
 *   - Efficient mobile menu transitions
 *   - Hardware-accelerated animations
 * @calledBy All HTML pages (global layout)
 * @example
 * // Header structure:
 * <header class="header">
 *   <div class="container">
 *     <div class="nav-brand">
 *       <a class="logo" href="/">Chahua</a>
 *     </div>
 *   </div>
 * </header>
 */

/* layout.css - Header และ Footer */

/* Header Variables */
:root {
    --header-bg: #1a1a1a;
    --header-border: #00aaff;
    --header-text: #ffffff;
    --header-text-secondary: #b3b3b3;
    --header-hover: rgba(0, 170, 255, 0.1);
    --header-dropdown-bg: #2a2a2a;
    --header-border-color: #333333;
    --header-shadow: rgba(0, 0, 0, 0.2);
}

/* Header Main Structure */
.header {
    background: var(--header-bg);
    border-bottom: 2px solid var(--header-border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
}

body.mobile-menu-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    position: relative;
}

/* Logo/Brand */
.nav-brand .logo {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--header-text);
    text-decoration: none;
    transition: color 0.3s ease;
}

.nav-brand .logo:hover {
    color: var(--header-border);
}

.brand-accent {
    color: var(--header-border);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 12px;
    z-index: 1001;
    min-width: 48px;
    min-height: 48px;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0,170,255,0.3);
    position: relative;
}

.hamburger-line {
    width: 100%;
    height: 3px;
    background: var(--header-border);
    border-radius: 2px;
    transition: all 0.3s ease;
    margin: 2px 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Navigation Menu */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
}

@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
    }
}

.nav-content {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-overlay {
    display: none;
}

.nav-link {
    color: var(--header-text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    color: var(--header-border);
    background: var(--header-hover);
}

/* Auth Buttons */
.auth-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-auth {
    padding: 0.5rem 1rem;
    border: 2px solid var(--header-border);
    background: transparent;
    color: var(--header-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    font-weight: 500;
}

.btn-auth:hover {
    background: var(--header-border);
    color: var(--header-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--header-shadow);
}

.btn-auth.register {
    background: var(--header-border);
    color: var(--header-bg);
}

.btn-auth.register:hover {
    background: #0088cc;
}

/* User Dropdown */
.user-dropdown {
    position: relative;
    display: inline-block;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 2px solid var(--header-border);
    border-radius: 8px;
    color: var(--header-border);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.user-menu-btn:hover {
    background: var(--header-hover);
}

.user-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    transition: transform 0.3s ease;
}

.user-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 200px;
    background: var(--header-dropdown-bg);
    border: 2px solid var(--header-border-color);
    border-radius: 12px;
    box-shadow: 0 8px 25px var(--header-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 10002;
}

.user-dropdown.open .user-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--header-text-secondary);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    border-radius: 8px;
    margin: 0.25rem 0;
}

.user-menu-item:hover {
    background: var(--header-hover);
    color: var(--header-border);
}

.user-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.user-menu-divider {
    height: 1px;
    background: var(--header-border-color);
    margin: 0.5rem 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        background: rgba(0, 170, 255, 0.1);
        border: 2px solid var(--header-border);
        border-radius: 8px;
        position: relative;
        z-index: 1001;
    }
    
    .mobile-menu-toggle:hover,
    .mobile-menu-toggle:active {
        background: rgba(0, 170, 255, 0.2);
        transform: scale(1.05);
    }

    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 320px;
        max-width: 85vw;
        height: 100vh;
        background: var(--header-bg);
        border-left: 2px solid var(--header-border);
        transition: right 0.3s ease;
        z-index: 1002;
        box-shadow: -5px 0 15px var(--header-shadow);
        display: flex;
        flex-direction: column;
    }

    .nav-menu.active {
        right: 0;
    }

    .nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: transparent;
        z-index: 1001;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .nav-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .nav-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding: 1rem 1.5rem 2rem;
        height: 100%;
        overflow-y: auto;
        position: relative;
    }
    
    .nav-content::before {
        content: "✕";
        position: absolute;
        top: 1rem;
        right: 1.5rem;
        font-size: 1.5rem;
        color: var(--header-border);
        cursor: pointer;
        z-index: 10002;
        padding: 8px 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 2px solid var(--header-border);
        border-radius: 20px;
        background: var(--header-bg);
        font-weight: bold;
        transition: all 0.3s ease;
    }
    
    .nav-content::before:hover {
        background: var(--header-border);
        color: var(--header-bg);
    }
    
    .nav-content::after {
        content: "เมนู";
        display: block;
        font-size: 1.2rem;
        font-weight: bold;
        color: var(--header-border);
        margin-bottom: 2rem;
        padding-bottom: 1rem;
        border-bottom: 2px solid var(--header-border-color);
        width: 100%;
        margin-top: 3rem;
    }

    .nav-link {
        width: 100%;
        padding: 1rem;
        margin-bottom: 0.5rem;
        border-bottom: 1px solid var(--header-border-color);
        font-size: 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
        pointer-events: auto;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0,170,255,0.3);
    }

    .auth-buttons {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        margin-top: 2rem;
        padding-top: 2rem;
        border-top: 2px solid var(--header-border-color);
    }

    .btn-auth {
        width: 100%;
        text-align: center;
        padding: 1rem;
        font-size: 1rem;
        min-height: 48px;
        pointer-events: auto;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0,170,255,0.3);
    }

    .user-dropdown {
        width: 100%;
    }

    .user-menu-btn {
        width: 100%;
        justify-content: space-between;
        padding: 1rem;
        font-size: 1rem;
        min-height: 48px;
        pointer-events: auto;
    }

    .user-menu-dropdown {
        position: static;
        box-shadow: none;
        border: 1px solid var(--header-border-color);
        margin-top: 1rem;
        width: 100%;
        z-index: 1002;
    }
}

@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: rgba(0,170,255,0.3);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    a, button, input, select, textarea {
        -webkit-user-select: auto;
        user-select: auto;
    }
    
    .nav-link,
    .btn-auth,
    .user-menu-btn,
    .user-menu-item {
        pointer-events: auto !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0,170,255,0.3) !important;
    }
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 2px solid var(--accent-blue);
    color: var(--text-secondary);
}

.footer-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
}

.footer-brand {
    flex: 1;
}

.brand-link {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-blue);
    flex-shrink: 0;
}

.brand-svg {
    width: 20px;
    height: 20px;
    color: white;
}

.brand-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    flex: 2;
}

.footer-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.footer-links li a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.3s ease;
}

.footer-links li a:hover {
    color: var(--accent-blue);
}

.social-links {
    display: flex;
    justify-content: flex-start;
    gap: 0.75rem;
}

.social-link {
    display: flex;
    align-items: center;
    padding: 0.25rem;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.social-link:hover {
    color: var(--accent-blue);
}

.social-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.footer-bottom {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
}

.footer-bottom p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

@media (min-width: 1024px) {
    .footer-main {
        flex-direction: row;
        gap: 4rem;
    }
    
    .brand-link {
        justify-content: flex-start;
    }
    
    .footer-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 3rem;
    }
}

@media (min-width: 640px) and (max-width: 1023px) {
    .footer-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }
}
