/**
 * ツアー検索フォーム  - 新UI CSS
 * 2026/03/02 作成: モダンなUI、モーダル目的地選択、レスポンシブグリッドレイアウト対応
 */

.tour-search-form-container {
    margin-left: auto;
    margin-right: auto;
    font-size: 15px;
}

/* 出発予定日のカレンダー入力フィールドのスタイリング */
.date-field-wrapper {
    position: relative !important;
}

.date-input-wrapper {
    position: relative !important;
    display: block !important;
    background-color: #fff!important;
}

div.wpforms-container-full .wpforms-form input[type="date"] {
    z-index: 10 !important;
    background: transparent !important;
}

.date-input-wrapper .calendar-icon {
    content: "" !important;
    position: absolute !important;
    right: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    /* pointer-events: none; */
    width: 18px !important;
    height: 18px !important;
    z-index: 0 !important;
    display: block !important;
}

input[type="date"].wpforms-field-large,
input[type="date"].date-input-placeholder {
    padding: 8px 12px; /* 通常のパディングに戻す */
    font-size: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    height: 38px;
    box-sizing: border-box;
    position: relative;
    width: 100%;
    line-height: 22px;
}

/* 値が空の時は入力テキストを完全に非表示（カレンダーアイコンは除く） */
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder {
    color: transparent !important;
}

/* 値が空の時もカレンダーアイコンは常に表示 */
/* .date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder::-webkit-calendar-picker-indicator {
    opacity: 1 !important;
    display: inline-block !important;
} */

/* 値がある時は通常のフォントサイズに戻す */
.date-input-wrapper.has-value input[type="date"].date-input-placeholder {
    font-size: 15px !important;
}

/* Firefox用のカレンダーボタン表示 */
/* input[type="date"].date-input-placeholder::-moz-calendar-picker-indicator {
    cursor: pointer;
    opacity: 1 !important;
    display: inline-block !important;
    pointer-events: auto !important;
    z-index: 0 !important;
} */

input[type="date"].wpforms-field-large:focus,
input[type="date"].date-input-placeholder:focus {
    border-color: #023e7d;
    outline: none;
    box-shadow: 0 0 5px rgba(2, 62, 125, 0.3);
}

/* デフォルトでは「年/月/日」の表示を完全に非表示（Windows対応強化） */
/* 値が空の時のスタイル */
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder::-webkit-datetime-edit {
    color: transparent !important;
    opacity: 0 !important;
    -webkit-text-fill-color: transparent !important;
    width: 0 !important;
    padding: 0 !important;
}

.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder::-webkit-datetime-edit-fields-wrapper {
    color: transparent !important;
    opacity: 0 !important;
    -webkit-text-fill-color: transparent !important;
    width: 0 !important;
    padding: 0 !important;
}

/* 「年」「月」「日」のテキストを非表示 */
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder::-webkit-datetime-edit-text {
    color: transparent !important;
    opacity: 0 !important;
    -webkit-text-fill-color: transparent !important;
    padding: 0 !important;
    -webkit-appearance: none;
    width: 0 !important;
}

/* 年月日のフィールドをデフォルトで非表示 */
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder::-webkit-datetime-edit-year-field,
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder::-webkit-datetime-edit-month-field,
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder::-webkit-datetime-edit-day-field {
    color: transparent !important;
    background-color: transparent !important;
    opacity: 0 !important;
    -webkit-text-fill-color: transparent !important;
    width: 0 !important;
    padding: 0 !important;
}

/* フォーカス時の水色ハイライトを消す */
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder:focus::-webkit-datetime-edit-year-field,
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder:focus::-webkit-datetime-edit-month-field,
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder:focus::-webkit-datetime-edit-day-field {
    background-color: transparent !important;
    color: transparent !important;
    opacity: 0 !important;
    -webkit-text-fill-color: transparent !important;
    width: 0 !important;
}

/* 選択状態のハイライトを消す */
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder::-webkit-datetime-edit-year-field::selection,
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder::-webkit-datetime-edit-month-field::selection,
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder::-webkit-datetime-edit-day-field::selection {
    background-color: transparent !important;
}

