/**
 * Interactive Map Plugin - フロントエンド用CSS
 * サイドバー・モバイルUI・進捗表示対応版
 */

/* ===================================
   CSS変数（テーマ対応）
   =================================== */
:root {
    --imp-primary: #4CAF50;
    --imp-primary-dark: #388E3C;
    --imp-bg: rgba(255, 255, 255, 0.95);
    --imp-bg-solid: #ffffff;
    --imp-text: #333333;
    --imp-text-secondary: #666666;
    --imp-border: #e0e0e0;
    --imp-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --imp-sidebar-width: 300px;
    --imp-mobile-bar-height: 60px;
    --imp-transition: all 0.3s ease;
    --imp-input-bg: #ffffff;
    --imp-hover-bg: #f5f5f5;
}

/* ===================================
   マップコンテナ基本スタイル
   =================================== */
.imp-map-container {
    position: relative;
    width: 100%;
    background: #f0f0f0;
    overflow: hidden;
}

.imp-map {
    width: 100%;
    height: 100%;
    position: relative;
}

/* ローディング表示 */
.imp-map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    z-index: 100;
}

.imp-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--imp-primary);
    border-radius: 50%;
    animation: imp-spin 1s linear infinite;
}

@keyframes imp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.imp-loading-text {
    margin-top: 15px;
    color: var(--imp-text-secondary);
    font-size: 14px;
}

/* エラー表示 */
.imp-map-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
}

.imp-error-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.imp-error-message {
    color: var(--imp-text-secondary);
    font-size: 16px;
}

/* ===================================
   マーカースタイル
   =================================== */
.imp-marker {
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    border: 3px solid white !important;
    cursor: pointer !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
    z-index: 100 !important;
    pointer-events: auto !important;
    transition: box-shadow 0.3s ease, filter 0.3s ease !important;
}

.imp-marker:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
    filter: brightness(1.1) !important;
    z-index: 1000 !important;
}

/* 進捗表示 - ハイブリッドスタイル */
.imp-marker.completed {
    opacity: 0.7 !important;
    border: 3px solid var(--imp-primary) !important;
}

.imp-marker.completed::after {
    content: '✓';
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 18px;
    height: 18px;
    background: var(--imp-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 101;
}

/* ===================================
   PCサイドバー
   =================================== */
.imp-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--imp-sidebar-width);
    background: var(--imp-bg);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.imp-sidebar.collapsed {
    transform: translateX(calc(-1 * var(--imp-sidebar-width)));
}

.imp-sidebar-toggle {
    position: absolute;
    right: -40px;
    top: 20px;
    width: 40px;
    height: 40px;
    background: var(--imp-bg-solid);
    border: 1px solid var(--imp-border);
    border-radius: 0 4px 4px 0;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--imp-transition);
    color: var(--imp-text);
}

.imp-sidebar-toggle:hover {
    background: var(--imp-primary);
    color: white;
}

.toggle-icon {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    position: relative;
}

.toggle-icon::before,
.toggle-icon::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: currentColor;
}

.toggle-icon::before {
    top: -6px;
}

.toggle-icon::after {
    top: 6px;
}

.imp-sidebar-content {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
}

/* マップセレクター */
.imp-map-selector {
    margin-bottom: 20px;
}

.imp-map-dropdown {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--imp-border);
    border-radius: 4px;
    background: var(--imp-input-bg);
    color: var(--imp-text);
    font-size: 16px;
    cursor: pointer;
}

.imp-map-dropdown option {
    background: var(--imp-bg-solid);
    color: var(--imp-text);
}

/* 検索ボックス */
.imp-search {
    margin-bottom: 20px;
}

.imp-search input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--imp-border);
    border-radius: 4px;
    font-size: 14px;
    background: var(--imp-input-bg);
    color: var(--imp-text);
}

.imp-search input::placeholder {
    color: var(--imp-text-secondary);
}

.imp-search input:focus {
    outline: none;
    border-color: var(--imp-primary);
}

/* 進捗統計 */
.imp-progress-stats {
    background: var(--imp-hover-bg);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid var(--imp-border);
}

.progress-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    margin-bottom: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--imp-primary);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 14px;
    color: var(--imp-text);
    font-weight: 500;
}

