/**
 * Header Styles
 * 
 * @package Forgeee
 * @since 1.0.0
 */

/* ========================================
   Base Header Styles
   ======================================== */
.site-header {
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 999;
    transition: all 0.3s ease;
}

/* ========================================
   Header Overlay Mode
   ======================================== */
.has-header-overlay .site-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background-color: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.has-header-overlay .site-header .site-title a,
.has-header-overlay .site-header .main-navigation a,
.has-header-overlay .site-header .menu-toggle {
    color: #fff;
}

.has-header-overlay .site-header .site-title a:hover,
.has-header-overlay .site-header .main-navigation a:hover {
    color: rgba(255, 255, 255, 0.8);
}

/* スクロール時の背景付与 */
.has-header-overlay .site-header.scrolled {
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.has-header-overlay .site-header.scrolled .site-title a,
.has-header-overlay .site-header.scrolled .main-navigation a,
.has-header-overlay .site-header.scrolled .menu-toggle {
    color: var(--fg-primary-color, #333);
}

.has-header-overlay .site-header.scrolled .site-title a:hover,
.has-header-overlay .site-header.scrolled .main-navigation a:hover {
    color: var(--fg-secondary-color, #0073aa);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    min-height: 70px;
}

/* Header Width Variations */
.header-width-full .container {
    max-width: 100%;
    padding: 0 30px;
}

.header-width-contained .container {
    max-width: var(--fg-container-width, 1200px);
}

/* ========================================
   Site Branding
   ======================================== */
.site-branding {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.site-logo-link {
    display: inline-block;
    line-height: 1;
}

/* Logo Styles */
.site-logo img,
.custom-logo {
    width: auto;
    height: auto;
    max-width: 100%;
    display: block;
}

/* Forgeeeパーツ内のサイトロゴ */
.wp-block-group .wp-block-site-logo img,
.wp-block-group .forgeee-site-logo img {
    width: auto;
    height: auto;
    max-width: 100%;
}

.site-logo {
    max-height: 50px;
    width: auto;
    display: block;
}

.site-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.site-title a {
    color: var(--fg-primary-color, #333);
    text-decoration: none;
    transition: color 0.3s ease;
}

.site-title a:hover {
    color: var(--fg-secondary-color, #0073aa);
}

.site-description {
    margin: 5px 0 0;
    font-size: 14px;
    color: #666;
}

/* ========================================
   Main Navigation
   ======================================== */
.main-navigation {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
}

.main-navigation li {
    position: relative;
    margin: 0;
}

.main-navigation a {
    display: block;
    padding: 10px 20px;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

.main-navigation a:hover,
.main-navigation .current-menu-item > a,
.main-navigation .current-menu-ancestor > a {
    color: var(--fg-primary-color, #0073aa);
}

/* Navigation hover effect */
.main-navigation > ul > li > a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: var(--fg-primary-color, #0073aa);
    transform: translateX(-50%);
    transition: width 0.3s ease;
}

.main-navigation > ul > li > a:hover::after,
.main-navigation > ul > .current-menu-item > a::after {
    width: calc(100% - 40px);
}

/* ========================================
   Dropdown Menu
   ======================================== */
.main-navigation .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background-color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 999;
}

.main-navigation li:hover > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.main-navigation .sub-menu li {
    margin: 0;
}

.main-navigation .sub-menu a {
    padding: 12px 20px;
    font-size: 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.main-navigation .sub-menu a:hover {
    background-color: rgba(0, 115, 170, 0.05);
    padding-left: 25px;
}

.main-navigation .sub-menu li:last-child a {
    border-bottom: none;
}

/* Dropdown indicator */
.main-navigation .menu-item-has-children > a::before {
    content: '\25BC';
    font-size: 10px;
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s ease;
}

.main-navigation .menu-item-has-children:hover > a::before {
    transform: translateY(-50%) rotate(180deg);
}

/* ========================================
   Mobile Menu Toggle
   ======================================== */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    align-items: center;
    gap: 8px;
}

.menu-toggle-inner {
    display: flex;
    flex-direction: column;
    width: 24px;
    height: 18px;
    position: relative;
}

.menu-toggle-inner span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: #333;
    transition: all 0.3s ease;
    position: absolute;
    left: 0;
}

.menu-toggle-inner span:nth-child(1) {
    top: 0;
}

.menu-toggle-inner span:nth-child(2) {
    top: 50%;
    transform: translateY(-50%);
}

.menu-toggle-inner span:nth-child(3) {
    bottom: 0;
}

/* Active state */
.menu-toggle.active .menu-toggle-inner span:nth-child(1) {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}

.menu-toggle.active .menu-toggle-inner span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .menu-toggle-inner span:nth-child(3) {
    bottom: 50%;
    transform: translateY(50%) rotate(-45deg);
}

.menu-toggle-text {
    font-size: 14px;
    font-weight: 500;
}

/* ========================================
   Header Search
   ======================================== */
.header-search {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-search-form {
    position: relative;
    display: none;
}

.header-search-form.active {
    display: block;
}

.header-search-form input[type="search"] {
    width: 200px;
    padding: 8px 35px 8px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.header-search-form input[type="search"]:focus {
    width: 250px;
    outline: none;
    border-color: var(--fg-primary-color, #0073aa);
}

.header-search-form button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #666;
}

.header-search-toggle {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #333;
    font-size: 20px;
    transition: color 0.3s ease;
}

.header-search-toggle:hover {
    color: var(--fg-primary-color, #0073aa);
}

/* ========================================
   Header CTA Button
   ======================================== */
.header-cta {
    margin-left: 20px;
}

.header-cta-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: var(--fg-primary-color, #0073aa);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.header-cta-button:hover {
    background-color: var(--fg-secondary-color, #005a87);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* ========================================
   Sticky Header
   ======================================== */
.site-header.sticky-scroll {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    animation: slideDown 0.3s ease;
}

.site-header.sticky-always {
    position: sticky;
    top: 0;
}

.site-header.sticky-scroll.scrolled,
.site-header.sticky-always.scrolled {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    background-color: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
}

.site-header.sticky-scroll.scrolled .header-inner,
.site-header.sticky-always.scrolled .header-inner {
    padding: 10px 0;
    min-height: 60px;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ========================================
   Responsive Design
   ======================================== */
@media screen and (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
        padding: 10px 0;
    }
    
    .site-branding {
        flex: 1;
    }
    
    .site-logo {
        max-height: 40px;
    }
    
    .menu-toggle {
        display: flex;
        order: 3;
    }
    
    .main-navigation {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background-color: #fff;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        overflow-y: auto;
        transition: left 0.3s ease;
        z-index: 9999;
    }
    
    .main-navigation.active {
        left: 0;
    }
    
    .main-navigation ul {
        flex-direction: column;
        align-items: stretch;
        padding: 20px 0;
    }
    
    .main-navigation li {
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }
    
    .main-navigation a {
        padding: 15px 20px;
    }
    
    .main-navigation > ul > li > a::after {
        display: none;
    }
    
    /* Mobile submenu */
    .main-navigation .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background-color: rgba(0, 0, 0, 0.02);
        display: none;
    }
    
    .main-navigation .sub-menu.active {
        display: block;
    }
    
    .main-navigation .sub-menu a {
        padding-left: 40px;
        font-size: 13px;
    }
    
    .main-navigation .menu-item-has-children > a::before {
        content: '\25BC';
        right: 20px;
    }
    
    .main-navigation .menu-item-has-children.active > a::before {
        transform: translateY(-50%) rotate(180deg);
    }
    
    /* Mobile overlay */
    .mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 9998;
    }
    
    .mobile-menu-overlay.active {
        display: block;
    }
    
    /* Header search on mobile */
    .header-search {
        width: 100%;
        order: 4;
        margin-top: 10px;
        justify-content: flex-end;
    }
    
    .header-search-form {
        width: 100%;
    }
    
    .header-search-form input[type="search"] {
        width: 100%;
    }
    
    .header-search-form input[type="search"]:focus {
        width: 100%;
    }
    
    /* Header CTA on mobile */
    .header-cta {
        margin-left: 10px;
    }
    
    .header-cta-button {
        padding: 8px 15px;
        font-size: 13px;
    }
}

/* ========================================
   Kadence Header Specific Styles
   ======================================== */
.kadence-header {
    position: relative;
    z-index: 999;
}

/* Notice styles (only shown in admin) */
.fg-kadence-notice {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px;
    margin: 0;
}

.fg-kadence-notice p {
    margin: 0;
    color: #856404;
}

/* Kadence sticky header compatibility */
.kadence-header.sticky-normal,
.kadence-header.sticky-smart,
.kadence-header.sticky-always {
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

/* Admin bar adjustment for Kadence */
body.admin-bar .kadence-header.sticky-normal,
body.admin-bar .kadence-header.sticky-smart,
body.admin-bar .kadence-header.sticky-always {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .kadence-header.sticky-normal,
    body.admin-bar .kadence-header.sticky-smart,
    body.admin-bar .kadence-header.sticky-always {
        top: 46px;
    }
}

/* Kadence width settings compatibility */
.kadence-header.header-width-full {
    width: 100%;
}

.kadence-header.header-width-boxed {
    max-width: 1200px;
    margin: 0 auto;
}

.kadence-header.header-width-contained .kb-header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Ensure Kadence blocks display properly */
.kadence-header .wp-block-kadence-header {
    width: 100%;
}

/* Fix for potential Kadence layout issues */
.kadence-header .kb-header-row {
    display: flex;
    align-items: center;
    width: 100%;
}

.kadence-header .kb-header-section {
    flex: 1;
}

/* Back to top button */
.fg-back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--fg-primary-color);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fg-back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.fg-back-to-top:hover {
    background: var(--fg-primary-hover-color);
    transform: translateY(-3px);
}

.fg-back-to-top svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}