/**
 * Give Directions 管理画面用スタイル
 *
 * 目次:
 * 1. リスト画面
 * 2. 編集画面 - 基本レイアウト
 * 3. 編集画面 - タイトル・タブナビゲーション
 * 4. 編集画面 - フォームコンポーネント
 * 5. 編集画面 - ロケーションセクション
 * 6. 編集画面 - 画像管理
 * 7. 編集画面 - ボタンスタイル
 * 8. ライブラリカスタマイズ
 * 9. アニメーション
 * 10. レスポンシブ対応
 */

/* ===========================================
   1. リスト画面
   =========================================== */

/* 検索フォーム */
.gd-search-form {
    margin-top: 20px;
}

.gd-search-form .search-box {
    float: right;
    margin: 0 0 10px;
}

.gd-search-form .search-box input[type="search"] {
    width: 280px;
    margin-right: 5px;
}

/* テーブル列幅の調整 */
.wp-list-table .column-cb {
    width: 2.2em;
}

.wp-list-table .column-title {
    width: 25%;
}

.wp-list-table .column-image {
    width: 60px;
    text-align: center;
}

.wp-list-table .column-shortcode {
    width: 30%;
}

.wp-list-table .column-author {
    width: 15%;
}

.wp-list-table .column-date {
    width: 18%;
}

/* ショートコード列のスタイル */
.wp-list-table .column-shortcode code {
    display: inline-block;
    padding: 3px 8px;
    background: #f0f0f1;
    border-radius: 3px;
    font-size: 12px;
    color: #2c3338;
    word-break: break-all;
}

/* 画像列のサムネイル */
.wp-list-table .column-image .gd-list-thumbnail {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    overflow: hidden;
    background: #f0f0f1;
    border: 1px solid #dcdcde;
    margin: 0 auto;
}

.wp-list-table .column-image .gd-list-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 行アクション */
.wp-list-table .row-actions {
    color: #646970;
}

/* ===========================================
   2. 編集画面 - 基本レイアウト
   =========================================== */

.gd-edit-wrap {
    position: relative;
}

/* ヘッダーエリア */
.gd-header-area {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dcdcde;
}

.gd-header-area .wp-heading-inline {
    margin: 0;
}

.gd-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* メッセージエリア */
#gd-message-area {
    position: fixed;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    max-width: 600px;
    width: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#gd-message-area.show {
    opacity: 1;
    visibility: visible;
}

#gd-message-area .notice {
    margin: 0;
}

.gd-save-status {
    display: inline-block;
    padding: 12px 20px;
    border-radius: 4px;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.3s ease-out;
}

.gd-save-status.success {
    background: #d5f4e6;
    color: #00a32a;
    border: 1px solid #00a32a;
}

.gd-save-status.error {
    background: #f8d7da;
    color: #d63638;
    border: 1px solid #d63638;
}

/* メインコンテナ */
.gd-edit-container {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

/* 左側: フォームエリア */
.gd-form-area {
    flex: 0 0 40%;
    min-width: 400px;
}

.gd-form-scroll {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding-right: 10px;
}

/* 右側: 地図エリア */
.gd-map-area {
    flex: 1;
    min-height: calc(100vh - 200px);
    position: sticky;
    top: 32px;
}

#gd-map-preview {
    width: 100%;
    height: 100%;
    min-height: 600px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    background: #f0f0f1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #646970;
}

/* ===========================================
   3. 編集画面 - タイトル・タブナビゲーション
   =========================================== */

/* タイトルセクション */
.gd-title-section {
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
}

.gd-post-title-input {
    width: 100%;
    font-size: 16px;
    padding: 8px 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    line-height: 1.4;
}

.gd-post-title-input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: 2px solid transparent;
}

.gd-label-required {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 13px;
}

.gd-title-section .description {
    margin-top: 5px;
    margin-bottom: 0;
    color: #646970;
    font-size: 12px;
}

/* タブナビゲーション */
.gd-tabs-navigation {
    display: flex;
    gap: 0;
    margin-bottom: 15px;
    border-bottom: 2px solid #dcdcde;
}

.gd-tab-button {
    flex: 1;
    padding: 10px 20px;
    background: #f0f0f1;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 600;
    color: #646970;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    margin-bottom: -2px;
}

.gd-tab-button:hover {
    background: #f6f7f7;
    color: #2c3338;
}

