/*
Theme Name: JPB Child Theme
Description: Custom child theme for Japan Parts Bros based on Twenty Twenty-Five
Template: twentytwentyfive
Version: 1.0.0
*/

/* Import parent theme styles */
@import url("../twentytwentyfive/style.css");

/* Custom JPB Header Styles - Exact Druco design */
.jpb-custom-header {
    background-color: #ffffff;
    border-bottom: 1px solid #e5e5e5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    overflow: visible !important; /* CRITICAL: Allow dropdowns to expand outside */
}

.jpb-header-container {
    max-width: 1345px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
    padding-top: 3px;
    overflow: visible !important; /* CRITICAL: Allow dropdowns to expand outside */
}

/* Logo Section */
.jpb-logo {
    display: flex;
    align-items: center;
    height: 50px;
    margin-right: 30px;
}

.jpb-logo img {
    height: 45px;
    width: auto;
}

/* Unified Search/Categories Container */
.jpb-search-container {
    flex: 1;
    max-width: 600px;
    position: relative;
    overflow: visible !important; /* CRITICAL: Allow dropdowns to expand outside */
}

.jpb-search-form {
    display: flex !important;
    border: none !important; /* Completely borderless */
    border-radius: 25px !important;
    overflow: visible !important; /* CRITICAL: Allow dropdowns to expand outside */
    background: #f8f8f8 !important; /* Light gray background like reference */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important; /* Subtle shadow */
}

/* Override any WordPress default search form styles */
.jpb-search-container form,
.jpb-search-container .jpb-search-form,
form.jpb-search-form {
    border-radius: 25px !important;
    border: none !important; /* Remove all borders */
    background: #f8f8f8 !important; /* Gray background */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

/* Categories Dropdown - Left side of unified bar */
.jpb-categories {
    position: relative;
}

.jpb-categories::after {
    content: '';
    position: absolute;
    right: -1px;
    top: 8px; /* Space from top */
    bottom: 8px; /* Space from bottom */
    width: 2px;
    background-color: #e0e0e0;
}

.jpb-categories-btn {
    background-color: transparent !important;
    color: #333 !important;
    border: none !important;
    padding: 12px 20px !important;
    cursor: pointer !important;
    font-weight: 500 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    transition: background-color 0.3s ease !important;
    white-space: nowrap !important;
    border-radius: 0 !important; /* Remove border radius for seamless look */
}

.jpb-categories-btn:hover {
    background-color: #f9f9f9;
}

/* Categories Dropdown - NUCLEAR OPTION */
.jpb-categories-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: white !important;
    border: 1px solid #ddd !important;
    border-radius: 0 0 8px 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    z-index: 999999 !important;
    max-height: 300px !important;
    overflow-y: auto !important;
    visibility: hidden !important;
    opacity: 0 !important;
    transform: translateY(-10px) !important;
    transition: all 0.3s ease !important;
    pointer-events: none !important;
    display: block !important; /* Always block, control with visibility */
}

