/* 基本スタイル */
body {
    font-family: 'Noto Sans JP', sans-serif;
    margin: 0;
    padding: 0;
    overflow: auto;
    overscroll-behavior: none;
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: auto;
    touch-action: pan-x pan-y;
    width: 100%;
    height: 100%;
    position: relative;
}

html {
    overscroll-behavior: none;
    overscroll-behavior-y: none;
    touch-action: pan-x pan-y;
    width: 100%;
    height: 100%;
    position: relative;
}

/* ローディングインジケータ */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-indicator.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    margin-top: 10px;
    font-size: 16px;
    color: #333;
}

/* メインコンテナ */
.container {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* サイドバー */
.sidebar {
    width: 170px;
    background: #f5f5f5;
    border-right: 1px solid #ddd;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 50px;
    height: calc(100vh - 50px);
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    z-index: 1000;
    padding-bottom: 80px;
    touch-action: pan-y !important;
    -webkit-tap-highlight-color: transparent !important;
    scroll-behavior: auto !important;
    scrollbar-width: thin !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    perspective: 1000 !important;
    -webkit-perspective: 1000 !important;
    -webkit-overflow-scrolling: touch !important;
}

/* サイドバーが読み込まれたときに上部にスクロールする */
.sidebar::before {
    content: "";
    display: block;
    height: 0;
    margin-top: 0;
}

.menu-items {
    height: auto;
    min-height: 100%;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 80px;
    position: relative;
    z-index: 1001;
    touch-action: pan-y !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: transform !important;
}

/* メニュー項目の最初の要素に上部マージンを追加して、常に上部に表示されるようにする */
.menu-category:first-child {
    margin-top: 0 !important;
}

.menu-category {
    border-bottom: 1px solid #ddd;
}

/* 図面カテゴリ */
.floorplan-category {
    margin-top: 0 !important;
    margin-bottom: 15px;
    border-bottom: 2px solid #4CAF50;
    position: relative;
    z-index: 1002;
}

.category-header {
    padding: 15px;
    cursor: pointer;
    background: #fff;
    position: relative;
    font-size: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 1003;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: transform !important;
}

/* 図面カテゴリのヘッダーを特別に強調 */
.floorplan-category .category-header {
    background: #f0f8ff;
    font-weight: bold;
    border-left: 4px solid #4CAF50;
}

/* カテゴリ名の右側に▶を追加 */
.category-header::after {
    content: "▶";
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #666;
}

.category-header:hover {
    background: #f0f0f0;
}

.category-header.expanded {
    background: #e8e8e8;
}

.category-header.expanded::after {
    content: "▼";
}

.category-content {
    display: none;
    background: #fff;
}

[class$="-type"] {
    padding: 10px 15px 10px 30px;
    cursor: pointer;
    font-size: 14px;
}

[class$="-type"]:hover {
    background: #f0f0f0;
}

/* データ送信ボタン */
.send-data-button {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 170px !important;
    height: 50px !important;
    background-color: #4CAF50 !important;
    color: white !important;
    border: none !important;
    cursor: pointer !important;
    font-weight: bold !important;
    z-index: 999999 !important;
    display: block !important;
    font-size: 16px !important;
    text-align: center !important;
    line-height: 50px !important;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1) !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    outline: none !important;
}

/* 追加のデータ送信ボタン - 表示設定 */
#fixed-send-button {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 170px !important;
    height: 50px !important;
    background-color: #4CAF50 !important;
    color: white !important;
    border: none !important;
    cursor: pointer !important;
    font-weight: bold !important;
    z-index: 1000000 !important;
    /* 通常のボタンよりも前面に */
    display: block !important;
    font-size: 16px !important;
    text-align: center !important;
    line-height: 50px !important;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1) !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    outline: none !important;
}

/* メインコンテンツ */
.main-content {
    flex: 1;
    margin-left: 170px;
    width: calc(100% - 170px);
    height: 100vh;
    overflow: auto;
    position: relative;
    -webkit-overflow-scrolling: touch !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    perspective: 1000 !important;
    -webkit-perspective: 1000 !important;
}

.floor-plan {
    width: 100%;
    height: 100%;
    overflow: auto !important;
    background: #fff;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    -webkit-overflow-scrolling: touch !important;
    touch-action: manipulation !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    perspective: 1000 !important;
    -webkit-perspective: 1000 !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
    scroll-behavior: auto !important;
    overscroll-behavior: none !important;
    -webkit-overscroll-behavior: none !important;
}

