/* Override generic main-content style for this page */
main#broadcast-wizard {
    display: block; /* 共通の.main-content(flex)を上書きし、縦並びにする */
    padding: 1.5rem; /* ページ全体の余白を調整 */
    gap: 0; /* 共通スタイルのgapをリセット */
    overflow-y: auto; /* コンテンツが長い場合にスクロールできるようにする */
}

/* Wizard Stepper */
.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}
.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #9ca3af; /* gray-400 */
    transition: color 0.3s;
}
.step.active {
    color: #3b82f6; /* blue-500 */
    font-weight: 600;
}
.step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #e5e7eb; /* gray-200 */
    color: #6b7280; /* gray-500 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 0.5rem;
    border: 2px solid transparent;
    transition: all 0.3s;
}
.step.active .step-icon {
    background-color: #dbeafe; /* blue-100 */
    color: #3b82f6; /* blue-500 */
    border-color: #3b82f6;
}
.step-label {
    font-size: 0.875rem;
}
.step-connector {
    flex-grow: 1;
    height: 2px;
    background-color: #e5e7eb; /* gray-200 */
    margin: 0 1rem;
    transform: translateY(-1rem);
}

/* Wizard Steps */
.wizard-step {
    display: none;
}
.wizard-step.active {
    display: block;
}
.step-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}
/* 各ステップのカードの最大幅を設定し、レスポンシブ対応を改善 */
.wizard-step .card {
    width: 50%;
    max-width: 960px; /* コンテンツの最大幅を設定 */
    margin: 0; /* 中央揃えを解除し、左寄せにする */
}

/* Step 1: Targeting */
.radio-button-group {
    display: flex;
    gap: 1rem;
}

.radio-button-label {
    flex: 1;
    position: relative;
}

.radio-button-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-button-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    background-color: #f9fafb;
}

.radio-button-label input[type="radio"]:hover + .radio-button-content {
    border-color: #93c5fd; /* blue-300 */
    background-color: #f7faff;
}

.radio-button-label input[type="radio"]:checked + .radio-button-content {
    border-color: #3b82f6; /* blue-500 */
    background-color: #eff6ff; /* blue-50 */
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.radio-button-icon {
    font-size: 1.75rem;
    color: #3b82f6;
    margin-bottom: 0.75rem;
}
#filter-conditions {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background-color: #f9fafb;
    border-radius: 0.5rem;
}
.date-range-inputs, .number-range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.target-preview-area {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.target-preview-area p {
    font-weight: 500;
}

/* Step 2: Compose - Redesigned */
.compose-container {
    display: block;
}

/* エディタ全体のコンテナ */
.compose-editor { /* 構文エラーを修正: 重複したセレクタを統合 */
    position: relative; /* For emoji picker positioning */
    display: flex;
    flex-direction: column;
    height: 100%;
}

.compose-editor .form-group {
    flex-grow: 1; /* Allow form group to take available space */
    display: flex;
    flex-direction: column;
}

/* --- Message Block Container --- */
#message-blocks-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.message-input-wrapper {
    flex-grow: 1; /* Allow wrapper to grow */
    display: flex; /* To make textarea height 100% work */
    position: relative;
}

.message-block .form-textarea.message-input {
    flex-grow: 1; /* Take all available vertical space */
    min-height: 200px;
    background-color: #f0f0f0;
    border: 1px solid #e5e7eb;
    resize: vertical;
}

.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
}

.message-block {
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background-color: #ffffff;
}
.message-block-header {
    padding: 0.5rem 1rem;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    color: #4b5563;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    display: flex;
    align-items: center;
}
.message-block-header span:not(.drag-handle) {
    flex-grow: 1;
}
.drag-handle {
    cursor: grab;
    color: #9ca3af;
    margin-right: 0.75rem;
    padding: 0 0.25rem;
}
.remove-block-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    margin-left: auto; /* 右端に寄せる */
}
.remove-block-btn:hover {
    color: #374151;
}

.message-block-content {
    padding: 1rem;
}
.message-block-content .form-group {
    margin-bottom: 0; /* Reset margin inside block */
}
.message-block-content .editor-toolbar {
    border: none;
    padding: 0.5rem 0 0 0;
}

.add-content-container {
    position: relative;
    text-align: center;
    padding: 0.5rem;
    border: 2px dashed #d1d5db;
    border-radius: 0.5rem;
}

.add-content-menu {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    z-index: 20;
}
.add-content-menu-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    border-radius: 0.25rem;
}
.add-content-menu-item:hover {
    background-color: #f3f4f6;
}
.add-content-menu-item i {
    margin-right: 0.5rem;
    color: #6b7280;
}
/* ★追加: 予約促進アイコンの色 */
.add-content-menu-item i.fa-calendar-check {
    color: #16a34a; /* green-600 */
}