.jpb-categories-dropdown.show {
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

.jpb-categories-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.jpb-categories-list li {
    border-bottom: 1px solid #f0f0f0;
}

.jpb-categories-list li:last-child {
    border-bottom: none;
}

.jpb-categories-list a {
    display: block;
    padding: 10px 16px; /* Reduced padding like profile dropdown */
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s ease;
    font-size: 14px; /* Same size as profile dropdown */
}

.jpb-categories-list a:hover {
    background-color: #f0b849;
    color: black;
}


/* Search Input - Center of unified bar */
.jpb-search-input {
    flex: 1 !important;
    border: none !important;
    padding: 12px 20px !important;
    font-size: 14px !important;
    outline: none !important;
    background: transparent !important;
    border-radius: 0 !important; /* Ensure no conflicting border radius */
}

/* Override any WordPress input styling within our search form */
.jpb-search-form input[type="search"],
.jpb-search-form input.jpb-search-input {
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

.jpb-search-input::placeholder {
    color: #999;
}

/* Search Button - Perfectly round like reference */
.jpb-search-btn {
    background-color: #f0b849 !important;
    border: none !important;
    width: 40px !important; /* Make it square first */
    height: 40px !important; /* Same height as width for perfect circle */
    margin: 2.5px !important; /* Center it within the 45px container */
    color: black !important;
    cursor: pointer !important;
    transition: background-color 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important; /* Perfect circle like reference */
    padding: 0 !important;
}

.jpb-search-btn svg {
    stroke: black !important; /* Make search icon black */
    fill: none !important;
}

.jpb-search-btn:hover {
    background-color: #e6a637;
    transform: scale(1.05); /* Slight hover effect */
}

/* Right Side Icons - Sleek Design */
.jpb-header-actions {
    display: flex;
    align-items: center;
    gap: 25px;
    margin-left: 30px;
    height: 40px; /* Fixed height for consistent alignment */
    overflow: visible !important; /* CRITICAL: Allow dropdowns to expand outside */
}

.jpb-action-item {
    position: relative;
    cursor: pointer;
    color: #666;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    flex-shrink: 0;
}

/* Special case for profile item alignment */
.jpb-action-item.jpb-profile {
    height: 0; /* As discovered by user - this fixes desktop alignment */
}

.jpb-action-item:hover {
    color: #f0b849;
    transform: translateY(-1px);
}

.jpb-action-item svg {
    padding-top: 9px;
    width: 22px;
    height: 22px;
    stroke-width: 1.5;
}

.jpb-action-item a {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
}

/* Badges for Cart and Favorites */
.jpb-cart-badge, .jpb-favorites-badge {
    position: absolute;
    top: -0px;
    right: -7px;
    background-color: #f0b849;
    color: black !important; /* Changed to black for better readability */
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Profile Avatar */
.jpb-profile-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto;
}

/* Profile Initials Circle */
.jpb-profile-initials {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #f0b849;
    color: black !important; /* Changed to black for better readability */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    margin: 0 auto;
}

.jpb-profile-initials:hover {
    background-color: #e6a637;
    transform: scale(1.05);
}

/* Profile Dropdown Menu */
.jpb-profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    z-index: 9999999 !important; /* MAXIMUM z-index to appear above search */
    min-width: 160px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.jpb-profile-dropdown.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.jpb-profile-menu {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.jpb-profile-menu li {
    border-bottom: 1px solid #f0f0f0;
}

.jpb-profile-menu li:last-child {
    border-bottom: none;
}

.jpb-profile-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: black !important; /* Changed to black for better readability */
    text-decoration: none;
    transition: background-color 0.2s ease;
    font-size: 14px;
}

.jpb-profile-menu a:hover {
    background-color: #f0b849;
    color: white;
}

.jpb-profile-menu svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Login Dropdown */
.jpb-login-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 15px;
    min-width: 220px;
    z-index: 9999999 !important;
    margin-top: 8px;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transform: translateY(-5px);
    transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.4s ease;
}

.jpb-login-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.jpb-login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jpb-login-form h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 14px;
    font-weight: 600;
}

.jpb-real-input {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #f9f9f9;
    color: #333;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s ease;
    outline: none;
}

.jpb-real-input:hover {
    border-color: #ccc;
    background: white;
}

.jpb-real-input:focus {
    border-color: #f0b849;
    background: white;
    box-shadow: 0 0 0 2px rgba(240, 184, 73, 0.2);
}

/* WordPress generated login form styling */
.jpb-wp-login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jpb-wp-login-form p {
    margin: 0;
}

.jpb-wp-login-form input[type="text"],
.jpb-wp-login-form input[type="password"] {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #f9f9f9;
    color: #333;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s ease;
    outline: none;
}

.jpb-wp-login-form input[type="text"]:focus,
.jpb-wp-login-form input[type="password"]:focus {
    border-color: #f0b849;
    background: white;
    box-shadow: 0 0 0 2px rgba(240, 184, 73, 0.2);
}

