/* リセットと基本スタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Meiryo', sans-serif;
    font-size: 14px;
    color: #333;
    background-color: #f5f5f5;
}

/* アプリケーションレイアウト */
#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* サイドバー */
#sidebar {
    width: 320px;
    min-width: 320px;
    height: 100vh;
    overflow-y: auto;
    background-color: #fff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    padding: 16px;
    z-index: 1000;
}

/* トップへ戻るリンク */
.back-to-top {
    display: inline-block;
    color: #666;
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 12px;
    transition: color 0.2s;
}

.back-to-top:hover {
    color: #3b82f6;
}

#sidebar h1 {
    font-size: 18px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #3b82f6;
    color: #3b82f6;
}

/* パネル */
.panel {
    margin-bottom: 16px;
    padding: 12px;
    background-color: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.panel h2 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #555;
}

.panel h3 {
    font-size: 13px;
    margin: 8px 0;
    color: #666;
}

/* セレクトボックス */
select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background-color: #fff;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #3b82f6;
}

/* ボタン */
.btn {
    display: inline-block;
    padding: 8px 16px;
    margin: 4px 4px 4px 0;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #3b82f6;
    color: #fff;
}

.btn-primary:hover {
    background-color: #1565c0;
}

.btn-secondary {
    background-color: #757575;
    color: #fff;
}

.btn-secondary:hover {
    background-color: #616161;
}

.btn-download {
    width: 100%;
    background-color: #2e7d32;
    color: #fff;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: bold;
}

.btn-download:hover {
    background-color: #1b5e20;
}

.btn-download:disabled {
    background-color: #a5d6a7;
    cursor: not-allowed;
}

.btn-full {
    width: 100%;
}

/* ファイルインポート */
.file-import {
    margin-bottom: 10px;
}

.file-name {
    margin-top: 8px;
    padding: 6px 10px;
    background-color: #e3f2fd;
    border-radius: 4px;
    font-size: 12px;
    color: #3b82f6;
    word-break: break-all;
}

#dxfCrsSection {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #e0e0e0;
}

#dxfCrsSection label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #666;
}

.area-info {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

.area-info span {
    font-weight: bold;
    color: #3b82f6;
}

/* バッファコントロール */
.buffer-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.buffer-control input[type="number"] {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.buffer-control input[type="number"]:focus {
    outline: none;
    border-color: #3b82f6;
}

.buffer-control .unit {
    font-size: 14px;
    color: #666;
    min-width: 20px;
}

/* ズームコントロール */
.zoom-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.zoom-control input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: #ddd;
    border-radius: 3px;
}

.zoom-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
}

#zoomValue {
    font-weight: bold;
    font-size: 16px;
    color: #3b82f6;
    min-width: 24px;
    text-align: center;
}

.hint {
    font-size: 12px;
    color: #888;
    margin-top: 6px;
}

/* 情報ボックス */
.info-box {
    margin-top: 10px;
    padding: 10px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 13px;
}

.info-box table {
    width: 100%;
}

.info-box td {
    padding: 2px 0;
}

.info-box td:first-child {
    color: #666;
    width: 60px;
}

.info-box td:last-child {
    font-family: 'Consolas', monospace;
    color: #333;
}

.stats {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.stats p {
    margin: 4px 0;
}

.stats span {
    font-weight: bold;
    color: #3b82f6;
}

/* ダウンロードセクション */
.download-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.progress-container {
    margin-top: 10px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: #2e7d32;
    width: 0%;
    transition: width 0.3s ease;
}

#progressText {
    margin-top: 6px;
    font-size: 12px;
    color: #666;
    text-align: center;
}

/* カーソル情報 */
.cursor-info p {
    margin: 4px 0;
    font-family: 'Consolas', monospace;
}

.cursor-info span {
    color: #3b82f6;
}

/* 標高凡例 */
#elevationLegend {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.legend-color {
    width: 30px;
    height: 16px;
    border: 1px solid #ccc;
    border-radius: 2px;
}

/* 地図 */
#map {
    flex: 1;
    height: 100vh;
    position: relative;
}

/* 地図上のオーバーレイパネル */
.map-overlay-panel {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 10px 12px;
    z-index: 1000;
    font-size: 12px;
    min-width: 140px;
}

.map-overlay-panel.bottom-left {
    bottom: 30px;
    left: 10px;
}

.map-overlay-panel.bottom-right {
    bottom: 30px;
    right: 10px;
}

.overlay-header {
    font-size: 11px;
    font-weight: bold;
    color: #666;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e0e0e0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* カーソル情報（オーバーレイ版） */
.map-overlay-panel .cursor-info p {
    margin: 3px 0;
    font-family: 'Consolas', monospace;
    font-size: 12px;
}

.map-overlay-panel .cursor-info span {
    color: #3b82f6;
    font-weight: bold;
}

/* 標高凡例（オーバーレイ版） */
.map-overlay-panel #elevationLegend {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.map-overlay-panel .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.map-overlay-panel .legend-color {
    width: 24px;
    height: 12px;
    border: 1px solid #ccc;
    border-radius: 2px;
}

/* ユーティリティ */
.hidden {
    display: none !important;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        min-width: auto;
        height: auto;
        max-height: 40vh;
    }

    #map {
        height: 60vh;
    }
}

/* Leaflet カスタマイズ */
.leaflet-control-layers {
    display: none;
}

.leaflet-draw-toolbar a {
    background-color: #fff;
}

/* ローディングオーバーレイ */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