.gd-tab-button.active {
    background: #fff;
    color: #2271b1;
    border-bottom-color: #2271b1;
}

.gd-tab-button:focus {
    outline: none;
    box-shadow: none;
}

/* タブコンテンツ */
.gd-tab-content {
    display: none;
}

.gd-tab-content.active {
    display: block;
}

/* ===========================================
   4. 編集画面 - フォームコンポーネント
   =========================================== */

/* フィールドグループ */
.gd-field-group {
    margin-bottom: 10px;
    transition: margin-bottom 0.3s ease;
}

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

/* 詳細が閉じているときはマージンを削除 */
.gd-field-group:has(+ .gd-details-content:not(.open)) {
    margin-bottom: 0;
}

.gd-field-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #1d2327;
    font-size: 13px;
}

.gd-field-group input[type="text"],
.gd-field-group input[type="number"],
.gd-field-group textarea,
.gd-field-group select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    line-height: 1.4;
}

.gd-field-group input[type="text"]:focus,
.gd-field-group input[type="number"]:focus,
.gd-field-group textarea:focus,
.gd-field-group select:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

.gd-field-group textarea {
    resize: vertical;
    font-family: inherit;
}

.gd-field-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.gd-field-row .gd-field-group {
    flex: 1;
    min-width: 200px;
}

/* 地図検索フィールド */
.gd-search-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.gd-search-wrapper .gd-location-search {
    flex: 1;
    min-width: 0;
}

.gd-search-wrapper .gd-search-button {
    flex-shrink: 0;
    white-space: nowrap;
}

.gd-search-results {
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 5px;
}

.gd-search-result-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f1;
    transition: background-color 0.2s;
}

.gd-search-result-item:last-child {
    border-bottom: none;
}

.gd-search-result-item:hover {
    background-color: #f6f7f7;
}

.gd-search-result-item .result-name {
    font-weight: 500;
    color: #1d2327;
    margin-bottom: 3px;
}

.gd-search-result-item .result-address {
    font-size: 12px;
    color: #646970;
}

.gd-search-no-results,
.gd-search-loading {
    padding: 15px;
    text-align: center;
    color: #646970;
    font-size: 13px;
}

/* ===========================================
   5. 編集画面 - ロケーションセクション
   =========================================== */

.gd-location-section {
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    padding: 15px 15px 10px 15px;
    margin-bottom: 10px;
}
.gd-tab-content>.gd-location-section:last-child {
    margin-bottom: 0;
}

.gd-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.gd-section-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: #1d2327;
    flex: 0 0 auto;
}

/* 経由地の「道案内に表示しない」チェックボックス */
.gd-hidden-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #646970;
    margin: 0;
    cursor: pointer;
    flex: 0 0 auto;
}

.gd-hidden-checkbox-label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.gd-section-header .gd-remove-waypoint {
    margin-left: auto;
}

/* 詳細トグル */
.gd-toggle-details {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    color: #2271b1;
    text-decoration: none;
    margin-top: 5px;
    cursor: pointer;
}

.gd-toggle-details:hover {
    color: #135e96;
}

.gd-toggle-details:focus {
    box-shadow: none;
    outline: none;
}

.gd-toggle-details .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
    transition: transform 0.3s ease;
}

.gd-toggle-details.active .dashicons {
    transform: rotate(180deg);
}

.gd-details-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    opacity: 0;
    margin-top: 0;
}

.gd-details-content.open {
    max-height: 2000px;
    opacity: 1;
    margin-top: 10px;
}

/* ===========================================
   6. 編集画面 - 画像管理
   =========================================== */

.gd-images-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    min-height: 35px;
}

.gd-image-item {
    position: relative;
    width: 70px;
    height: 70px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    overflow: hidden;
    background: #f0f0f1;
}

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