.jpb-wp-login-form input[type="submit"] {
    background-color: #f0b849;
    color: black !important;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    width: auto;
    margin-right: 8px;
}

.jpb-wp-login-form input[type="submit"]:hover {
    background-color: #e6a637;
}

.jpb-login-buttons {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.jpb-login-btn,
.jpb-signup-btn {
    flex: 1;
    display: block;
    text-align: center;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.jpb-login-btn {
    background-color: #f0b849;
    color: black !important;
    border: none;
    text-decoration: none;
}

.jpb-login-btn:hover {
    background-color: #e6a637;
    color: black !important;
    text-decoration: none;
}

.jpb-signup-btn {
    background-color: #f5f5f5;
    color: #666 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

.jpb-signup-btn:hover {
    background-color: #eeeeee;
    color: #666 !important;
}





/* Responsive Design */
@media (max-width: 768px) {
    .jpb-header-container {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px; /* Increased padding to match page width */
        position: relative;
        height: auto;
        overflow: visible !important; /* CRITICAL: Allow dropdowns to expand outside */
    }
    
    /* Top row: Logo (left) and Actions (right) - Same row alignment */
    .jpb-logo {
        order: 1;
        align-self: flex-start;
        margin: 0;
        position: absolute;
        left: 20px; /* Match container padding */
        top: 5px; /* Small top margin for breathing room */
        display: flex;
        align-items: center;
    }
    
    .jpb-logo img {
        height: 30px; /* Slightly smaller for better fit */
        width: auto;
    }
    
    .jpb-header-actions {
        order: 1;
        position: absolute;
        top: 5px; /* Match logo top position */
        right: 20px; /* Match container padding */
        align-items: center;
        gap: 15px;
        display: flex;
        overflow: visible !important; /* CRITICAL: Allow dropdowns to expand outside */
    }
    
    /* Bottom row: Search bar (full width) */
    .jpb-search-container {
        width: 100%; /* Full width within container */
        margin-top: 40px; /* Increased spacing between rows for better separation */
        margin-left: 0;
        margin-right: 0;
    }
    
    .jpb-search-form {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
        height: 45px !important;
        border-radius: 25px !important; /* Ensure mobile keeps curved borders */
        overflow: visible; /* Prevent overflow on mobile */
        border: none !important; /* Completely borderless on mobile */
        background: #f8f8f8 !important; /* Light gray background like reference */
    }
    
    /* Categories button - left side */
    .jpb-categories {
        flex-shrink: 0;
        width: auto;
        min-width: 80px; /* More flexible width */
        max-width: 100px; /* Allow some growth but prevent overflow */
        /* Remove duplicate border - using only ::after pseudo-element */
    }
    
    .jpb-categories-btn {
        padding: 10px 4px; /* Minimal padding to maximize space */
        font-size: 10px; /* Even smaller font for better fit */
        height: 100%;
        border-radius: 0 !important; /* Remove border radius for seamless look */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.1; /* Very tight line height */
        width: 100%; /* Use full available width */
        justify-content: center; /* Center the text */
    }
    
    /* Search input - center, flexible */
    .jpb-search-input {
        flex: 1;
        height: 100%;
        padding: 10px 8px; /* Minimal padding for more space */
        font-size: 13px; /* Slightly smaller font */
        border: none !important;
        background: transparent !important;
        outline: none !important;
        min-width: 0; /* Allow shrinking */
    }
    
    /* Search button - perfectly round like reference */
    .jpb-search-btn {
        flex-shrink: 0;
        width: 40px !important; /* Perfect circle size */
        height: 40px !important; /* Perfect circle size */
        margin: 2.5px !important; /* Center it in the container */
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important; /* Perfect circle like reference */
        background-color: #f0b849 !important;
        border: none !important;
        min-width: 40px !important;
    }
    
    .jpb-search-btn svg {
        width: 18px;
        height: 18px;
        stroke: black !important; /* Make search icon black on mobile */
        fill: none !important;
    }
    
    /* Adjust action icons for mobile */
    .jpb-action-item {
        width: 32px !important;
        height: 32px !important;
    }
    
    /* Reset profile height on mobile */
    .jpb-action-item.jpb-profile {
        height: auto !important; /* Reset the desktop height: 0 fix */
        top: 0;
    }
    
    .jpb-action-item svg {
        width: 18px;
        height: 18px;
    }
    
    .jpb-profile-avatar,
    .jpb-profile-initials {
        width: 28px !important;
        height: 28px !important;
    }
    
    .jpb-profile-initials {
        font-size: 11px !important;
    }
    
    /* Adjust badges for mobile */
    .jpb-cart-badge,
    .jpb-favorites-badge {
        top: 0; /* Align with icon instead of floating above */
        right: -5px;
        width: 18px;
        height: 18px;
        font-size: 10px;
        color: black !important; /* Ensure black text on mobile */
    }
    
    /* Mobile dropdown positioning */
    .jpb-profile-dropdown {
        right: -10px;
        min-width: 140px;
        z-index: 9999999 !important; /* MAXIMUM z-index to appear above search bar */
    }
    
    .jpb-login-dropdown {
        right: -10px;
        min-width: 220px;
        z-index: 9999999 !important; /* MAXIMUM z-index to appear above search bar */
    }
    
    .jpb-categories-dropdown {
        left: -10px;
        right: auto;
        min-width: 200px;
    }
}

/* Override default theme header */
.wp-block-group.alignfull:has(.jpb-custom-header) {
    margin: 0 !important;
}

/* Hide any default WordPress search forms that might interfere */
.wp-block-search:not(.jpb-search-form),
.search-form:not(.jpb-search-form),
.searchform:not(.jpb-search-form),
form[role="search"]:not(.jpb-search-form) {
    display: none !important;
}

/* Ensure only our custom search form is visible in header area */
.jpb-custom-header form:not(.jpb-search-form) {
    display: none !important;
}

/* Hide the default WordPress navigation menu below our custom header */
.wp-block-navigation,
.wp-block-group:has(.wp-block-navigation),
header .wp-block-navigation,
.wp-site-header .wp-block-navigation {
    display: none !important;
}

/* Hide page titles and content on front page - only show navbar */
.home .entry-title,
.home .page-title,
.home h1.wp-block-heading,
.home .wp-block-post-title,
.home .entry-content,
.home .wp-block-post-content,
.home .wp-block-query,
.home .wp-block-post-template {
    display: none !important;
}

/* Secondary Menu Styles */
.jpb-secondary-menu {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e5e5e5;
    position: sticky;
    top: 70px; /* Position below the main header */
    z-index: 999;
}

.jpb-secondary-menu-container {
    max-width: 1345px; /* Match the header container width */
    margin: 0 auto;
    padding: 0 20px;
}

.jpb-secondary-menu-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 40px;
    align-items: center;
    height: 50px;
}

.jpb-secondary-menu-list li {
    margin: 0;
}

.jpb-secondary-menu-list a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 15px 0;
    transition: color 0.2s ease;
    display: block;
}

.jpb-secondary-menu-list a:hover {
    color: #f0b849;
}

.jpb-secondary-menu-list a.current {
    color: #f0b849;
    border-bottom: 2px solid #f0b849;
}

/* Mobile responsive for secondary menu */
@media (max-width: 768px) {
    .jpb-secondary-menu {
        top: auto; /* Don't stick on mobile */
    }
    
    .jpb-secondary-menu-container {
        padding: 0 15px;
    }
    
    .jpb-secondary-menu-list {
        gap: 20px;
        height: 45px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .jpb-secondary-menu-list a {
        font-size: 12px;
        white-space: nowrap;
    }
}
