/**
 * サイドバー・モーダル専用CSS
 * PC用サイドバー・SP用モーダルのスタイル定義
 * 
 * @package YaneMediaTheme
 */

/* ==================================================
   地域検索ウィジェット共通スタイル（BEM記法）
   ================================================== */

.area-search {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.area-search__container {
    padding: 16px;
    background: rgba(249, 249, 249, 0.6);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.area-search__title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 16px 0;
    text-align: center;
}

.area-search__form {
    width: 100%;
}

.area-search__field {
    margin-bottom: 16px;
}

.area-search__label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    margin-bottom: 8px;
}

.area-search__select {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #333;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    cursor: pointer;
}

.area-search__select:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.area-search__select:hover {
    border-color: #bbb;
}

.area-search__select--prefecture {
    background-color: #fff;
}

.area-search__actions {
    text-align: center;
    margin-top: 20px;
}

.area-search__button {
    width: 100%;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    color: #fff;
    background: #4A90E2;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.area-search__button:hover:not(:disabled) {
    background: #357ABD;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.area-search__button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(74, 144, 226, 0.2);
}

.area-search__button:disabled,
.area-search__button--disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.area-search__loading {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
}

.area-search__loading::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4A90E2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    vertical-align: middle;
}

.area-search__error {
    padding: 12px 16px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 6px;
    margin-top: 16px;
}

.area-search__error .error-message {
    color: #c33;
    font-size: 14px;
    margin: 0;
}

.area-search-fallback {
    padding: 20px;
    text-align: center;
    background: #f0f0f0;
    border-radius: 8px;
    color: #666;
}

.area-search-fallback h4 {
    margin: 0 0 10px 0;
    color: #555;
}

.area-search-fallback p {
    margin: 0;
    font-size: 14px;
}

/* ==================================================
   PC用サイドバー
   ================================================== */

.pc-sidebar {
    position: fixed;
    top: 0;
    right: 0; /* 初期状態から表示 */
    width: 320px;
    height: 100vh;
    background: #fff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 9998;
    overflow-y: auto;
    padding: 20px 0;
    border-left: 3px solid #4A90E2;
}

.pc-sidebar--open {
    right: 0;
}

.pc-sidebar--closed {
    right: -350px;
}

.pc-sidebar__content {
    padding: 0 20px;
}

.pc-sidebar-toggle {
    position: fixed;
    top: 50%;
    right: 20px;
    width: 44px;
    height: 44px;
    background: #4A90E2;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
    transition: all 0.2s ease;
    z-index: 9999;
    transform: translateY(-50%);
    display: none; /* サイドバー固定表示のためトグルボタンを非表示 */
    align-items: center;
    justify-content: center;
}

.pc-sidebar-toggle:hover {
    background: #357ABD;
    transform: translateY(-50%) scale(1.05);
}

.pc-sidebar-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

/* サイドバー内コンテンツ */
.search-section {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.search-section h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

.view-all-link {
    display: inline-block;
    padding: 10px 20px;
    background: #28a745;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.view-all-link:hover {
    background: #218838;
    text-decoration: none;
    color: #fff;
}

/* ==================================================
   SP用モーダル
   ================================================== */

.sp-search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sp-search-modal.sp-modal--open {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
}

.sp-search-modal-content {
    background: #fff;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    position: relative;
    padding: 30px 20px 20px 20px;
}

.sp-modal--open .sp-search-modal-content {
    transform: scale(1);
}

.sp-search-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.sp-search-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* SP用追従ボタン */
.sp-search-button {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #4A90E2;
    color: #fff;
    border: none;
    padding: 16px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
    transition: background-color 0.3s ease, transform 0.2s ease;
    z-index: 1500;
    white-space: nowrap;
}

.sp-search-button:hover {
    background: #357ABD;
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.5);
}

.sp-search-button:active {
    transform: translateX(-50%) translateY(0);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
}

/* ==================================================
   レスポンシブ対応
   ================================================== */

/* タブレット・PC (768px以上) */
@media (min-width: 768px) {
    .sp-search-modal {
        display: none !important;
    }
    
    .sp-search-button {
        display: none;
    }
    
    .pc-sidebar {
        display: block;
    }
    
    .pc-sidebar-toggle {
        display: none !important; /* サイドバー固定表示のためトグルボタンを非表示 */
    }
}

/* スマートフォン (767px以下) */
@media (max-width: 767px) {
    .pc-sidebar {
        display: none !important;
    }
    
    .pc-sidebar-toggle {
        display: none;
    }
    
    .sp-search-button {
        display: block;
    }
    
    .sp-search-modal {
        display: none; /* JavaScript で制御 */
    }
    
    /* モーダル内の地域検索ウィジェット調整 */
    .sp-search-modal .area-search__container {
        background: transparent;
        box-shadow: none;
        padding: 0;
    }
    
    .sp-search-modal .area-search__title {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .sp-search-modal .area-search__select {
        font-size: 16px;
        padding: 14px 16px;
    }
    
    .sp-search-modal .area-search__button {
        font-size: 18px;
        padding: 16px 24px;
    }
}

/* 極小画面 (480px以下) */
@media (max-width: 480px) {
    .sp-search-modal-content {
        width: 95%;
        padding: 25px 15px 15px 15px;
    }
    
    .sp-search-button {
        font-size: 14px;
        padding: 14px 20px;
        border-radius: 20px;
    }
    
    .area-search__container {
        padding: 15px;
    }
    
    .area-search__title {
        font-size: 16px;
    }
    
    .area-search__select {
        font-size: 16px;
        padding: 12px 14px;
    }
    
    .area-search__button {
        font-size: 16px;
        padding: 14px 20px;
    }
}

/* ==================================================
   アニメーション
   ================================================== */

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

/* フェードイン */
@keyframes fadeIn {
    from { 
        opacity: 0;
        transform: translateY(10px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.area-search__container {
    animation: fadeIn 0.5s ease;
}

/* ボタンの押下効果 */
.area-search__button:focus,
.view-all-link:focus,
.sp-search-button:focus,
.pc-sidebar-toggle:focus {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

/* ==================================================
   ダークモード対応（将来の拡張）
   ================================================== */

@media (prefers-color-scheme: dark) {
    .area-search__container {
        background: #2d2d2d;
        color: #f0f0f0;
    }
    
    .area-search__title {
        color: #f0f0f0;
    }
    
    .area-search__label {
        color: #ccc;
    }
    
    .area-search__select {
        background: #3d3d3d;
        color: #f0f0f0;
        border-color: #555;
    }
    
    .pc-sidebar {
        background: #1e1e1e;
    }
    
    .sp-search-modal-content {
        background: #1e1e1e;
        color: #f0f0f0;
    }
    
    .search-section {
        background: #2d2d2d;
    }
}