.gd-remove-image {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.gd-remove-image:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* ===========================================
   7. 編集画面 - ボタンスタイル
   =========================================== */

/* 追加ボタン */
.gd-add-waypoint,
.gd-add-spot {
    width: 100%;
    margin-bottom: 8px;
    padding: 6px 12px;
    height: auto;
}
.gd-add-waypoint + .description,
.gd-add-spot + .description {
    margin-bottom: 10px;
}

/* 削除ボタン */
.gd-remove-waypoint,
.gd-remove-spot,
.button-link-delete {
    color: #b32d2e;
    text-decoration: none;
}

.gd-remove-waypoint:hover,
.gd-remove-spot:hover,
.button-link-delete:hover {
    color: #d63638;
    border-color: #b32d2e;
}

/* ===========================================
   8. ライブラリカスタマイズ
   =========================================== */

/* Leaflet Routing Machine - 指示パネルを非表示 */
.leaflet-routing-container {
    display: none;
}

/* カスタムマーカー */
.custom-marker,
.current-location-marker {
    background: transparent;
    border: none;
}

/* ポップアップのスタイル */
.gd-popup-content h4 {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: bold;
    word-wrap: break-word;
}

.gd-popup-content p {
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
    word-wrap: break-word;
}

/* Google Maps用のポップアップスタイル */
.gm-style .gd-popup-content {
    max-width: 300px;
    max-height: 300px;
    overflow-y: auto;
}

.gm-style .gd-popup-content h4 {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: bold;
    word-wrap: break-word;
}

.gm-style .gd-popup-content p {
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
    word-wrap: break-word;
}

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

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* タブレット - 1024px以下 */
@media screen and (max-width: 1024px) {
    .gd-edit-container {
        flex-direction: column;
    }

    .gd-form-area {
        flex: 1;
        min-width: auto;
    }

    .gd-map-area {
        position: relative;
        top: auto;
        min-height: 500px;
    }

    #gd-map-preview {
        min-height: 500px;
    }
}

/* モバイル - 782px以下 */
@media screen and (max-width: 782px) {
    /* リスト画面 */
    .gd-search-form .search-box {
        float: none;
        width: 100%;
    }

    .gd-search-form .search-box input[type="search"] {
        width: calc(100% - 90px);
    }

    .wp-list-table .column-shortcode code {
        font-size: 11px;
        padding: 2px 6px;
    }
    
    /* サムネイルをモバイルでも適切に表示 */
    .wp-list-table .column-image .gd-list-thumbnail {
        width: 40px;
        height: 40px;
    }

    /* 編集画面 */
    .gd-header-area {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .gd-header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .gd-form-scroll {
        max-height: none;
    }
}

/* 小型モバイル - 600px以下 */
@media screen and (max-width: 600px) {
    .gd-location-section {
        padding: 15px;
    }

    .gd-image-item {
        width: 60px;
        height: 60px;
    }

    .gd-header-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .gd-header-actions .button {
        width: 100%;
    }
}

/* ===========================================
   11. 設定ページ
   =========================================== */

.gd-settings-wrap .form-table {
    max-width: 800px;
}

.gd-settings-wrap .form-table th {
    padding: 20px 10px 20px 0;
    width: 200px;
}

.gd-settings-wrap .form-table td {
    padding: 20px 10px;
}

.gd-settings-wrap .form-table .title {
    padding: 15px 0;
    font-size: 1.1em;
}

/* カラーピッカーのスタイル */
.gd-marker-colors-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 15px;
}

.gd-color-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.gd-color-label {
    font-size: 13px;
    font-weight: 500;
    color: #1d2327;
    margin: 0;
}

.gd-color-picker {
    width: 30px;
    height: 30px;
    border: 2px solid #ffffff!important;
    border-radius: 50%!important;
    cursor: pointer;
    background: none;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.gd-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: 50%;
    overflow: hidden;
}

.gd-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
}

.gd-color-picker:hover {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.gd-color-picker:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}

.gd-reset-all-colors {
    margin-top: 10px;
}

/* 地図サービス選択 */
.gd-settings-wrap fieldset label {
    display: block;
    margin-bottom: 10px;
}

.gd-settings-wrap fieldset input[type="radio"] {
    margin-right: 8px;
}

/* Google Maps APIキー入力 */
.gd-google-maps-api-key-row input[type="text"] {
    width: 100%;
    max-width: 500px;
}

/* レスポンシブ対応 */
@media screen and (max-width: 782px) {
    .gd-settings-wrap .form-table th,
    .gd-settings-wrap .form-table td {
        display: block;
        width: 100%;
        padding: 10px 0;
    }
    
    .gd-settings-wrap .form-table th {
        border-bottom: none;
        padding-bottom: 5px;
    }
    
    .gd-settings-wrap .form-table td {
        padding-top: 5px;
    }
}
