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

:root {
    --primary-color: #10b981;
    --primary-hover: #059669;
    --secondary-color: #6366f1;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --panel-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', 'Meiryo', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
}

#app {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* 左サイドパネル */
#side-panel {
    width: 320px;
    min-width: 280px;
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
}

/* ヘッダー */
.panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
}

.panel-header .back-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 12px;
    display: block;
    margin-bottom: 4px;
}

.panel-header .back-link:hover {
    color: white;
}

.panel-header h1 {
    color: white;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header h1 svg {
    width: 24px;
    height: 24px;
}

/* パネルコンテンツ */
.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* セクション */
.section {
    border-bottom: 1px solid var(--border-color);
}

.section-header {
    padding: 12px 16px;
    background-color: #f8fafc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.section-header:hover {
    background-color: #f1f5f9;
}

.section-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header h3 svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.section-toggle {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.section.collapsed .section-toggle {
    transform: rotate(-90deg);
}

.section-body {
    padding: 12px 16px;
}

.section.collapsed .section-body {
    display: none;
}

/* ファイルインポート */
#drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 24px 16px;
    text-align: center;
    background-color: #fafafa;
    transition: all 0.2s;
    cursor: pointer;
}

#drop-zone:hover {
    border-color: var(--primary-color);
    background-color: #ecfdf5;
}

#drop-zone.drag-over {
    border-color: var(--primary-color);
    background-color: #ecfdf5;
}

#drop-zone svg {
    width: 32px;
    height: 32px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

#drop-zone p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 4px 0;
}

#drop-zone .formats {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* レイヤリスト */
.layer-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background-color: #f8fafc;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.layer-item.hidden {
    opacity: 0.5;
}

.layer-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 14px;
}

