/* リセットと基本スタイル */
* {
    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: 360px;
    min-width: 360px;
    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: #0891b2;
}

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

/* パネル */
.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;
}

/* タブ */
.tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 12px;
}

.tab-btn {
    flex: 1;
    padding: 10px 8px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #0891b2;
}

.tab-btn.active {
    color: #0891b2;
    border-bottom-color: #0891b2;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* フォーム要素 */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: #555;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row .form-group {
    flex: 1;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background-color: #fff;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #0891b2;
}

/* ボタン */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #0891b2;
    color: #fff;
}

.btn-primary:hover {
    background-color: #0e7490;
}

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

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

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 座標系選択 */
.zone-select-wrapper {
    margin-bottom: 12px;
}

.zone-info {
    margin-top: 6px;
    font-size: 11px;
    color: #888;
    line-height: 1.4;
}

/* 結果パネル */
.results-panel {
    background-color: #f0fdfa;
    border: 1px solid #99f6e4;
    padding: 12px;
    border-radius: 6px;
}

.results-panel h2 {
    color: #0e7490;
    font-size: 14px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #99f6e4;
}

.result-section {
    margin-bottom: 12px;
}

.result-section h3 {
    font-size: 12px;
    color: #0891b2;
    margin-bottom: 6px;
    font-weight: 600;
}

.result-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    font-size: 13px;
}

.result-grid dt {
    color: #666;
}

.result-grid dd {
    font-family: 'Consolas', 'Monaco', monospace;
    color: #333;
    font-weight: 500;
}

.result-grid dd.error {
    color: #dc2626;
}

.result-grid dd.positive {
    color: #16a34a;
}

.result-grid dd.negative {
    color: #dc2626;
}

.result-note {
    font-size: 11px;
    color: #888;
    font-family: inherit;
    font-weight: normal;
}

/* 主要な値の強調 */
.result-highlight {
    background-color: #ccfbf1;
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 12px;
}

.result-highlight .result-grid dd {
    font-size: 15px;
    font-weight: 600;
    color: #0e7490;
}

/* ボタングループ */
.button-group {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* 地図コントロール */
.map-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.map-controls select {
    flex: 1;
}

/* エラーメッセージ */
.error-message {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 10px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 12px;
}

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

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

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

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

/* カスタムマーカー */
.custom-marker {
    position: relative;
}

.marker-pin {
    width: 20px;
    height: 20px;
    border-radius: 50% 50% 50% 0;
    background: #0891b2;
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -20px 0 0 -10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.marker-pin::after {
    content: '';
    width: 10px;
    height: 10px;
    margin: 5px 0 0 5px;
    background: #fff;
    position: absolute;
    border-radius: 50%;
}

.marker-pulse {
    background: rgba(8, 145, 178, 0.3);
    border-radius: 50%;
    height: 40px;
    width: 40px;
    position: absolute;
    left: 50%;
    top: 50%;
    margin: -20px 0 0 -20px;
    animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* 地図上オーバーレイ */
.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;
}

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

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

/* ヒント */
.hint {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
}

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

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

    #sidebar {
        width: 100%;
        min-width: auto;
        height: auto;
        max-height: 50vh;
        overflow-y: auto;
    }

    #map {
        height: 50vh;
    }

    .form-row {
        flex-direction: column;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: none;
        width: 50%;
    }
}

/* Leaflet カスタマイズ */
.leaflet-control-attribution {
    font-size: 10px;
}