/* フィルターセクション */
.imp-filters {
    margin-top: 20px;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.filter-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--imp-text);
}

.filter-actions {
    display: flex;
    gap: 5px;
}

.filter-actions button {
    padding: 5px 10px;
    border: 1px solid var(--imp-border);
    background: white;
    color: var(--imp-text);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--imp-transition);
}

.filter-actions button:hover {
    background: var(--imp-primary);
    color: white;
    border-color: var(--imp-primary);
}

.filter-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.filter-item:hover {
    background: var(--imp-hover-bg);
}

.filter-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
    width: 100%;
}

.filter-checkbox {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.filter-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.filter-icon.custom-icon {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.filter-name {
    flex-grow: 1;
    font-size: 14px;
}

.filter-count {
    font-size: 12px;
    color: var(--imp-text-secondary);
    margin-left: auto;
}

/* ===================================
   モバイルUI
   =================================== */
.imp-mobile-bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--imp-mobile-bar-height);
    background: var(--imp-bg);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
}

.imp-mobile-action-button {
    padding: 8px 16px;
    border: 1px solid var(--imp-border);
    background: white;
    color: var(--imp-text);
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--imp-transition);
}

.imp-mobile-action-button:hover {
    background: var(--imp-primary);
    color: white;
    border-color: var(--imp-primary);
}

.imp-mobile-menu {
    position: absolute;
    bottom: var(--imp-mobile-bar-height);
    left: 0;
    right: 0;
    max-height: 70vh;
    background: var(--imp-bg);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 999;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.imp-mobile-menu.active {
    transform: translateY(0);
}

.imp-mobile-menu-content {
    padding: 20px;
}

/* ===================================
   ポップアップ（固定位置）
   =================================== */
.imp-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    pointer-events: auto;
}

.imp-fixed-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    margin: 0 !important;
}

.imp-popup-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    min-height: 0;
}

.imp-popup-scrollable {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 20px;
    margin: 10px 0;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    flex-basis: auto;
}

.imp-popup-scrollable::-webkit-scrollbar {
    width: 8px;
}

.imp-popup-scrollable::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.imp-popup-scrollable::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.imp-popup-scrollable::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.imp-popup-name {
    font-size: 18px;
    font-weight: bold;
    padding: 20px 20px 10px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.imp-popup-todo {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 20px;
    align-items: center;
    flex-shrink: 0;
    min-height: 60px;
}

.imp-popup-detail-link {
    padding: 0 20px 15px;
    flex-shrink: 0;
}

.imp-popup-items {
    margin: 15px 0;
}

.imp-items-label {
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
    font-size: 14px;
}

.imp-items-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.imp-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 8px;
    transition: all 0.2s;
}

.imp-item-row:hover {
    background: #f0f0f0;
    transform: translateX(2px);
}

.imp-item-image {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid #ddd;
    transition: all 0.2s;
}

.imp-item-image:hover {
    border-color: #0073aa;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.2);
}

.imp-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.imp-item-info {
    flex: 1;
}

.imp-item-title {
    font-size: 15px;
    color: #333;
    font-weight: 500;
}

.imp-lightbox-hint {
    font-size: 11px;
    color: #999;
    margin-top: 10px;
    text-align: center;
    font-style: italic;
}

.imp-popup-image-wrapper {
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
}

.imp-popup-thumb-img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.2s;
}

.imp-popup-thumb-img:hover {
    transform: scale(1.02);
}

.imp-lightbox-trigger {
    cursor: pointer;
}

.imp-popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.imp-popup-close:hover {
    background: #e0e0e0;
    transform: rotate(90deg);
}

/* 備考セクション */
.imp-popup-note-section {
    margin: 15px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    border-left: 4px solid var(--imp-primary);
}

.imp-note-label {
    font-weight: bold;
    color: #333;
    margin: 0 0 8px 0;
    font-size: 14px;
}

.imp-note-text {
    margin: 0;
    color: #555;
    line-height: 1.6;
    font-size: 14px;
    white-space: pre-wrap;
}

.imp-note-with-image {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.imp-note-image-wrapper {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid #ddd;
    transition: all 0.2s;
}

.imp-note-image-wrapper:hover {
    border-color: var(--imp-primary);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.2);
}

.imp-note-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.imp-note-text-wrapper {
    flex: 1;
    min-width: 0;
}

