/* 基本設定 */
body {
    margin: 0;
    padding: 0;
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    overflow: hidden;
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}

:root {
    --base-unit: 60px;
    --font-base: 18px;
    --font-small: 14px;
    --spacing: 25px;
    --radius: 12px;
}

@media screen and (max-width: 600px) {
    :root {
        --base-unit: 48px !important;
        --font-base: 15px !important;
        --font-small: 12px !important;
        --spacing: 15px !important;
    }

    .control-icon svg {
        width: 24px !important;
        height: 24px !important;
    }

    .maplibregl-ctrl-group button {
        width: 48px !important;
        height: 48px !important;
    }

    /* スマホ時の展開サイズ調整 */
    #layer-tab-container.expanded {
        width: 200px !important;
    }

    #data-tab-container.expanded {
        width: 220px !important;
    }

    #opacity-tab-container.expanded {
        width: 230px !important;
    }

    #info-container.expanded {
        width: calc(100vw - 40px) !important;
        /* 画面端の余白を確保 */
        max-width: 270px !important;
        /* これ以上は広がらないように制限 */
        height: auto !important;
    }

    .maplibregl-ctrl-top-right {
        margin-top: calc((48px * 3) + 45px) !important;
    }
}

.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

.left-controls-column {
    position: relative;
    top: var(--spacing);
    left: var(--spacing);
    z-index: 110;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
    pointer-events: none;
}

.left-controls-column>* {
    pointer-events: auto;
}

.right-controls-column {
    position: absolute;
    top: var(--spacing);
    right: var(--spacing);
    bottom: var(--spacing);
    width: var(--base-unit);
    z-index: 110;
    pointer-events: none;
}

.right-controls-column>* {
    pointer-events: auto;
}

#layer-tab-container {
    position: absolute;
    top: 0;
    right: 0;
}

#opacity-tab-container {
    position: absolute;
    top: calc(var(--base-unit) + 15px);
    right: 0;
}

#info-container {
    position: absolute;
    top: calc((var(--base-unit) * 2) + 30px);
    right: 0;
}

/* パネル全体の共通設定：heightのアニメーションを削除してチラつきを防止 */
.expandable-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: var(--base-unit);
    height: var(--base-unit);
    background: white;
    border-radius: var(--radius);
    transition: height 0.35s cubic-bezier(0.25, 1, 0.5, 1),
        border-radius 0.35s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    cursor: pointer;
    box-sizing: border-box;
    z-index: 1;
}

.expandable-container.expanded {
    z-index: 10;
    height: auto;
    /* 展開時は幅を広げるアニメーションを維持したい場合 */
    transition: width 0.35s cubic-bezier(0.25, 1, 0.5, 1),
        height 0.35s ease;
}

/* 各パネルの展開サイズ指定 */
#layer-tab-container.expanded {
    width: 220px;
    padding-bottom: 5px;
    cursor: default;
}

#opacity-tab-container.expanded {
    width: 300px;
    height: var(--base-unit);
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    cursor: default;
}

/* 案内パネル展開時の設定 */
#info-container.expanded {
    width: 260px;
    max-width: 90vw;
    right: 0;
    cursor: default;
}

#data-tab-container.expanded {
    width: 260px;
    max-height: calc(100vh - (var(--spacing) * 2) - 40px);
    cursor: default;
}

.control-icon {
    width: calc(var(--base-unit) - 2px);
    min-width: calc(var(--base-unit) - 2px);
    height: calc(var(--base-unit) - 2px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.right-controls-column .expandable-container {
    align-items: flex-end;
}

#opacity-tab-container {
    align-items: center;
}

#data-tab-container .control-icon {
    align-self: flex-start;
}

.control-content {
    display: none;
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
    width: 100%;
    box-sizing: border-box;
}