/* Firefoxなど他のブラウザ対応 */
.date-input-wrapper:not(.has-value) input[type="date"].date-input-placeholder::-moz-text {
    opacity: 0 !important;
}

input[type="date"].date-input-placeholder:-moz-ui-invalid {
    box-shadow: none;
}

/* 値が入力されたら日付を表示 */
.date-input-wrapper.has-value input[type="date"].date-input-placeholder::-webkit-datetime-edit {
    color: #333 !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #333 !important;
    width: auto !important;
    padding: initial !important;
}

.date-input-wrapper.has-value input[type="date"].date-input-placeholder::-webkit-datetime-edit-fields-wrapper {
    color: #333 !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #333 !important;
    width: auto !important;
    padding: initial !important;
}

.date-input-wrapper.has-value input[type="date"].date-input-placeholder::-webkit-datetime-edit-year-field,
.date-input-wrapper.has-value input[type="date"].date-input-placeholder::-webkit-datetime-edit-month-field,
.date-input-wrapper.has-value input[type="date"].date-input-placeholder::-webkit-datetime-edit-day-field {
    color: #333 !important;
    background-color: transparent !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #333 !important;
    width: auto !important;
    padding: initial !important;
}

/* 値がある時もフォーカス時の水色ハイライトを消す */
.date-input-wrapper.has-value input[type="date"].date-input-placeholder:focus::-webkit-datetime-edit-year-field,
.date-input-wrapper.has-value input[type="date"].date-input-placeholder:focus::-webkit-datetime-edit-month-field,
.date-input-wrapper.has-value input[type="date"].date-input-placeholder:focus::-webkit-datetime-edit-day-field {
    background-color: transparent !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #333 !important;
}

.date-input-wrapper.has-value input[type="date"].date-input-placeholder::-webkit-datetime-edit-text {
    color: #333 !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #333 !important;
    padding: initial !important;
    width: auto !important;
}

.date-input-wrapper.has-value input[type="date"].date-input-placeholder::-moz-text {
    opacity: 1 !important;
}

/* プレースホルダーの色を統一 */
.tour-search-form-container .wpforms-field-large::placeholder,
.tour-search-form-container .destination-selector::placeholder {
    color: #757575 !important;
    opacity: 1;
}

.tour-search-form-container select.wpforms-field-large {
    color: #757575 !important;
}

.tour-search-form-container select.wpforms-field-large:not([value=""]):valid {
    color: #333 !important;
}

.tour-search-form-container select.wpforms-field-large option {
    color: #333;
}

.tour-search-form-container select.wpforms-field-large option[disabled] {
    color: #757575 !important;
}

/* Selectの矢印アイコン */
.tour-search-form-container select.wpforms-field-large {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px !important;
    padding-right: 36px !important;
    cursor: pointer !important;
}

.tour-search-form-container select.wpforms-field-large::-ms-expand {
    display: none !important;
}

/* チェックボックスグループ（コンパクト） */
.tour-search-form-container .checkbox-group-compact {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 4px;
    list-style: none !important;
    padding-left: 0 !important;
}

.tour-search-form-container .checkbox-group-compact label {
    font-size: 13px !important;
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    background: #fff !important;
    padding: 5px 8px !important;
    border-radius: 4px;
    border: 1px solid #cbd5e0 !important;
    transition: all 0.2s;
    margin: 0 !important;
    font-weight: normal !important;
}

.tour-search-form-container .checkbox-group-compact label:hover {
    background: #edf2f7 !important;
    border-color: #1e88e5 !important;
}

.tour-search-form-container .checkbox-group-compact input[type="checkbox"] {
    margin: 0 !important;
    cursor: pointer;
    width: 14px;
    height: 14px;
}

/* 目的地選択フィールドのスタイル */
.destination-selector {
    cursor: pointer;
    background-color: #fff;
    position: relative;
}