/* ===================================
   ライトボックス
   =================================== */
.imp-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    opacity: 0;
    transition: opacity 0.3s;
    overflow: hidden;
}

.imp-lightbox.active {
    opacity: 1;
}

.imp-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.imp-lightbox-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.imp-lightbox-content img {
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.imp-lightbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.imp-lightbox-close:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

/* ===================================
   モバイル専用調整
   =================================== */
@media (max-width: 768px) {
    .imp-sidebar {
        display: none;
    }
    
    .imp-mobile-bottom-bar {
        display: flex;
    }
    
    .imp-mobile-menu {
        display: block;
    }
    
    .imp-fixed-popup {
        width: 85%;
        max-width: 380px;
        max-height: 60vh;
        height: auto;
    }
    
    .imp-popup-name {
        font-size: 16px;
        padding: 15px 15px 10px;
    }
    
    .imp-popup-scrollable {
        padding: 0 15px;
        max-height: 35vh;
    }
    
    .imp-popup-todo {
        padding: 12px 15px;
        gap: 15px;
        font-size: 14px;
        min-height: 50px;
    }
    
    .imp-popup-todo label {
        white-space: nowrap;
    }
    
    .imp-popup-detail-link {
        padding: 0 15px 12px;
    }
    
    .imp-popup-detail-link a {
        font-size: 14px;
    }
    
    .imp-note-with-image {
        flex-direction: column;
    }
    
    .imp-note-image-wrapper {
        width: 100%;
        height: 150px;
    }
    
    .imp-lightbox-content {
        max-width: 98vw;
        max-height: 98vh;
        padding: 0;
    }
    
    .imp-lightbox-content img {
        max-width: 98vw;
        max-height: 98vh;
    }
    
    .imp-lightbox-close {
        top: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
        font-size: 28px;
    }
    
    .imp-main-filters {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding: 0;
        -webkit-overflow-scrolling: touch;
    }
    
    .filter-icon-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        border: 2px solid #ddd;
        background: white;
        cursor: pointer;
        transition: all 0.2s;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .filter-icon-btn.active {
        border-color: var(--imp-primary);
        box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
    }
    
    .imp-expand-filters {
        width: 44px;
        height: 44px;
        background: white;
        border: 1px solid var(--imp-border);
        border-radius: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
    }
    
    .imp-expand-filters.expanded {
        background: var(--imp-primary);
        color: white;
    }
    
    .imp-mobile-expanded {
        position: absolute;
        bottom: 100%;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid var(--imp-border);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .imp-mobile-expanded.show {
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .imp-mobile-expanded-content {
        padding: 15px;
    }
    
    .mobile-filter-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
    }
    
    .mobile-filter-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 12px;
        border: 2px solid transparent;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .mobile-filter-item.active {
        background: var(--imp-hover-bg);
        border-color: var(--imp-primary);
    }
    
    .mobile-filter-icon {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        border: 2px solid white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    
    .mobile-filter-label {
        font-size: 12px;
        text-align: center;
        color: var(--imp-text);
    }
}

@media (max-width: 480px) {
    .imp-fixed-popup {
        width: 90%;
        max-width: 320px;
        max-height: 55vh;
    }
    
    .imp-popup-scrollable {
        max-height: 30vh;
    }
    
    .imp-popup-name {
        font-size: 15px;
    }
    
    .imp-popup-todo {
        font-size: 13px;
        padding: 10px 12px;
    }
}

@media (min-width: 769px) {
    .imp-mobile-bottom-bar,
    .imp-mobile-menu {
        display: none;
    }
}

@media (orientation: landscape) and (max-width: 768px) {
    .imp-lightbox-content img {
        max-height: 90vh;
    }
}

/* ===================================
   全画面機能
   =================================== */
.imp-fullscreen-btn {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    background: white;
    border: 1px solid var(--imp-border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 1000;
}

.imp-fullscreen-btn:hover {
    background: var(--imp-primary);
    color: white;
    transform: scale(1.1);
}

.imp-map-container.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    margin: 0 !important;
}

.imp-map-container.fullscreen .imp-fullscreen-btn {
    background: rgba(255, 255, 255, 0.9);
}

.imp-fullscreen-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 100001;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.imp-fullscreen-toast.show {
    opacity: 1;
}