/**
 * Wine Shop Module - 全局頭部樣式
 * 包含：消息欄、導航欄、搜索框和購物車樣式
 */
/* 重置邊距，確保沒有白框 */
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
}

/* 當彈出層激活時，禁用背景頁面滾動 */
body.popup-active {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.wine-shop-home {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    padding-bottom: 40px;
    background-color: var(--main-bgcolor);
}

/* 消息欄樣式 */
.message-bar {
    background-color: #173D58; /* 使用主色調 */
    height: 60px; /* 設定高度為60px */
    color: white;
    overflow: hidden;
    position: relative;
    z-index: 100; /* 確保消息欄在其他元素上方 */
    width: 100%;
    margin-top: 30px;
}

.message-wrapper {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
}

.message-slider {
    width: 100%;
    position: relative;
    height: 100%;
    overflow: hidden;
}

.message-item {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.message-item.active {
    opacity: 1;
    transform: translateY(0);
}

.message-content {
    text-align: center;
    width: 100%;
}

.message-content p {
    margin: 0;
    font-size: 18px;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

/* 滾動效果 - 當文字內容過長時應用 */
@keyframes scrollText {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

.message-content p.scrolling {
    animation: scrollText 15s linear infinite;
    padding-left: 100%;
    white-space: nowrap;
    display: inline-block;
}

/* 確保消息欄在小螢幕上也能正確顯示 */
@media (max-width: 768px) {
    .message-bar {
        height: auto;
        min-height: 60px;
        max-height: none;
        display: block !important; /* 強制顯示 */
        visibility: visible !important;
        z-index: 100;
    }
    
    .message-item {
        position: relative; /* 改為相對定位，避免絕對定位導致的問題 */
        opacity: 0;
        display: none;
    }
    
    .message-item.active {
        opacity: 1;
        display: flex;
    }
    
    .message-content p {
        font-size: 14px;
        padding: 10px 5px;
        white-space: normal; /* 允許文本換行 */
        overflow-wrap: break-word;
        line-height: 1.4;
        display: block;
        animation: none;
    }

    .message-content p.scrolling {
        animation: none;
        padding-left: 5px;
        white-space: normal;
        display: block;
    }
}

/* 導航欄樣式 */
.navigation-bar {
    background-color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border-bottom: 5px solid var(--menu-border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navigation-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px 20px;
}

/* 導航欄行樣式 */
.nav-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}

.top-row {
    border-bottom: 1px solid var(--top-border-color);
    padding-bottom: 10px;
    margin-bottom: 10px;
}

/* Logo樣式 */
.logo {
    font-family: "Cormorant", serif;
}

.logo a {
    text-decoration: none;
    color: var(--primary-color);
}

.logo-text {
    font-family: var(--heading-font);
    font-size: 56px;
    font-weight: 0;
    color: var(--primary-color);
    letter-spacing: 1px;
    text-transform: none;
}

.logo img {
    width: 250px; height: auto;
}

.nav-menu {
    display: flex;
    align-items: center;
    z-index: 1000;
}

.menu-items {
    display: flex;
    list-style-type: none;
    margin: 0;
    padding: 0;
}

.menu-item {
    margin: 0 15px;
    position: relative;
}

.menu-item a {
    color: #333;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.3s ease;
}

.menu-item a:hover, 
.menu-item.active a {
    color: var(--accent-color);
    text-decoration: none;
}

.menu-item {
    display: flex !important;
    position: relative !important;
    z-index: 5;
}

/* Winery菜单项特殊悬停效果 */
.menu-item a.menu-toggle[data-target="winery-popup"]:hover {
    color: var(--accent-color);
    text-shadow: 0 0 1px rgba(199, 173, 119, 0.3);
    transition: all 0.3s ease;
}

.sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    min-width: 180px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    padding: 10px 0;
    list-style: none;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.menu-item:hover .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.sub-menu li {
    padding: 0;
    margin: 0;
}

.sub-menu li a {
    display: block;
    padding: 8px 15px;
    font-size: 14px;
    color: #333;
}

.sub-menu li a:hover {
    background-color: #f5f5f5;
    color: var(--accent-color);
}

.nav-actions {
    display: flex;
    align-items: center;
}

/* 彈出層樣式 */
.menu-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    z-index: 99999;
    width: 600px; /* 從500px修改為600px */
    max-height: 60vh; /* 保留最大高度 */
    overflow-y: auto; /* 改為auto，當內容過長時顯示滾動條 */
    /* 使用可跨瀏覽器兼容的滾動條設置方式 */
    /* scrollbar-width: thin; 此屬性在某些瀏覽器中不被支持 */
}
.menu-popup .popup-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    /* 可選：加陰影或底線 */
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    padding: 0 20px; /* 左右內邊距 */
    min-height: 56px; /* 統一高度 */    
}
.menu-popup .popup-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 20px;
    padding:20px;
}

/* 自定義滾動條樣式 */
.menu-popup::-webkit-scrollbar {
    width: 6px;
}

.menu-popup::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.menu-popup::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

.menu-popup::-webkit-scrollbar-thumb:hover {
    background-color: #999;
}

/* 為firefox提供滾動條樣式 - 使用替代方案 */
@supports (scrollbar-color: auto) {
    .menu-popup {
        scrollbar-color: var(--border-color) #f1f1f1;
        scrollbar-width: thin;
    }
}

.close-popup {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s;
}

.close-popup:hover {
    color: var(--primary-color);
}

.popup-content {
    overflow-y: auto;
    flex: 1 1 auto;    
    padding: 5px 20px 0px 20px; /* 保持上部5px，左右20px，底部0px */
}

.popup-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.popup-links li {
    margin-bottom: 10px;
}

.popup-links li:last-child {
    margin-bottom: 0;
}

.popup-links a {
    display: block;
    padding: 10px;
    color: var(--text-dark);
    text-decoration: none;
    transition: all 0.3s;
    border-radius: 3px;
}

.popup-links a:hover {
    background-color: #f5f5f5;
    color: var(--accent-color);
}

.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* 當彈出層顯示時的樣式 */
.popup-active {
    overflow: hidden;
}

.popup-active .popup-overlay {
    display: block;
}

.menu-popup.active {
    display: block;
}

.hashtag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

/* 統一所有子菜單的hashtag按鈕樣式 */
.hashtag-button {
    position: relative;
    display: inline-block;
    padding: 6px 12px;
    background-color: var(--light-gray);
    color: var(--text-dark);
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-right: 6px;
    margin-bottom: 6px;
}

.hashtag-button:hover {
    color: var(--accent-color);
}

.hashtag-button.clicked::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 100%;
    transform: scale(1);
    opacity: 1;
    animation: clickWave 0.5s ease-out;
}

