/* CSS Reset */
* {
    box-sizing: border-box;
}

/* 新的 Sidebar 樣式 */
#sidebar {
    width: 76px;
    height: calc(100vh - 72px);
    padding: 16px;
    background-color: #ffffff;
    border-right: 2px solid #d9dde3;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

@media (min-width: 1024px) {
    #sidebar {
        width: 250px;
    }
}

/* Search 區域 */
.search-container {
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.04);
    width: 44px;
    height: 36px;
    border-radius: 10px;
    padding: 0 12px;
    transition: background-color 0.3s ease;
}

@media (min-width: 1024px) {
    .search-container {
        width: 218px;
    }
}

.search-container:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

.search-icon {
    width: 16px;
    height: 16px;
    color: rgba(0, 0, 0, 0.2);
    margin-right: 0;
}

@media (min-width: 1024px) {
    .search-icon {
        margin-right: 8px;
    }
}

.search-input {
    display: none;
    background: transparent;
    outline: none;
    font-size: 16px;
    font-weight: 300;
    line-height: 20px;
    color: rgba(0, 0, 0, 0.6);
    width: 100%;
    border: none;
}

@media (min-width: 1024px) {
    .search-input {
        display: block;
    }
}

/* 經銷商/公司 區域 */
.company-header {
    padding: 12px;
}

.company-title {
    font-size: 16px;
    color: #214f7c;
    font-weight: bold;
    display: flex;
    align-items: center;
}

.company-icon {
    margin-right: 8px;
}

.company-text {
    display: none;
}

@media (min-width: 1024px) {
    .company-text {
        display: inline;
    }
}

.country-header {
    padding: 12px;
    padding-top: 4px;
}

.country-title {
    font-size: 16px;
    color: rgba(0, 0, 0, 0.4);
    font-weight: bold;
    display: none;
}

@media (min-width: 1024px) {
    .country-title {
        display: block;
    }
}

/* 國家列表 */
.country-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.dropdown-item .dropdown-toggle {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 6px;
    transition: background-color 0.3s ease;
    text-decoration: none;
    color: inherit;
}

.dropdown-item .dropdown-toggle:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.point-icon {
    width: 0;
    opacity: 0;
    transform: translateX(-8px);
    transition: all 0.5s ease;
}

.dropdown-toggle:hover .point-icon {
    width: 16px;
    opacity: 1;
    transform: translateX(0);
    margin-right: 8px;
}

.country-name {
    font-weight: 500;
    color: #404040;
    transition: all 0.5s ease;
    display: none;
}

@media (min-width: 1024px) {
    .country-name {
        display: block;
    }
}

/* 下拉選單 */
.dropdown-menu {
    display: none;
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 500px; /* 可依需求調整高度 */
    overflow-y: auto; /* 啟用垂直滾輪 */
}

.dropdown-menu.show {
    display: block;
}

.li-list-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 6px;
    margin-top: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.li-list-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.icon-img {
    margin-right: 8px;
    transition: all 0.3s ease;
}

.li-list-item a {
    text-decoration: none;
    color: #404040;
}

/* 新增經銷商按鈕 */
.add-company-btn {
    border: 1px solid #404040;
    border-radius: 10px;
    height: 48px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-company-btn:hover {
    background-color: #ee963f;
    border: none;
    color: white;
}

.add-company-icon {
    margin-right: 0;
}

@media (min-width: 1024px) {
    .add-company-icon {
        margin-right: 4px;
    }
}

.add-company-text {
    font-size: 14px;
    display: none;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    font-weight: bold;
}

@media (min-width: 1024px) {
    .add-company-text {
        display: flex;
    }
}

/* Toggle button */
.toggle-btn {
    position: absolute;
    top: 50%;
    left: 74px;
    transform: translateY(-50%);
    width: 20px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d9dde3;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    background: white;
    cursor: pointer;
    z-index: 101;
}

@media (min-width: 1024px) {
    .toggle-btn {
        display: none;
    }
}

/* Mobile Sidebar Expansion Styles */
.sidebar.expanded,
#sidebar.expanded {
    width: 250px !important;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1000;
    height: 100%;
    box-shadow: 4px 0 8px rgba(0,0,0,0.1);
    background-color: #fff;
}

.sidebar.expanded .company-text,
.sidebar.expanded .country-title,
.sidebar.expanded .country-name,
.sidebar.expanded .add-company-text {
    display: block;
}

.sidebar.expanded .add-company-icon {
    margin-right: 4px;
}

.sidebar.expanded .company-text {
    display: inline;
}

.sidebar.expanded .toggle-btn {
    left: 248px;
}

/* 添加 sidebar-content 樣式 */
.sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu li {
    margin-bottom: 5px;
}

.menu > li > a {
    /* 設置主選單文字為粗體 */
    font-weight: bolder;
}

