* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #2c3e50;
    color: #333;
    overflow: hidden;
}

/* 画像一覧ボタン（右上） */
.pano-list-btn-top {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 100;
    padding: 12px 20px;
    background: rgba(52, 73, 94, 0.95);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.pano-list-btn-top:hover {
    background: rgba(41, 128, 185, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.pano-list-btn-top span {
    font-size: 18px;
}

/* タイトル表示エリア */
.floor-plan-title {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    word-wrap: break-word;
    cursor: pointer;
    transition: all 0.3s;
}

.floor-plan-title:hover {
    background: rgba(41, 128, 185, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.floor-plan-title span {
    display: block;
}

/* 選択中の画像表示 */
.selected-image-indicator {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 100;
    background: rgba(52, 73, 94, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: none;
    cursor: pointer;
    transition: all 0.3s;
}

.selected-image-indicator.active {
    display: block;
}

.selected-image-indicator:hover {
    background: rgba(231, 76, 60, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.selected-image-indicator:hover .indicator-label::after {
    content: ' (クリックで解除)';
}

.selected-image-indicator .indicator-label {
    font-size: 12px;
    opacity: 0.8;
    display: block;
    margin-bottom: 4px;
}

.selected-image-indicator .indicator-name {
    font-weight: bold;
    font-size: 14px;
    color: #3498db;
}

/* フルビュー図面表示エリア */
.floor-plan-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #ecf0f1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.floor-plan-container .placeholder {
    color: #95a5a6;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    padding: 60px;
    border: 3px dashed #bdc3c7;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.7);
    max-width: 600px;
}

.floor-plan-container .placeholder:hover {
    border-color: #3498db;
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.02);
}

.floor-plan-container .placeholder.drag-over {
    border-color: #2ecc71;
    background: rgba(46, 204, 113, 0.1);
    transform: scale(1.05);
}

.placeholder-content {
    pointer-events: none;
    user-select: none;
}

.placeholder-icon {
    font-size: 80px;
    display: block;
    margin-bottom: 20px;
}

.placeholder-title {
    font-size: 24px;
    font-weight: bold;
    color: #34495e;
    margin-bottom: 10px;
}

.placeholder-subtitle {
    font-size: 16px;
    color: #7f8c8d;
    margin-bottom: 10px;
}

.canvas-wrapper {
    display: none;
    position: relative;
    transform-origin: 0 0;
}

.canvas-wrapper.active {
    display: block;
}

#floor-plan-canvas {
    display: block;
    cursor: crosshair;
}

.pins-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.pins-container .pin {
    pointer-events: auto;
}

/* ピン */
.pin {
    position: absolute;
    width: 30px;
    height: 30px;
    background: #e74c3c;
    border: 3px solid white;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s;
    z-index: 50;
    user-select: none;
}

.pin:hover {
    transform: rotate(-45deg) scale(1.1);
    z-index: 51;
}

.pin.move-mode {
    cursor: grab;
    background: #3498db;
    border-color: #f1c40f;
    animation: pulse 1.5s ease-in-out infinite;
}

.pin.move-mode:hover {
    transform: rotate(-45deg) scale(1.2);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 0 rgba(52, 152, 219, 0.7);
    }
    50% {
        box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 10px rgba(52, 152, 219, 0);
    }
}

.pin:active {
    cursor: grabbing;
}

.pin.dragging {
    cursor: grabbing;
    transition: none;
}

.pin::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
}

/* ピンラベル */
.pin-label {
    position: absolute;
    background: rgba(44, 62, 80, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    pointer-events: auto;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 50;
    user-select: none;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pin-label:hover {
    background: rgba(41, 128, 185, 0.95);
    z-index: 51;
}

.pin-label.last-opened {
    background: rgba(52, 152, 219, 0.95);
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

.pin-label.last-opened:hover {
    background: rgba(41, 128, 185, 1);
}

/* ピンプレビュー */
.pin-preview {
    position: absolute;
    display: none;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 10px;
    z-index: 52;
    pointer-events: none;
    max-width: 250px;
}

.pin-preview.active {
    display: block;
}

.pin-preview img {
    width: 230px;
    height: 130px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.pin-preview .preview-name {
    display: none;
}

/* コンテキストメニュー */
.pin-context-menu,
.hierarchy-context-menu {
    position: fixed;
    display: none;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 5px;
    z-index: 1500;
    min-width: 160px;
}

.pin-context-menu.active,
.hierarchy-context-menu.active {
    display: block;
}

.context-menu-item {
    padding: 12px 15px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #2c3e50;
    font-weight: 500;
}

.context-menu-item:hover {
    background: #ecf0f1;
}

.context-menu-item:first-child:hover {
    background: #d4e6f1;
}

.context-menu-item:last-child:hover {
    background: #fadbd8;
    color: #c0392b;
}

.context-menu-item span {
    font-size: 16px;
}

/* オーバーレイパネル */
.overlay-panel {
    position: fixed;
    top: 0;
    right: -450px;
    width: 420px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
    z-index: 200;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.overlay-panel.active {
    right: 0;
}

.panel-header {
    background: #34495e;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 18px;
    margin: 0;
}

.close-panel {
    background: transparent;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    transition: transform 0.2s;
}

.close-panel:hover {
    transform: scale(1.2);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* 階層管理 */
.hierarchy-tree {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 20px;
}

.tree-location {
    margin-bottom: 10px;
}

.tree-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #f8f9fa;
    border: 2px solid transparent;
}

.tree-item .item-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    cursor: pointer;
}

.tree-item:hover {
    background: #e8f4f8;
    border-color: #3498db;
}

.tree-item.selected {
    background: #3498db;
    color: white;
    font-weight: bold;
}

.tree-item .icon {
    font-size: 16px;
}

.tree-item .add-btn-item {
    width: 28px;
    height: 28px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.tree-item .add-btn-item:hover {
    background: #229954;
    transform: scale(1.15);
}

.tree-item.selected .add-btn-item {
    background: #2ecc71;
}

.tree-item.selected .add-btn-item:hover {
    background: #27ae60;
}

.tree-house {
    margin-left: 20px;
    margin-top: 5px;
}

.tree-area {
    margin-left: 40px;
    margin-top: 5px;
}

.add-btn-inline {
    display: block;
    width: 40px;
    height: 40px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    transition: all 0.3s;
    margin-top: 10px;
    margin-left: 0;
    line-height: 1;
    padding: 0;
}

.add-btn-inline:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.add-btn-inline.tree-house {
    margin-left: 20px;
}

.add-btn-inline.tree-area {
    margin-left: 40px;
}

.current-path {
    padding: 12px;
    background: #ecf0f1;
    border-radius: 4px;
    font-size: 14px;
    color: #2c3e50;
    margin-top: 10px;
}

/* アップロードセクション */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.upload-box label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #2c3e50;
}

.upload-box input[type="file"] {
    display: block;
    margin-top: 8px;
    padding: 10px;
    border: 2px dashed #ddd;
    border-radius: 4px;
    width: 100%;
    cursor: pointer;
    background: #f9f9f9;
}

.upload-box input[type="file"]:hover {
    border-color: #3498db;
    background: #e8f4f8;
}

.info {
    padding: 12px;
    background: #e8f4f8;
    border-left: 4px solid #3498db;
    border-radius: 4px;
}

.info p {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

/* 360度画像リスト */
.upload-btn-wrapper {
    margin-bottom: 20px;
}

.upload-btn-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 20px;
    background: #3498db;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.upload-btn-label:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.upload-btn-label span {
    font-size: 20px;
}

#pano-images-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pano-item {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f9f9f9;
    position: relative;
}

.pano-item:hover {
    border-color: #3498db;
    background: #e8f4f8;
}

.pano-item.selected {
    border-color: #e74c3c;
    background: #ffe8e6;
}

.pano-item.has-pins {
    border-color: #27ae60;
    background: #e8f8f5;
}

.pano-item.has-pins:hover {
    border-color: #229954;
    background: #d5f4e6;
}

.pano-item.has-pins.selected {
    border-color: #e74c3c;
    background: #ffe8e6;
    box-shadow: 0 0 0 2px #27ae60;
}

.pano-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 4px;
}

.pano-item .pin-count {
    display: block;
    font-size: 11px;
    color: #27ae60;
    font-weight: bold;
    text-align: center;
    padding: 4px;
    background: rgba(39, 174, 96, 0.1);
    border-radius: 4px;
    margin-top: 4px;
}

.pano-item .type-badge {
    display: inline-block;
    font-size: 10px;
    color: white;
    font-weight: bold;
    text-align: center;
    padding: 3px 8px;
    background: rgba(52, 152, 219, 0.9);
    border-radius: 3px;
    margin-top: 4px;
}

.pano-item .type-badge.normal {
    background: rgba(149, 165, 166, 0.9);
}

.pano-item .delete-image-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    line-height: 1;
    padding: 0;
    z-index: 10;
}

.pano-item .delete-image-btn:hover {
    background: rgba(192, 57, 43, 1);
    transform: scale(1.1);
}

.pano-item.disabled {
    opacity: 0.6;
}

.pano-item.disabled:hover {
    border-color: #ddd;
    transform: none;
    box-shadow: none;
}

.pano-item.disabled .delete-image-btn {
    pointer-events: auto;
}

/* 保存インジケーター */
.save-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(52, 73, 94, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1500;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.save-indicator.active {
    opacity: 1;
    transform: translateY(0);
}

.save-indicator.success {
    background: rgba(39, 174, 96, 0.95);
}

.save-indicator.error {
    background: rgba(231, 76, 60, 0.95);
}

.save-indicator::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid white;
    border-radius: 50%;
    border-top-color: transparent;
    margin-right: 10px;
    animation: spin 0.8s linear infinite;
}

.save-indicator.success::before,
.save-indicator.error::before {
    animation: none;
    border: none;
    width: 0;
    height: 0;
    margin-right: 0;
}

.save-indicator.success::before {
    content: '✓';
    font-size: 16px;
    margin-right: 8px;
}

.save-indicator.error::before {
    content: '✕';
    font-size: 16px;
    margin-right: 8px;
}

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

/* ローディングオーバーレイ */
.loading-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

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

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top: 6px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: white;
    font-size: 18px;
    font-weight: bold;
    margin-top: 20px;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
}

.modal.active {
    display: block;
}

.modal-content {
    position: relative;
    width: 90%;
    height: 90%;
    margin: 2% auto;
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.close:hover,
.close:focus {
    color: #bbb;
}

#pano-viewer {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* スクロールバー */
.panel-content::-webkit-scrollbar {
    width: 8px;
}

.panel-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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

/* レスポンシブ */
@media (max-width: 768px) {
    .overlay-panel {
        width: 90vw;
        right: -90vw;
    }

    .control-buttons {
        top: 10px;
        left: 10px;
    }

    .control-btn {
        min-width: 50px;
        padding: 10px;
        font-size: 12px;
    }

    .control-btn span {
        font-size: 16px;
    }
}