.hashtag-country {
    font-weight: 600; /* 加粗以更好區分國家 */
    background-color: var(--primary-color);
    color: white;
}

.hashtag-country:hover {
    color: var(--accent-color);
}

@keyframes clickWave {
    0% {
        transform: scale(0);
        opacity: 0.8;
    }
    100% {
        transform: scale(40);
        opacity: 0;
    }
}

/* 確保所有彈出菜單中的標籤容器顯示一致 */
.menu-popup .hashtag-container,
#popup-wines .hashtag-container {
    display: flex !important; /* 強制顯示 */
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

/* 桌面版葡萄酒菜單樣式 */
.desktop-wine-section {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.desktop-wine-section:last-child {
    border-bottom: none;
}

/* 桌面和移動版葡萄酒子菜單標題共用樣式 */
.desktop-wine-section h4,
.wine-section h4, .region-section h4 {
    margin: 0 0 10px 0;
    padding: 5px 0;
    color: var(--primary-color);
}

/* 桌面版特定樣式 */
.desktop-wine-section h4 {
    font-size: 18px;
}

/* 移動版特定樣式 */
.wine-section h4, .region-section h4 {
    position: relative;
    font-size: 16px;
}

/* 菜單切換按鈕樣式 */
.menu-toggle {
    display: inline-block;
    position: relative;
}

/* 購物車圖標樣式 */
.cart-icon {
    position: relative;
}

.cart-link {
    display: flex;
    align-items: center;
    color: #333;
    text-decoration: none;
    font-size: 26px; /* 從20px增加到26px */
}

.cart-count {
    position: absolute;
    top: -12px;
    right: -12px;
    background-color: var(--accent-color);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    font-size: 14px;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 24px;
}

.cart-count:not(.empty) {
    display: flex;
}

/* 搜索框樣式 */
.search-box {
    flex: 0 0 auto;
    margin-right: 20px;
}

.search-form {
    display: flex;
    align-items: center;
}

.search-form input[type="text"] {
    border: 1px solid var(--border-color);
    border-radius: 3px 0 0 3px;
    padding: 8px 10px;
    width: 200px;
    font-size: 14px;
}

.search-form button[type="submit"] {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 3px 3px 0;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.search-form button[type="submit"]:hover {
    background-color: rgba(23, 61, 88, 0.9);
}

.search-form button[type="submit"] i {
    font-size: 16px;
}

/* 移動版搜索圖標樣式（用於搜索按鈕） */
.search-form .mobile-search-icon-style {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 9px 14px;
    border-radius: 0 3px 3px 0;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-form .mobile-search-icon-style:hover {
    background-color: rgba(23, 61, 88, 0.9);
}

.search-btn {
    background-color: transparent;
    color: var(--primary-color);
    border: none;
    border-radius: 0 3px 3px 0;
    padding: 8px 12px;
    cursor: pointer;
}

.search-btn i {
    font-size: 16px;
}

/* 響應式樣式 */
@media (max-width: 992px) {
    .search-form input[type="text"] {
        width: 150px;
    }
}

@media (max-width: 768px) {
    .navigation-container {
        flex-wrap: wrap;
    }
    
    .logo {
        margin-bottom: 10px;
    }

    .logo img {
        width: 100px;
    }
    
    .nav-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .search-box {
        flex-grow: 1;
        margin-right: 15px;
    }
    
    .search-form input[type="text"] {
        width: 100%;
    }
    
    .logo-text {
        font-size: 36px;
    }
    
    .menu-popup {
        width: 90%;
    }

    .search-box {
        display: none;
    }
    
    .hashtag-container {
        gap: 5px;
    }
    
    .hashtag-button {
        font-size: 12px;
        padding: 3px 10px;
        margin-right: 4px;
        margin-bottom: 4px;
    }
}

/* 移動端水平滾動類別菜單和全屏彈出層 */
@media (max-width: 768px) {
    /* 隱藏桌面菜單 */
    .desktop-menu {
        display: none;
    }
    
    /* 水平滾動類別菜單 */
    .wine-categories-scroll {
        display: flex;
        overflow-x: scroll; /* 強制顯示滾動 */
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        padding: 10px 15px; /* 增加左右填充 */
        background-color: var(--primary-color);
        /* 隱藏滾動條但保留功能 */
        scrollbar-width: none;
        -ms-overflow-style: none;
        width: 100%;
        max-width: 100%;
        overflow-y: hidden;
        flex-wrap: nowrap;
        margin: 0;
        -webkit-tap-highlight-color: transparent;
        position: relative;
        touch-action: pan-x; /* 允許水平平移手勢 */
    }
    
    .wine-categories-scroll::-webkit-scrollbar {
        display: none;
    }
    
    .wine-category {
        flex: 0 0 auto;
        padding: 10px 8px;
        font-size: 16px;
        color: white;
        scroll-snap-align: start;
        border-bottom: 2px solid transparent;
        transition: all 0.3s ease;
        cursor: pointer;
        min-width: auto;
        text-align: center;
        white-space: nowrap;
    }
    
    .wine-category.active {
        border-bottom-color: white;
        font-weight: bold;
    }
    
    /* 移動端全屏彈出層 */
    .mobile-popup {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: white;
        z-index: 1100;
        overflow-y: auto;
        transition: transform 0.3s ease;
        transform: translateY(100%);
    }
    
    .mobile-popup.active {
        display: block;
        transform: translateY(0);
    }
    
    .mobile-popup-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        background-color: white;
        z-index: 10;
    }
    
    .mobile-popup-content {
        padding: 15px;
    }
    
    .mobile-close-btn {
        background: none;
        border: none;
        font-size: 24px;
        color: var(--text-dark);
    }
    
    /* 酒莊字母索引（水平滾動） */
    .mobile-alphabet-index {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        padding: 10px 0;
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 56px; /* 頂部導航欄高度 */
        background-color: white;
        z-index: 5;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .mobile-alphabet-index::-webkit-scrollbar {
        display: none;
    }
    
    .mobile-alpha-index {
        flex: 0 0 auto;
        display: inline-block;
        min-width: 36px;
        height: 36px;
        line-height: 36px;
        text-align: center;
        margin-right: 5px;
        scroll-snap-align: start;
        background-color: white;
        color: var(--text-dark);
        border-radius: 50%;
        text-decoration: none;
        border: 1px solid var(--border-color);
    }
    
    .mobile-alpha-index.active {
        background-color: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }
}

@media (min-width: 769px) {
    /* 隱藏移動端元素 */
    .wine-categories-scroll,
    .mobile-popup,
    .mobile-menu-toggle {
        display: none !important;
    }
}

/* 字母索引和內容區域樣式 */
.alphabet-index {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 5px 0; /* 減少上下內邊距 */
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 5;
}

.alpha-index {
    display: inline-block;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    background-color: white;
    color: var(--text-dark);
    border-radius: 50%;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.alpha-index:hover, .alpha-index.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.alphabet-content {
    height: calc(90vh - 200px); /* 計算高度，減去彈出層標題、字母索引和內邊距的總高度 */
    overflow-y: auto; /* 只在內容區域顯示滾動條 */
    padding-right: 5px;
    margin-top: 10px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
}

.alphabet-content::-webkit-scrollbar {
    width: 6px;
}

.alphabet-content::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

.alpha-section {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    scroll-margin-top: 10px;
}

.alpha-section:last-child {
    border-bottom: none;
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    .alpha-index {
        width: 25px;
        height: 25px;
        line-height: 25px;
        font-size: 12px;
    }
    
    .alphabet-index {
        padding-bottom: 10px;
    }
    
    .alpha-section {
        margin-bottom: 15px;
    }
}

/* 移動端全屏彈出層 */
.mobile-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    z-index: 1100;
    overflow-y: auto;
    transition: transform 0.3s ease;
    transform: translateY(100%);
}

.mobile-popup.active {
    display: block;
    transform: translateY(0);
}

.mobile-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 10;
}

.mobile-popup-content {
    padding: 15px;
}