.destination-selector::after {
    content: "▼";
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* 目的地選択モーダル */
.destination-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.destination-modal.show {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 0;
}

.destination-modal-content {
    background-color: #fff;
    margin: 20px auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.destination-modal-header {
    background-color: #f5f5f5;
    color: #333;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
}

.destination-modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.destination-modal-header h2::before {
    content: "🔍";
    font-size: 20px;
}

.destination-modal-close {
    color: #666;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.destination-modal-close:hover {
    color: #333;
}

.destination-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.destination-accordion {
    list-style: none;
    margin: 0;
    padding: 0;
}

.accordion-area {
    border-bottom: 1px solid #e0e0e0;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    background-color: #fff;
    transition: background-color 0.3s;
    user-select: none;
}

.accordion-header:hover {
    background-color: #f9f9f9;
}

.accordion-header-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

.accordion-toggle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #1e88e5;
    color: white;
    border-radius: 50%;
    font-size: 18px;
    transition: transform 0.3s;
}

.accordion-area.active .accordion-toggle {
    transform: rotate(45deg);
}

.accordion-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-out;
    background-color: #fafafa;
}

.accordion-area.active .accordion-content {
    grid-template-rows: 1fr;
}

.accordion-inner {
    overflow: hidden;
}

.country-group {
    border-bottom: 1px solid #e8e8e8;
}

.country-group:last-child {
    border-bottom: none;
}

.country-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px 12px 40px;
    cursor: pointer;
    background-color: #fafafa;
    transition: background-color 0.3s;
    gap: 10px;
}

.country-header.is-title {
    cursor: pointer;
    background-color: #fafafa;
    font-weight: 500;
    padding-left: 80px;
}

.country-header.is-title:hover {
    background-color: #f0f0f0;
}

.country-header.is-selectable {
    padding-left: 40px;
    flex-direction: row;
}

.country-header.is-selectable .destination-checkbox {
    order: -1;
    margin-right: 10px;
}

.country-header.is-selectable .country-name {
    order: 0;
}

.country-header:hover {
    background-color: #f0f0f0;
}

.country-name {
    font-size: 15px;
    color: #333;
    flex: 1;
}

.destination-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid #999;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-color: #fff;
    transition: all 0.2s;
}

.destination-checkbox.checked {
    background-color: #1e88e5;
    border-color: #1e88e5;
}

.destination-checkbox.checked::after {
    content: "✓";
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.country-toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e88e5;
    font-size: 22px;
    font-weight: bold;
    transition: transform 0.3s;
}

.country-group.active .country-toggle {
    transform: rotate(90deg);
}

.city-list {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-out;
    background-color: #fff;
}

.country-group.active .city-list {
    grid-template-rows: 1fr;
}

.city-list-inner {
    overflow: hidden;
}

.city-item {
    padding: 10px 20px 10px 60px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}

.city-item .destination-checkbox {
    order: -1;
}

.city-item .city-item-text {
    order: 0;
}

/* 都市名のインデント（国全ての次の項目） */
.city-item:not(:first-child) {
    padding-left: 80px;
}

.city-item:hover {
    background-color: #e3f2fd;
    border-left-color: #1e88e5;
    color: #1e88e5;
}

.city-item-text {
    flex: 1;
}

.destination-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #fff;
    display: flex;
    justify-content: center;
}

.destination-submit-btn {
    background-color: #d32f2f;
    color: white;
    border: none;
    padding: 12px 60px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.destination-submit-btn:hover {
    background-color: #c62828;
}

.destination-submit-btn:active {
    background-color: #b71c1c;
}

.tour-search-form-container div.wpforms-container-full .wpforms-form .wpforms-field {
    padding-top: 0 !important;
    padding-bottom: 18px !important;
}

.tour-search-form-container .wpforms-field label,
.tour-search-form-container .placeholder {
    color: #666 !important;
}

.tour-search-form-container div.wpforms-container-full .wpforms-form .wpforms-field-label {
    font-size: 15px !important;
}

div.wpforms-container-full .wpforms-form .wpforms-submit-container {
    padding-top: 28px;
}

/* =============================================
   カスタム日付ピッカー ポップアップ
   ============================================= */
.custom-date-picker-popup {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    width: 280px;
    font-size: 14px;
    user-select: none;
}

.cdp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}

