/* ============================================
   TB-INSPIRED HEADER 
   Three-layer: Top Bar + Main Header + Navigation
   ============================================ */

/* Top Utility Bar */
.tb-top-bar {
    background: #fafafa;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.75rem;
    padding: 0.5rem 0;
}

.tb-top-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tb-top-left,
.tb-top-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.tb-top-link {
    color: #4b5563;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
}

.tb-top-link:hover {
    color: #2563eb;
}

.tb-top-divider {
    width: 1px;
    height: 14px;
    background: #d1d5db;
}

.tb-top-lang,
.tb-top-currency {
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}

.tb-top-lang:hover,
.tb-top-currency:hover {
    color: #2563eb;
}

/* Main Header */
.tb-main-header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tb-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

/* Logo */
.tb-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.tb-logo:hover {
    opacity: 0.85;
}

.tb-logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

.tb-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.tb-logo-text strong {
    font-size: 1.375rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.15;
}

.tb-logo-text span {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 500;
}

/* Search Bar - Dominant Element */
.tb-search-wrapper {
    flex: 1;
    max-width: 720px;
    margin: 0 auto;
}

.tb-search-form {
    margin-bottom: 0.625rem;
}

.tb-search-box {
    display: flex;
    align-items: stretch;
    background: white;
    border: 2px solid #2563eb;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.12);
    transition: all 0.2s;
    height: 44px;
}

.tb-search-box:focus-within {
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.2);
    transform: translateY(-1px);
}

.tb-search-category {
    position: relative;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    min-width: 160px;
}

.tb-category-select {
    border: none;
    background: transparent;
    font-size: 0.875rem;
    color: #374151;
    font-weight: 500;
    padding-right: 1.5rem;
    cursor: pointer;
    appearance: none;
    width: 100%;
}

.tb-category-select:focus {
    outline: none;
}

.tb-search-category i {
    position: absolute;
    right: 0.75rem;
    pointer-events: none;
    color: #6b7280;
    font-size: 0.75rem;
}

.tb-search-divider {
    width: 1px;
    background: #e5e7eb;
}

.tb-search-input {
    flex: 1;
    border: none;
    padding: 0 1rem;
    font-size: 0.938rem;
    color: #111827;
    min-width: 200px;
    font-weight: 400;
}

.tb-search-input:focus {
    outline: none;
}

.tb-search-input::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

.tb-search-btn {
    border: none;
    background: #2563eb;
    color: white;
    padding: 0 2rem;
    font-size: 0.938rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tb-search-btn:hover {
    background: #1d4ed8;
}

.tb-search-suggestions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.tb-suggestion-label {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
}

.tb-suggestion-tag {
    font-size: 0.75rem;
    color: #4b5563;
    padding: 0.25rem 0.75rem;
    background: #f3f4f6;
    border-radius: 14px;
    transition: all 0.2s;
    font-weight: 500;
}

.tb-suggestion-tag:hover {
    background: #2563eb;
    color: white;
}

/* Header Actions */
.tb-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.tb-rfq-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: #fef3c7;
    color: #d97706;
    border: 1px solid #fde68a;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.938rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.tb-rfq-btn:hover {
    background: #fde68a;
    border-color: #fcd34d;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.15);
}

/* User Menu Dropdown */
.tb-user-menu {
    position: relative;
}

.tb-user-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.938rem;
    color: #374151;
    font-weight: 500;
    transition: all 0.2s;
}

.tb-user-trigger:hover {
    border-color: #2563eb;
    color: #2563eb;
}

.tb-user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 1000;
}

.tb-user-menu:hover .tb-user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tb-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.938rem;
    color: #374151;
    transition: all 0.2s;
    font-weight: 500;
}

.tb-dropdown-item:hover {
    background: #f9fafb;
    color: #2563eb;
}

.tb-dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0.5rem 0;
}

.tb-signin-btn {
    padding: 0.625rem 1.25rem;
    color: #374151;
    font-weight: 500;
    font-size: 0.938rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.tb-signin-btn:hover {
    border-color: #2563eb;
    color: #2563eb;
}

.tb-register-btn {
    padding: 0.625rem 1.5rem;
    background: #2563eb;
    color: white;
    font-weight: 600;
    font-size: 0.938rem;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.tb-register-btn:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    transform: translateY(-1px);
}

/* Navigation Bar */
.tb-nav-bar {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 0;
    position: sticky;
    top: 84px;
    z-index: 999;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.tb-nav-content {
    display: flex;
    align-items: stretch;
    overflow: visible;
}

.tb-nav-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0 1rem;
    margin-left: auto;
    flex-shrink: 0;
    border-left: 1px solid #f3f4f6;
}

/* Categories Mega Menu */
.tb-nav-categories {
    position: relative;
    border-right: 1px solid #f0f0f0;
    overflow: visible;
}

.tb-categories-trigger {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.938rem;
    font-weight: 600;
    height: 100%;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.tb-categories-trigger:hover {
    opacity: 0.95;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.tb-mega-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 280px;
    max-height: none !important;
    overflow: visible !important;
    background: white;
    border: 1px solid #e5e7eb;
    border-top: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s;
    z-index: 1000;
}

.tb-mega-content {
    max-height: none !important;
    overflow: visible !important;
}

body:not(.tb-disable-categories-hover) .tb-nav-categories:hover .tb-mega-menu,
.tb-nav-categories.active .tb-mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Seller/Buyer/Admin panel pages must not let category nav overlay intercept panel clicks. */
body.tb-disable-categories-hover .tb-nav-bar {
    display: none !important;
}

body.tb-disable-categories-hover .tb-nav-categories,
body.tb-disable-categories-hover .tb-mega-menu,
body.tb-disable-categories-hover .tb-categories-trigger {
    pointer-events: none !important;
}

.tb-mega-category {
    position: relative;
    border-bottom: 1px solid #f3f4f6;
}

.tb-mega-category:last-child {
    border-bottom: none;
}

.tb-mega-category-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: #374151;
    font-weight: 500;
    transition: all 0.2s;
}

.tb-mega-category-title:hover {
    background: #f9fafb;
    color: #2563eb;
}

.tb-mega-subcategories {
    position: static;
    width: 100%;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0 0.75rem 0.75rem 2rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.25rem;
    opacity: 1;
    visibility: visible;
    transition: none;
}

.tb-mega-category:hover .tb-mega-subcategories {
    opacity: 1;
    visibility: visible;
}

.tb-mega-sub-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.813rem;
    color: #6b7280;
    border-radius: 4px;
    transition: all 0.2s;
    font-weight: 500;
    display: block;
}