.layer-icon.sima { background-color: #dbeafe; color: #2563eb; }
.layer-icon.kml { background-color: #fef3c7; color: #d97706; }
.layer-icon.dxf { background-color: #dcfce7; color: #16a34a; }
.layer-icon.exif { background-color: #fce7f3; color: #db2777; }

.layer-info {
    flex: 1;
    min-width: 0;
}

.layer-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.layer-actions {
    display: flex;
    gap: 4px;
}

.layer-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.layer-btn:hover {
    background-color: #e2e8f0;
    color: var(--text-primary);
}

.layer-btn.danger:hover {
    background-color: #fee2e2;
    color: var(--danger-color);
}

.layer-btn svg {
    width: 16px;
    height: 16px;
}

.empty-layers {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* 座標系設定 */
.form-group {
    margin-bottom: 12px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    background-color: white;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* ポイントリスト */
.point-list {
    max-height: 300px;
    overflow-y: auto;
}

.point-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.point-item:last-child {
    border-bottom: none;
}

.point-item:hover {
    background-color: #f1f5f9;
}

.point-item.selected {
    background-color: #ecfdf5;
}

.point-number {
    width: 32px;
    height: 32px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.point-details {
    flex: 1;
    min-width: 0;
}

.point-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.point-coords {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: monospace;
}

.point-nav-btn {
    padding: 6px 12px;
    background-color: #4285f4;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.point-nav-btn:hover {
    background-color: #3367d6;
}

.point-nav-btn svg {
    width: 14px;
    height: 14px;
}

/* マップエリア */
#map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* マップコントロール */
.map-controls {
    position: absolute;
    right: 10px;
    bottom: 100px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.map-control-btn {
    width: 40px;
    height: 40px;
    background-color: white;
    border: none;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.map-control-btn:hover {
    background-color: #f1f5f9;
}

.map-control-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.map-control-btn svg {
    width: 20px;
    height: 20px;
}

/* 現在地情報（サイドパネル内） */
.location-info-panel {
    margin: 0 12px 12px;
    background-color: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 12px;
}

.location-info-panel.hidden {
    display: none;
}

.location-info-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.location-info-header svg {
    width: 16px;
    height: 16px;
}

.location-info-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* 現在地情報（地図下部） */
.map-location-info {
    position: absolute;
    bottom: 30px;
    left: 10px;
    right: auto;
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.map-location-info.hidden {
    display: none;
}

.location-info-content {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    font-size: 11px;
    flex: 1;
}

.location-info-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.location-label {
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.location-value {
    font-family: 'Consolas', 'Monaco', monospace;
    color: var(--text-primary);
    font-weight: 600;
}

/* 座標表示トグルボタン */
.coords-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    margin-left: 8px;
    flex-shrink: 0;
}

.coords-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.coords-toggle-btn svg {
    width: 16px;
    height: 16px;
}

.coords-toggle-btn.hidden-mode svg {
    opacity: 0.4;
}

.coords-toggle-btn.hidden-mode::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 20px;
    background: currentColor;
    transform: rotate(45deg);
}

/* ステータスバー（サイドパネル内） */
.status-bar-panel {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background-color: #f8fafc;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
}

.status-bar-panel svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* 互換性のために旧CSSも残す */
.current-location-info {
    display: none;
}

#status-bar:not(.status-bar-panel) {
    display: none;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 16px;
}

.status-item svg {
    width: 14px;
    height: 14px;
}

.status-divider {
    width: 1px;
    height: 14px;
    background-color: var(--border-color);
    margin-right: 16px;
}

/* モバイル対応 */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }

    /* パネルトグルボタン */
    .panel-toggle-btn {
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1001;
        width: 44px;
        height: 44px;
        background-color: white;
        border: none;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .panel-toggle-btn svg {
        width: 24px;
        height: 24px;
        color: var(--text-primary);
    }

    /* オーバーレイ */
    .panel-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1001;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .panel-overlay.visible {
        opacity: 1;
        visibility: visible;
    }

    /* サイドパネル（モバイル） */
    #side-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 300px;
        max-width: 85vw;
        height: 100vh;
        max-height: none;
        border-right: 1px solid var(--border-color);
        border-top: none;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1002;
    }

    #side-panel.open {
        transform: translateX(0);
    }

    #side-panel::before {
        display: none;
    }

    #side-panel .panel-header {
        padding-top: 12px;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }

    .panel-header-content {
        flex: 1;
    }

    .panel-close-btn {
        background: none;
        border: none;
        padding: 4px;
        cursor: pointer;
        color: rgba(255, 255, 255, 0.8);
        display: block;
    }

    .panel-close-btn:hover {
        color: white;
    }

    .panel-close-btn svg {
        width: 24px;
        height: 24px;
    }

    #map-container {
        flex: 1;
        height: 100vh;
        min-height: auto;
    }

    /* ズームコントロールをパネルトグルボタンと重ならないように下に移動 */
    .leaflet-top.leaflet-left {
        top: 60px;
    }

    .map-controls {
        right: 10px;
        bottom: 100px;
    }

    /* 現在地情報（モバイル） */
    .map-location-info {
        bottom: 40px;
        left: 8px;
        right: 8px;
        padding: 8px 10px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }

    .location-info-content {
        flex-direction: column;
        gap: 2px;
        font-size: 11px;
    }

    .coords-toggle-btn {
        width: 32px;
        height: 32px;
    }

    .coords-toggle-btn svg {
        width: 18px;
        height: 18px;
    }

    .point-list {
        max-height: 200px;
    }

    .section-body {
        padding: 10px 12px;
    }

    #drop-zone {
        padding: 16px 12px;
    }

    #drop-zone svg {
        width: 24px;
        height: 24px;
    }
}

/* PC表示時はトグルボタンを非表示 */
@media (min-width: 769px) {
    .panel-toggle-btn {
        display: none;
    }

    .panel-overlay {
        display: none;
    }

    .panel-close-btn {
        display: none;
    }
}

/* タッチデバイス向け */
@media (hover: none) {
    .layer-btn {
        width: 36px;
        height: 36px;
    }

    .point-item {
        padding: 14px 12px;
    }
}

/* カスタム現在地マーカー */
.current-location-marker {
    width: 32px;
    height: 32px;
    position: relative;
    transition: transform 0.3s ease;
}

.current-location-arrow {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.current-location-arrow svg {
    width: 100%;
    height: 100%;
}

.current-location-dot {
    width: 24px;
    height: 24px;
    background-color: #4285f4;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.location-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background-color: rgba(66, 133, 244, 0.3);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* トースト通知 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background-color: #1e293b;
    color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background-color: var(--primary-color);
}

.toast.error {
    background-color: var(--danger-color);
}

.toast.warning {
    background-color: var(--warning-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ポイントマーカースタイル */
.point-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 点名ラベル（常時表示） */
.point-label {
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 500;
    color: #1e293b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
}

.point-label::before {
    display: none;
}