.cdp-prev,
.cdp-next {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #555;
    padding: 0 6px;
}
.cdp-prev:hover,
.cdp-next:hover {
    color: #023e7d;
}

.cdp-month-year {
    font-weight: bold;
    font-size: 15px;
    color: #333;
}

.cdp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    padding: 6px 8px 2px;
    font-size: 12px;
    font-weight: bold;
    color: #666;
}
.cdp-weekdays .cdp-sun { color: #d32f2f; }
.cdp-weekdays .cdp-sat { color: #1565c0; }

.cdp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 4px 8px 8px;
}

.cdp-day {
    text-align: center;
    padding: 6px 0;
    border-radius: 50%;
    cursor: pointer;
    color: #333;
    font-size: 13px;
    transition: background-color 0.15s;
}
.cdp-day:nth-child(7n+1) { color: #d32f2f; }  /* 日曜 */
.cdp-day:nth-child(7n)   { color: #1565c0; }  /* 土曜 */

.cdp-day--empty {
    cursor: default;
}

.cdp-day--disabled {
    color: #ccc !important;
    cursor: not-allowed;
}

.cdp-day--today {
    border: 1px solid #023e7d;
}

.cdp-day--selected {
    background-color: #023e7d;
    color: #fff !important;
}

.cdp-day:not(.cdp-day--empty):not(.cdp-day--disabled):not(.cdp-day--selected):hover {
    background-color: #e3f0ff;
}

.cdp-footer {
    padding: 8px 12px;
    border-top: 1px solid #eee;
    text-align: right;
}

.cdp-clear {
    background: none;
    border: 1px solid #999;
    border-radius: 4px;
    padding: 4px 14px;
    font-size: 13px;
    cursor: pointer;
    color: #555;
}
.cdp-clear:hover {
    background-color: #f5f5f5;
    border-color: #666;
}

/* text型入力のスタイル（date型CSSと同等） */
input[type="text"].date-input-placeholder {
    cursor: pointer;
}

/* === PC表示：4列グリッドレイアウト === */
@media (min-width: 1025px) {
    .tour-search-form-container .wpforms-field-container {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
        align-items: start;
    }
    
    /* 旅行日数は最後の行で全幅表示 */
    .tour-search-form-container .wpforms-field-container .tour-duration-field {
        grid-column: 1 / -1;
    }
    
    /* フィールドのpadding-bottomを0に（grid gapで対応するため） */
    .tour-search-form-container .wpforms-field-container > .wpforms-field {
        padding-bottom: 0 !important;
    }
    
    /* Submit containerも全幅 */
    .tour-search-form-container .wpforms-submit-container {
        grid-column: 1 / -1;
        margin-top: 8px;
    }
}

/* === タブレット表示：3列グリッドレイアウト === */
@media (min-width: 769px) and (max-width: 1024px) {
    .tour-search-form-container .wpforms-field-container {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        align-items: start;
    }
    
    /* 旅行日数は最後の行で全幅表示 */
    .tour-search-form-container .wpforms-field-container .tour-duration-field {
        grid-column: 1 / -1;
    }
    
    /* フィールドのpadding-bottomを0に（grid gapで対応するため） */
    .tour-search-form-container .wpforms-field-container > .wpforms-field {
        padding-bottom: 0 !important;
    }
    
    /* Submit containerも全幅 */
    .tour-search-form-container .wpforms-submit-container {
        grid-column: 1 / -1;
        margin-top: 8px;
    }
}

/* === モバイル表示：モーダルとチェックボックスの調整 === */
@media (max-width: 768px) {
    .destination-modal-content {
        width: 95%;
        max-width: none;
    }

    .accordion-header {
        padding: 14px 15px;
    }

    .accordion-header-title {
        font-size: 15px;
    }

    .country-header {
        padding: 10px 15px 10px 30px;
    }

    .city-item {
        padding: 10px 15px 10px 45px;
        font-size: 13px;
    }

    .tour-search-form-container .checkbox-group-compact {
        gap: 6px 4px;
    }

    .tour-search-form-container .checkbox-group-compact label {
        font-size: 12px !important;
    }
}