.expanded .control-content {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.layer-options {
    flex-direction: column;
    gap: 8px;
    padding: 0 15px 15px 15px;
    width: 100%;
}

.data-options {
    flex-direction: column;
    gap: 15px;
    padding: 0 15px 15px 15px;
    overflow-y: auto;
}

.category-group {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

/* 大カテゴリタイトルのレイアウト調整 */
.category-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: bold;
    color: #000000;
    /* border-bottom: 1px solid #eee; */
    padding-bottom: 0px;
    margin-top: 0px;
    margin-bottom: 0px;

    /* 💡【重要】親の横幅が広がっている最中も、絶対に文字を縦並び（改行）にさせない */
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
}

.subcategory-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* カテゴリタイトル内のlabelの微調整 */
.category-title .layer-label {
    background: #f9f9f9;
    /* ここをお好みの色（例: 薄いグレーや薄い青など）に変更 */
    border: 1px solid #eee !important;
    /* 枠線が必要であれば指定 */
}

/* チェック時の背景色を維持しつつ、デザインを統一する */
.category-title .layer-label:has(input:checked) {
    background: #138664;
    color: white;
    border-radius: 8px;
}

.layer-label {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    padding: 10px 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #f9f9f9;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.layer-label:hover {
    background: #f0f0f0;
}

.layer-label:has(input:checked) {
    background: #333;
    color: white;
    border-color: #333;
}

.sub-label:has(input:checked) {
    background: #006cd8;
    border-color: #006cd8;
}

.layer-label input[type="checkbox"] {
    cursor: pointer;
    margin: 0;
    width: 15px;
    height: 15px;
}

.maplibregl-ctrl-top-right {
    position: absolute !important;
    top: var(--spacing) !important;
    right: var(--spacing) !important;
    left: auto !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
    z-index: 100 !important;
    margin-top: calc((var(--base-unit) * 3) + 45px) !important;
}

.maplibregl-ctrl-group {
    background: none !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
}

.maplibregl-ctrl-group button {
    width: var(--base-unit) !important;
    height: var(--base-unit) !important;
    background: white !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    border-radius: var(--radius) !important;
    margin: 0 !important;
}

.info-panel-content {
    display: none;
    flex-direction: column;
    padding: 0 15px 15px 15px;
    width: 260px;
    box-sizing: border-box;
}

.expanded .info-panel-content {
    display: flex;
}

.info-inner {
    width: 100%;
    white-space: normal;
    word-break: break-all;
}

.info-title {
    margin: 0 0 10px 0;
    font-size: 16px;
    border-left: 4px solid #333;
    padding-left: 10px;
    line-height: 1.2;
    font-weight: bold;
}

.disclaimer {
    padding: 10px 15px;
    background: #f0f7ff;
    border-left: 4px solid #006cd8;
    border-radius: 2px 6px 6px 2px;
}

.disclaimer-list {
    margin: 0;
    padding: 0 0 0 1.2em;
    list-style-type: disc;
    font-size: 13px;
    color: #555;
    line-height: 1.6;
}

.disclaimer-list li {
    margin-bottom: 4px;
}

.disclaimer-list li:last-child {
    margin-bottom: 0;
}

#map {
    background: #e0f2ff !important;
}

.custom-3d-control button {
    font-weight: bold;
    font-size: 12px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--base-unit) !important;
    height: var(--base-unit) !important;
    cursor: pointer;
    background-color: #ffffff;
    transition: background-color 0.2s;
    margin: 0 !important;
}

.custom-3d-control button:hover {
    background-color: #f5f5f5;
}

.layer-label:has(input:disabled) {
    cursor: not-allowed;
    opacity: 0.8;
}

.opacity-options {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-grow: 1;
    min-width: 0;
    padding: 0 10px 0 15px;
    box-sizing: border-box;
    height: 100%;
}

.opacity-slider-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
}

.opacity-slider-title {
    font-size: 13px;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    flex-shrink: 0;
}

#sld-opacity {
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
    margin: 0;
    cursor: pointer;
    accent-color: #333;
}

.bottom-center-logo {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 110;
    pointer-events: none;
}

