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

html {
    height: auto;
}

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

/* アプリケーションレイアウト - PC */
@media (min-width: 769px) {
    #app {
        display: flex;
        height: 100vh;
        width: 100vw;
    }
}

/* アプリケーションレイアウト - モバイル */
@media (max-width: 768px) {
    #app {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-height: 100vh;
    }

    #sidebar {
        order: 1;
    }

    .results-panel {
        order: 2;
    }

    #map {
        order: 3;
    }
}

/* サイドバー */
#sidebar {
    background-color: #fff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    padding: 16px;
    z-index: 1000;
}

@media (min-width: 769px) {
    #sidebar {
        width: 420px;
        min-width: 420px;
        height: 100vh;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    #sidebar {
        width: 100%;
        min-width: auto;
    }
}

.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;
}

/* タブ */
.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: 12px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
}

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

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

.tab-container {
    min-height: 180px;
    margin-bottom: 12px;
}

.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: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%;
}

/* 座標系選択 */
.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;
    padding: 16px;
    z-index: 1000;
}

@media (min-width: 769px) {
    .results-panel {
        position: relative;
        width: 320px;
        min-width: 320px;
        height: 100vh;
        overflow-y: auto;
        border-left: 1px solid #99f6e4;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    }
}

@media (max-width: 768px) {
    .results-panel {
        width: 100%;
        border-top: 1px solid #99f6e4;
    }
}

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

.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border: none;
    background: #e0e0e0;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background: #ccc;
}

.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;
}

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

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

/* ネットワークステータス */
.network-status {
    margin-top: 16px;
    text-align: center;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.status-badge.online {
    background-color: #d1fae5;
    color: #065f46;
}

.status-badge.offline {
    background-color: #fef3c7;
    color: #92400e;
}

/* ローディング */
.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 {
    position: relative;
}

@media (min-width: 769px) {
    #map {
        flex: 1;
        height: 100vh;
    }
}

@media (max-width: 768px) {
    #map {
        width: 100%;
        height: 400px;
    }
}

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

/* レスポンシブ対応（追加スタイル） */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: none;
        width: 50%;
        font-size: 11px;
        padding: 8px 4px;
    }

    .close-btn {
        display: none;
    }
}

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