.tb-mega-sub-item:hover {
    background: rgba(37, 99, 235, 0.08);
    color: #2563eb;
}

/* Navigation Links */
.tb-nav-links {
    display: flex;
    align-items: stretch;
    flex: 1;
    gap: 0;
}

.tb-nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    font-size: 0.938rem;
    color: #374151;
    font-weight: 600;
    transition: all 0.2s;
    border-left: 1px solid #f3f4f6;
    white-space: nowrap;
}

.tb-nav-link:hover {
    background: #f9fafb;
    color: #2563eb;
}

.tb-nav-highlight {
    color: #ef4444;
    font-weight: 600;
}

.tb-nav-highlight:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* Stats Info Bar */
.tb-stats-bar {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.625rem 0;
}

.tb-stats-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
}

.tb-stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.813rem;
    color: #64748b;
}

.tb-stat-item i {
    font-size: 1rem;
    color: #94a3b8;
}

.tb-stat-label {
    font-weight: 400;
}

.tb-stat-value {
    font-weight: 600;
    color: #0f172a;
}

/* Responsive Design */
@media (max-width: 1199px) {
    .tb-header-row {
        gap: 1rem;
    }
    
    .tb-search-wrapper {
        max-width: 500px;
    }
    
    .tb-search-category {
        min-width: 120px;
    }
    
    .tb-logo-text span {
        display: none;
    }
}

@media (max-width: 991px) {
    .tb-top-bar {
        display: none;
    }
    
    .tb-stats-bar {
        display: none;
    }

    .tb-nav-right {
        display: none;
    }
    
    .tb-main-header {
        top: 0;
    }
    
    .tb-nav-bar {
        top: 84px;
    }
    
    .tb-logo-text strong {
        font-size: 1.125rem;
    }
    
    .tb-search-wrapper {
        flex: 1;
        max-width: none;
    }
    
    .tb-search-category {
        display: none;
    }
    
    .tb-search-suggestions {
        display: none;
    }
    
    .tb-nav-links {
        overflow-x: auto;
    }
    
    .tb-rfq-btn span {
        display: none;
    }
}

@media (max-width: 768px) {
    .tb-main-header {
        padding: 0.75rem 0;
    }
    
    .tb-header-row {
        gap: 0.75rem;
    }
    
    .tb-logo-icon {
        width: 36px;
        height: 36px;
        font-size: 1.125rem;
    }
    
    .tb-logo-text {
        display: none;
    }
    
    .tb-search-divider {
        display: none;
    }
    
    .tb-search-btn {
        padding: 0 1.25rem;
    }
    
    .tb-search-btn span {
        display: none;
    }
    
    .tb-user-trigger span {
        display: none;
    }
    
    .tb-register-btn {
        padding: 0.625rem 1rem;
        font-size: 0.813rem;
    }
    
    .tb-nav-links .tb-nav-link {
        padding: 0.75rem 1rem;
    }
}

/* Panel pages: reduce excessive left-right header whitespace */
.panel-with-top-header .tb-main-header .container-xxl,
.panel-with-top-header .tb-nav-bar .container-xxl {
    max-width: none;
    width: 100%;
    padding-left: 16px;
    padding-right: 16px;
}

@media (min-width: 1400px) {
    .panel-with-top-header .tb-main-header .container-xxl,
    .panel-with-top-header .tb-nav-bar .container-xxl {
        padding-left: 24px;
        padding-right: 24px;
    }
}

/* Products page: force compact header spacing */
body.market-products-page {
    margin: 0 !important;
    padding: 0 !important;
}

body.market-products-page .tb-main-header {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
}

body.market-products-page .tb-header-row {
    min-height: 52px !important;
}

body.market-products-page .tb-nav-bar {
    top: 56px !important;
}

body.market-products-page .tb-categories-trigger,
body.market-products-page .tb-nav-link {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}