.map-logo {
    width: 300px;
    height: auto;
    display: block;
    /* ここから追加 */
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    /* ここまで追加 */
}

@media screen and (max-width: 600px) {
    .bottom-center-logo {
        bottom: 50px;
    }

    .map-logo {
        width: 180px;
    }
}

/* 大カテゴリタイトルのレイアウト調整 */
.category-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: bold;
    color: #000000;
    /* border-bottom: 1px solid #eee; */
    padding-bottom: 0px;
    margin-bottom: 0px;
    cursor: default;
    /* タイトル自体はデフォルトカーソル */
}

/* チェックボックス部分の当たり判定 */
.category-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    user-select: none;
    padding: 2px 4px;
}

/* 右側の開閉クリックエリア（幅いっぱいに広げて当たり判定を確保） */
.category-toggle-trigger {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-grow: 1;
    /* 残りの余白をすべてクリック判定にする */
    align-self: stretch;
    /* 上下の高さもいっぱいに広げる */
    cursor: pointer;
    padding-left: 20px;
    /* 左側に少しマージンを持たせて誤クリック防止 */
}

.cat-toggle-text {
    color: #888;
    user-select: none;
}

/* =================================================================
   検索窓・検索結果周りのスタイル（前面表示の強制）
   ================================================================= */

.search-wrapper {
    position: absolute;
    /* カラム内で縦並びにするため relative に */
    top: 75px;
    left: 0;
    /* z-index: 150; */
    /* レイヤータブ等より確実の上に表示されるように高めに設定 */
    width: fit-content;
}

.search-container {
    display: flex;
    align-items: center;
    width: var(--base-unit);
    height: var(--base-unit);
    background: white;
    border-radius: var(--radius);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    /* 入力欄を隠す用。候補リストは外に出したので影響しません */
}

/* 検索窓が展開されたときの横幅 */
.search-container.expanded {
    width: 320px;
}

@media screen and (max-width: 600px) {
    .search-container.expanded {
        width: 260px;
    }
}

.search-icon {
    min-width: var(--base-unit);
    height: var(--base-unit);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    flex-shrink: 0;
}

#search-input {
    flex-grow: 1;
    /* 💡 残りの幅をいっぱいに広げる */
    height: 100%;
    border: none;
    outline: none;
    font-size: var(--font-small);
    padding: 0 40px 0 10px;
    /* 💡 右側にバツボタン用の余白（40px）を確保 */
    font-weight: bold;
    background: transparent;
    opacity: 0;
    /* 💡 初期状態（閉じている時）は完全に非表示 */
    transition: opacity 0.2s ease;
    /* 💡 ふわっと表示させる */
    width: 0;
    /* 💡 閉じている時は幅を0にしてはみ出しを防ぐ */
    min-width: 0;
}

/* 検索窓が開いた時だけ入力欄を見せる */
.search-container.expanded #search-input {
    opacity: 1;
    width: auto;
}

/* 💡 検索結果のドロップダウン（最前面に強制表示） */
.search-results {
    position: absolute;
    top: 100%;
    /* 検索窓の真下に配置 */
    left: 0;
    width: 320px;
    /* 横幅を明示的に固定して潰れを防止 */
    background: #ffffff !important;
    /* 背景色を不透明な白に強制 */
    border-radius: var(--radius);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    max-height: 280px;
    overflow-y: auto;
    display: none;
    /* JSで block に切り替え */
    z-index: 200;
    /* マップ上のあらゆる要素より前面にする */
    margin-top: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

@media screen and (max-width: 600px) {
    .search-results {
        width: 260px;
    }
}

/* 検索候補アイテム */
.search-item {
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    background: #ffffff;
    transition: background 0.2s ease;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover,
.search-item.selected {
    background: #6898d3 !important;
    /* 選択時のハイライト */
}

/* スマホ用の追記 */
@media screen and (max-width: 600px) {
    .search-wrapper {
        top: 62px;
        /* 48px + 間隔15px 程度に合わせて調整 */
    }
}