.menu a {
    display: block;
    /* 按鈕的高度 */
    padding: 8px;
    text-decoration: none;
    color: #ecf0f1;
    background-image: linear-gradient(to bottom right, #30465e, #5b7a9b);
    /* background-color: #30465e; */
    /* 添加外框 */
    border: 2px solid #1e2d3d;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    margin: 0px 8px;
    border-radius: 5px;
    /* 文字置中 */
    text-align: center;
    /* 設置行高，讓文字在按鈕中垂直置中 */
    line-height: 1.5;
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease, padding 0.3s ease, margin 0.3s ease;
}

.menu a:hover {
    background-image: linear-gradient(to bottom right, #1abc9c, #9fd3c8);
    /*background-color: #1abc9c;*/
    /* 移除跳動動畫效果 */
    /* transition: background-color 0.3s ease; */
    /* padding: 15px; */
    /* margin: -8px 0px; */
    /* font-size: 1.2em; */
    z-index: 10;
    /* 確保被選中的按鈕在最上層 */
    position: relative;
    /* 需要設置 position 才能應用 z-index */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    /* 添加浮起效果 */
}

.submenu {
    display: none;
    list-style: none;
    padding-left: 20px;
    flex-direction: column;
}

/*
.menu a.has-submenu:hover+.submenu,
.submenu:hover {
    display: flex;
}
*/

.submenu.submenu-open {
    display: flex;
}

/* 上方相鄰按鈕 */
.submenu li:has(+ li:hover) a {
    /*transform: skewX(-10deg);*/
    /* 傾斜效果 */

    /* 下方相鄰按鈕向下移動 margin-top: 5px;*/
    clip-path: polygon(0% 0%, 100% 0%, 150% 100%, -50% 100%);
    /* 只調整右下角 */
    /* 創建梯形 */

    /* 下方相鄰按鈕變成上梯形 */
    background-color: #16283b;
}

/* 下方相鄰按鈕 */
.submenu li:hover + li a {
    /*transform: skewX(+10deg);*/
    /* 傾斜效果 */
    /* 下方相鄰按鈕向下移動 margin-bottom: 5px;*/
    clip-path: polygon(-15% 0%, 115% 0%, 100% 100%, 0% 100%);
    /* 下方相鄰按鈕變成上梯形 */

    /* 下方相鄰按鈕變成上梯形 */
    /* 其他相鄰按鈕變成下梯形 */
    background-color: #16283b;
}

#toggle-btn {
    display: none;
    padding: 10px;
    background-color: #ddd;
    border: none;
    cursor: pointer;
    z-index: 1;
    position: fixed;
    top: 10px;
    left: 10px;
}

#hamburger-icon {
    width: 30px;
    height: 20px;
    position: relative;
    cursor: pointer;
}

#hamburger-icon span {
    display: block;
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: #333;
    border-radius: 2px;
    transition: 0.25s ease-in-out;
}

#hamburger-icon span:nth-child(1) {
    top: 0px;
}

#hamburger-icon span:nth-child(2) {
    top: 8px;
}

#hamburger-icon span:nth-child(3) {
    top: 16px;
}

#hamburger-icon.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

#hamburger-icon.active span:nth-child(2) {
    opacity: 0;
}

#hamburger-icon.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.content {
    /*width: 100%;
    padding: 0px 50px 0px 10px;
    box-sizing: border-box;
    /* 將 padding 包含在元素尺寸中 */
    /*主要內容區內縮*/
    /*margin-left: 20px;
    transition: margin-left 0.3s ease-in-out;
    overflow: auto;
    /*background-color: #7f2323;*/
    /* 內容超出時顯示滾動條 */
    /* border: 1px solid black; */
    /* 為了方便觀察，加上邊框 */
}

@media (max-width: 768px) {
    /* [RWD 修復] 修正 Class 名稱，改為抽屜式 (Drawer) 覆蓋選單 */
    #sidebar {
        position: fixed;
        left: -260px;
        width: 250px !important;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease-in-out;
        box-shadow: 4px 0 10px rgba(0,0,0,0.15);
    }

    #sidebar.mobile-open {
        left: 0;
    }

    /* 手機版隱藏桌機的展開按鈕 */
    .toggle-btn {
        display: none !important;
    }

    /* 手機版側邊欄強制顯示文字內容 */
    #sidebar .company-text,
    #sidebar .country-title,
    #sidebar .country-name,
    #sidebar .add-company-text {
        display: block;
    }
}

/*圖示 https://tophix.com/font-tools/iconfont-viewer */
/*     https://fontdrop.info/?darkmode=true */
@font-face {
    font-family: "iconfont";
    src: url("./fonts/element-icons.535877f5.woff") format("woff");
    font-weight: normal;
    font-style: normal;
}

.iconfont {
    font-family: "iconfont" !important;
    font-size: 16px;
    font-style: normal;
    display: inline-block;
}

#sidebar-nav-container {
    position: relative;
    z-index: 100;
    overflow: visible;
}
