﻿/* ==========================================
   style.css - グローバルスタイル
   ========================================== */

/* アニメーション */
@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* スクロールバーカスタマイズ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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

/* テーブルスタイル */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.data-table th {
    background-color: #34495e;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #ddd;
}

.data-table tr:hover {
    background-color: #f9f9f9;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* カード */
.card {
    background-color: white;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.card-body {
    font-size: 14px;
    color: #555;
}

/* グリッド */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* ダッシュボード 2ペインレイアウト */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.dashboard-sidebar {
    grid-column: 1;
    grid-row: 1;
    overflow-y: auto;
    padding: 20px;
    padding-right: 10px;
}

.dashboard-map {
    grid-column: 1;
    grid-row: 2;
    display: none;
}

/* デスクトップ用 2ペインレイアウト */
@media (min-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 1fr 450px;
        grid-template-rows: 1;
        gap: 0;
        overflow: hidden;
    }
    
    .dashboard-sidebar {
        grid-column: 1;
        grid-row: 1;
        overflow-y: auto;
        padding: 20px;
        border-right: 1px solid #ddd;
        height: 100%;
    }
    
    .dashboard-sidebar::-webkit-scrollbar {
        width: 6px;
    }
    
    .dashboard-sidebar::-webkit-scrollbar-thumb {
        background: #bbb;
        border-radius: 3px;
    }
    
    .dashboard-map {
        grid-column: 2;
        grid-row: 1;
        height: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    
    .dashboard-map .card {
        margin-bottom: 0;
        border-radius: 0;
        box-shadow: none;
        border-left: 1px solid #ddd;
        height: 100%;
        padding: 0;
    }
    
    .dashboard-map .card-header {
        background: white;
        z-index: 10;
        padding: 15px 20px;
        border-bottom: 2px solid #3498db;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .dashboard-map #mapContainer {
        flex: 1;
        border-radius: 0;
    }
}

/* バッジ */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary {
    background-color: #3498db;
    color: white;
}

.badge-success {
    background-color: #27ae60;
    color: white;
}

.badge-warning {
    background-color: #f39c12;
    color: white;
}

.badge-danger {
    background-color: #e74c3c;
    color: white;
}

/* アラート */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    border-left: 4px solid;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #0c5460;
    color: #0c5460;
}

.alert-success {
    background-color: #d4edda;
    border-color: #155724;
    color: #155724;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #856404;
    color: #856404;
}

.alert-danger {
    background-color: #f8d7da;
    border-color: #721c24;
    color: #721c24;
}

/* ローディング */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .page-container {
        height: auto;
    }
    
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
    
    .navbar-nav {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .navbar-nav a {
        padding: 5px 8px;
        font-size: 12px;
    }
    
    .grid {
        grid-template-columns: 1fr;
    }
}

/* ダークモード対応（今後） */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }

    .card,
    .data-table {
        background-color: #2a2a2a;
        color: #e0e0e0;
    }

    .sidebar {
        background-color: #2a2a2a;
        border-right-color: #444;
    }
}

/* ==========================================
   折りたたみUI - サイドバー
   ========================================== */

/* サイドバー折りたたみコンテナ */
.collapsible-sidebar-container {
    position: relative;
    display: flex;
    height: 100%;
}

/* サイドバー本体 */
.collapsible-sidebar {
    width: 300px;
    min-width: 300px;
    transition: width 0.3s ease, min-width 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
    background: white;
    border-right: 1px solid #ddd;
}

.collapsible-sidebar.collapsed {
    width: 0;
    min-width: 0;
    opacity: 0;
    border-right: none;
}

.collapsible-sidebar-content {
    width: 300px;
    padding: 20px;
    overflow-y: auto;
    height: 100%;
    box-sizing: border-box;
}

/* サイドバートグルボタン */
.sidebar-toggle-btn {
    position: absolute;
    left: 300px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background: white;
    border: 1px solid #ddd;
    border-left: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #666;
    z-index: 1001;
    transition: left 0.3s ease, background-color 0.2s;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}

.sidebar-toggle-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.collapsible-sidebar.collapsed + .sidebar-toggle-btn,
.collapsible-sidebar-container.collapsed .sidebar-toggle-btn {
    left: 0;
}

/* ==========================================
   折りたたみUI - 凡例（最小化バー方式）
   ========================================== */

/* 凡例コンテナ */
.collapsible-legend {
    position: absolute;
    bottom: 50px;
    right: 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid #ccc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: all 0.2s ease;
    overflow: hidden;
}

/* 凡例展開時 */
.collapsible-legend.expanded {
    padding: 8px 10px;
    min-width: 90px;
    max-width: 140px;
}

/* 凡例最小化時 */
.collapsible-legend.minimized {
    width: 28px;
    padding: 8px 4px;
    cursor: pointer;
}

.collapsible-legend.minimized:hover {
    background: #f5f5f5;
}

/* 凡例ヘッダー */
.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 11px;
    color: #333;
}

.legend-minimize-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: #f0f0f0;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #666;
    transition: background-color 0.2s;
}

.legend-minimize-btn:hover {
    background: #ddd;
    color: #333;
}

/* 凡例コンテンツ */
.legend-content {
    font-size: 12px;
}

.collapsible-legend.minimized .legend-header,
.collapsible-legend.minimized .legend-content {
    display: none;
}

/* 最小化バー（縦書きラベル） */
.legend-minimized-bar {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 11px;
    color: #666;
    white-space: nowrap;
    display: none;
}

.collapsible-legend.minimized .legend-minimized-bar {
    display: block;
}

/* 凡例アイテム */
.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 5px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

.legend-label {
    font-size: 10px;
    color: #555;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================
   折りたたみUI - レスポンシブ対応
   ========================================== */

@media (max-width: 1023px) {
    /* モバイルではサイドバートグル非表示（元々サイドバーが隠れる） */
    .sidebar-toggle-btn {
        display: none;
    }

    .collapsible-sidebar {
        width: 100% !important;
        min-width: 100% !important;
    }

    .collapsible-sidebar-content {
        width: 100%;
    }

    /* 凡例は右下に小さく */
    .collapsible-legend {
        bottom: 80px;
        right: 10px;
    }
}