.image-upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    background-color: #f9fafb;
}
.image-upload-placeholder i { font-size: 2rem; color: #9ca3af; margin-bottom: 0.5rem; }
.image-upload-placeholder p { font-weight: 600; color: #4b5563; margin: 0; }
.image-upload-note { font-size: 0.8rem; color: #6b7280; }

.image-preview-area { position: relative; }
.image-preview { max-width: 100%; border-radius: 0.5rem; }

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-section .btn i {
    margin-right: 0.25rem;
}

.char-counter {
    font-size: 0.875rem;
    color: #6b7280;
}

/* --- Emoji Picker --- */
emoji-picker {
    position: absolute;
    left: 0;
    bottom: 50px; /* Position above the toolbar */
    z-index: 10;
    --background: #f9fafb;
    --border-color: #e5e7eb;
}
emoji-picker.hidden {
    display: none;
}

/* --- Phone Preview --- */
.phone-preview-wrapper {
    /* position: sticky; を削除し、通常のブロック要素に戻す */
    position: static;
    top: auto;
    align-self: auto;
    /* ★追加: モーダル内で高さを最大にするため */
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.preview-controls {
    display: flex;
    justify-content: center;
}

.preview-toggle-buttons {
    display: inline-flex;
    background-color: #e5e7eb;
    border-radius: 0.375rem;
    padding: 0.25rem;
}

.preview-toggle-btn {
    padding: 0.375rem 1rem;
    border: none;
    background-color: transparent;
    color: #4b5563;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.preview-toggle-btn.active {
    background-color: white;
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* --- Talk List Preview --- */
.talk-list-preview-container {
    background-color: #ffffff;
    border-radius: 0.5rem;
    padding: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.talk-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.talk-list-icon { font-size: 2.5rem; color: #d1d5db; }
.talk-list-content { flex-grow: 1; min-width: 0; }
.talk-list-header { display: flex; justify-content: space-between; align-items: center; }
.talk-list-name { font-weight: 600; }
.talk-list-time { font-size: 0.75rem; color: #6b7280; }
.talk-list-message { font-size: 0.875rem; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }


.phone-frame {
    width: 320px;
    height: 600px; /* ★変更: 高さを最大にする */
    background-color: #111;
    border-radius: 36px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2), inset 0 0 0 2px #333;
    display: flex; /* ★追加: 中のphone-screenが100%になるように */
    flex-direction: column; /* ★追加 */
}

.phone-screen {
    background-color: #8cbde6; /* LINE chat background color */
    height: 100%;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    flex-grow: 1; /* ★追加: 親のflexコンテナ内で高さを最大にする */
}

.phone-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 16px;
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
}

.phone-status-bar .status-icons {
    display: flex;
    gap: 6px;
}

.line-chat-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.line-chat-header {
    background-color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    color: #111;
    flex-shrink: 0;
    margin-top: 28px; /* Space for status bar */
    border-bottom: 1px solid #f0f0f0;
}

.line-chat-header .account-name {
    flex-grow: 1;
    text-align: center;
}

.line-chat-header .header-icons {
    display: flex;
    gap: 16px;
}

.line-chat-body {
    flex-grow: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Push messages to the bottom */
    min-height: 0;
    overflow-y: auto; /* スクロールバーを必要に応じて表示 */
}

/* --- SortableJS Styles --- */
.message-block.sortable-ghost {
    opacity: 0.5;
    background: #dbeafe; /* blue-100 */
}
.message-block.sortable-chosen {
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transform: scale(1.01);
}

.line-preview-image {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}
.line-preview-image img {
    max-width: 200px;
    border-radius: 1rem;
}
/* プレビュー画面内のスクロールバーのデザインを調整 */
.line-chat-body::-webkit-scrollbar {
    width: 5px;
}
.line-chat-body::-webkit-scrollbar-track {
    background: transparent; /* スクロールバーの背景は透明に */
}
.line-chat-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3); /* スクロールバー自体の色 */
    border-radius: 3px;
}

.line-message-outgoing {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.line-message-bubble {
    background-color: #BDE99A; /* LINE's green bubble color */
    padding: 0.4rem 0.8rem; /* 上下のpaddingを小さく調整 */
    border-radius: 1rem;
    max-width: 80%;
    word-break: break-word;
    white-space: pre-wrap;
    position: relative;
    color: #111;
}

/* Bubble tail */
.line-message-bubble::after {
    content: '';
    position: absolute;
    top: 8px;
    right: -7px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: #BDE99A;
    border-right: 0;
    border-top: 0;
    margin-top: -4px;
    margin-right: -4px;
}

/* ★追加: 予約促進ブロックのスタイル */
.reservation-promo-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    background-color: #f0fdf4; /* green-50 */
    border: 1px solid #bbf7d0; /* green-200 */
    padding: 1rem;
    border-radius: 0.375rem;
}
.promo-icon {
    font-size: 1.75rem;
    color: #16a34a; /* green-600 */
}
.promo-text p {
    margin: 0;
}
.promo-text .promo-description {
    font-size: 0.875rem;
    color: #14532d; /* green-900 */
    margin-top: 0.25rem;
}

/* ★追加: プレビュー画面でのFlex Messageのスタイル */
.line-flex-message-preview {
    background-color: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
    max-width: 240px;
    margin: 0 auto 0.5rem auto; /* 中央寄せ */
    border: 1px solid #e0e0e0;
}
.line-flex-message-preview .flex-header { background-color: #2563EB; color: white; padding: 10px; font-weight: bold; }
.line-flex-message-preview .flex-body { background-color: white; padding: 10px; font-size: 0.9em; }
.line-flex-message-preview .flex-body p { margin: 0 0 8px 0; }
.line-flex-message-preview .flex-body p:last-child { margin-bottom: 0; }
.line-flex-message-preview .flex-footer { background-color: white; padding: 10px; border-top: 1px solid #eee; }
.line-flex-message-preview .flex-button { width: 100%; background-color: #2563EB; color: white; border: none; padding: 10px; border-radius: 5px; cursor: pointer; font-weight: bold; }


/* Step 3: Confirm */
.confirmation-summary {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.summary-item {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 1rem;
}
.summary-label {
    font-weight: 600;
    text-align: right;
    color: #374151;
}
.summary-value {
    color: #1f2937;
}

/* Step 3 Confirmation Preview Adjustment */
.confirmation-summary .summary-value .phone-preview-wrapper.confirm-preview {
    padding-top: 0;
    justify-content: flex-start;
}

.confirmation-summary .summary-value .phone-preview-wrapper.confirm-preview .phone-frame {
    transform: scale(0.8);
    transform-origin: top left;
    margin-bottom: -96px; /* Compensate for scaling (480px * (1 - 0.8) = 96px) */
}

/* Step 4: Complete */
.completion-box {
    text-align: center;
    padding: 3rem 1rem;
    background-color: #f9fafb;
    border-radius: 0.5rem;
    max-width: 600px;
    margin: 2rem auto;
}
.completion-icon {
    font-size: 4rem;
    color: #22c55e; /* green-500 */
    margin-bottom: 1rem;
}
.completion-box h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.completion-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* --- Customer Selection UI (Step 1) --- */
.customer-selection-wrapper {
  margin-top: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem;
  background-color: #f9fafb;
}

.customer-selection-container {
  display: flex;
  gap: 1rem;
  min-height: 400px;
}

.customer-selection-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.75rem;
}

.customer-selection-header {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
}

.search-box-small {
  margin-bottom: 0.75rem;
}

.customer-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex-grow: 1;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
}

.customer-list-item {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background-color 0.15s ease;
  font-size: 0.9rem;
}

.customer-list-item:hover {
  background-color: #eff6ff;
}

/* --- Modal Styles (reusable for customer search) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-content {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.modal-content.modal-lg {
    max-width: 800px;
}
.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-title { /* ★修正: modal-titleのスタイルを統一 */
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}
.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
}
.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* --- Undo Toast Notification --- */
.undo-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: #333; /* Dark background */
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 100;
    transform: translateY(150%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.4s ease-in-out, opacity 0.4s ease-in-out, visibility 0s 0.4s;
}
.undo-toast.show {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    transition: transform 0.4s ease-in-out, opacity 0.4s ease-in-out;
}
.undo-toast .btn { background-color: #555; border: 1px solid #777; color: white; }
.undo-toast .btn:hover { background-color: #666; }

/* --- Floating Preview Button --- */
.floating-preview-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background-color: #3b82f6; /* blue-500 */
    color: white;
    border-radius: 50%;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 900;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, opacity 0.3s, visibility 0.3s;
    font-size: 0.7rem; /* for the text */
    gap: 2px;
}
.floating-preview-btn.hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.5);
}
.floating-preview-btn i {
    font-size: 1.5rem;
}
.floating-preview-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* --- Preview Modal --- */
.preview-modal-overlay {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    background-color: transparent;
    z-index: 1050; /* Higher than other elements */
    pointer-events: none; /* 背景のクリックを透過させる */
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    /* 表示されている状態 */
    transform: translateX(0);
}

/* JSで付与される.hiddenクラスを上書きして、transformで非表示にする */
#preview-modal.hidden {
    display: block !important; /* style.cssのdisplay:noneを上書き */
    transform: translateX(100%);
    pointer-events: none;
}

.preview-modal-content {
    background-color: #f9fafb; /* Light gray background */
    border-radius: 0.75rem 0 0 0.75rem; /* 左側のみ角丸に */
    box-shadow: -5px 0 25px rgba(0,0,0,0.15); /* 左側に影を落とす */
    width: 380px; /* プレビューの幅を固定 */
    height: 100%;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto; /* パネル自体はクリックできるようにする */
}

.preview-modal-header {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
}
.preview-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}
.preview-modal-close-btn {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: #6b7280;
    cursor: pointer;
    line-height: 1;
}
.preview-modal-body {
    padding: 1.5rem;
    overflow-y: auto; /* Allow scrolling for the body if needed */
    /* ★追加: 中の要素の高さを最大にするため */
    display: flex;
    flex-direction: column;
}