.floorplan-image-container {
    background: #fff;
    padding: 20px 20px 60px 20px;
    margin: 0 auto;
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    display: block;
    text-align: center;
    touch-action: manipulation !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    perspective: 1000 !important;
    -webkit-perspective: 1000 !important;
    box-sizing: border-box !important;
    -webkit-box-sizing: border-box !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* 図面画像を中央揃えにする */
.floorplan-image-container img {
    display: block !important;
    margin: 0 auto !important;
    max-width: 100% !important;
    height: auto !important;
    position: relative !important;
    left: 0 !important;
    right: 0 !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* 上部メニュー */
.top-menu {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #fff;
    -webkit-box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 100;
    max-height: 400px;
}

.top-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #ddd;
}

.category-title {
    font-size: 18px;
    font-weight: bold;
}

.close-top-menu {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0 10px;
    color: #666;
}

.products-scroll {
    height: 350px;
    overflow: hidden;
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    z-index: 105;
    background: #fff;
    border-bottom: 1px solid #ddd;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    perspective: 1000 !important;
    -webkit-perspective: 1000 !important;
    overscroll-behavior: none !important;
    -webkit-overscroll-behavior: none !important;
}

.products-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    padding: 10px;
    min-width: max-content;
    position: relative;
    overflow-y: auto !important;
    overflow-x: auto !important;
    height: 330px;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box;
    touch-action: pan-y pan-x !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    perspective: 1000 !important;
    -webkit-perspective: 1000 !important;
    overscroll-behavior: none !important;
    -webkit-overscroll-behavior: none !important;
    scroll-behavior: auto !important;
}

.product-item {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    cursor: pointer;
    -webkit-transition: box-shadow 0.2s;
    transition: box-shadow 0.2s;
    position: relative;
    margin-bottom: 5px;
    height: calc(100% - 5px);
    box-sizing: border-box;
}

.product-item:hover {
    -webkit-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.product-item img {
    width: 100%;
    height: 150px;
    -o-object-fit: cover;
    object-fit: cover;
    border-radius: 2px;
}

.product-item>div {
    margin-top: 8px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-size {
    color: #666;
    white-space: normal !important;
    overflow: visible !important;
    height: auto !important;
    min-height: 40px;
}

/* 家具ポップアップ */
.furniture-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
}

.popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 20px;
    border-radius: 4px;
    width: 90%;
    max-width: 500px;
}

.close-popup {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.popup-header h3 {
    margin: 0 0 10px;
}

.popup-image {
    text-align: center;
    margin-bottom: 15px;
}

.popup-image img {
    max-width: 100%;
    max-height: 300px;
    -o-object-fit: contain;
    object-fit: contain;
}

.popup-image iframe {
    width: 100%;
    height: 300px;
    border: none;
}

.popup-size {
    font-size: 16px;
    color: #666;
    margin-bottom: 5px;
}

.popup-price {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
}

.popup-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.popup-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.popup-cancel {
    background: #f5f5f5;
    color: #333;
}

.popup-place {
    background: #4CAF50;
    color: #fff;
}

/* 家具要素 */
.furniture {
    position: absolute !important;
    cursor: move;
    cursor: -webkit-grab;
    cursor: grab;
    touch-action: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    transform-origin: center center !important;
    will-change: transform, left, top !important;
    -webkit-transform-style: preserve-3d !important;
    -webkit-backface-visibility: hidden !important;
    z-index: 2000 !important;
}

.furniture:active {
    cursor: -webkit-grabbing;
    cursor: grabbing;
}

.furniture img {
    width: 100%;
    height: 100%;
    -o-object-fit: contain;
    object-fit: contain;
    pointer-events: none;
}

.furniture.selected {
    outline: 2px solid #4CAF50 !important;
    border: 2px solid #4CAF50 !important;
}

.furniture-name {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    text-align: center;
}

.furniture-delete,
.furniture-rotate {
    position: absolute;
    display: none;
    width: 35px;
    height: 35px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    font-size: 25px;
    line-height: 35px;
    text-align: center;
    padding: 0;
    z-index: 1000;
}

.furniture-delete {
    top: -35px;
    right: -35px;
    color: #ff4444;
    z-index: 1001 !important;
    pointer-events: auto !important;
    touch-action: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

.furniture-rotate {
    bottom: -35px;
    right: -35px;
    color: #2196F3;
    z-index: 1001 !important;
    pointer-events: auto !important;
    touch-action: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    will-change: transform !important;
    -webkit-transform-style: preserve-3d !important;
    -webkit-backface-visibility: hidden !important;
}

.furniture.selected .furniture-delete,
.furniture.selected .furniture-rotate {
    display: inline-block;
}

/* 図面変更確認ダイアログ */
.confirm-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
}

.confirm-content {
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 20px;
    border-radius: 4px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.confirm-message {
    font-size: 16px;
    margin-bottom: 20px;
}

.confirm-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.confirm-buttons button {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.confirm-no {
    background: #f5f5f5;
    color: #333;
}

.confirm-yes {
    background: #4CAF50;
    color: #fff;
}

/* スクロールバーのスタイル */
::-webkit-scrollbar {
    width: 8px;
    display: block;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* iOSのスクロール問題対応 */
.menu-items,
.floor-plan,
.products-container {
    -webkit-overflow-scrolling: touch !important;
}
