/* Booking System Specific Styles */

/* グローバルリセット */
*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --booking-bg: #f9f9fa;
  --card-bg: #ffffff;
  --border-color: #e5e7eb;
}

body.bg-gray {
  background-color: var(--booking-bg);
}

/* ===== Header ===== */
.booking-header {
  background: white;
  border-bottom: 1px solid var(--border-color);
  padding: 15px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.booking-header__inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  overflow: hidden; /* ★ 子要素がはみ出さないようにする */
}

.booking-header__inner > a:first-child {
  flex-shrink: 0;
}

.booking-header__secure {
  font-size: 0.9rem;
  color: var(--color-primary);
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0; /* ★ flex子要素として縮小を許可 */
}

/* ===== Main Container ===== */
.booking-main {
  max-width: 1100px;
  margin: 30px auto;
  padding: 0 20px;
}

/* ===== Progress Steps ===== */
.booking-progress {
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
  background: white;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.02);
  overflow: hidden; /* ★ */
}

.step {
  color: #64748b;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0; /* ★ flex子要素として縮小を許可 */
  overflow: hidden; /* ★ */
}

.step > span {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  color: #334155;
  border-radius: 50%;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.step.active {
  color: var(--color-primary);
}
.step.active > span {
  background: var(--color-primary);
  color: white;
}

.step.completed {
  color: var(--color-primary);
}

/* ===== Layout ===== */
.booking-layout {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 320px);
  gap: 24px;
  align-items: start;
  overflow: hidden;
}

@media (max-width: 768px) {
  .booking-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .booking-flow,
  .booking-sidebar {
    min-width: 0;
  }
}

/* ===== Step Content ===== */
.step-title {
  font-size: 1.2rem;
  margin-bottom: 15px;
  color: var(--color-text);
}

.step-card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  margin-bottom: 20px;
  overflow: hidden; /* ★ */
}

.step-card.no-padding {
  padding: 0;
}

.step-desc.padding-msg {
  padding: 15px 24px;
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  margin: 0;
  border-radius: 12px 12px 0 0;
}

/* ===== Forms ===== */
.form-row {
  display: flex;
  gap: 15px;
}

.form-group {
  margin-bottom: 20px;
}
.form-group.half {
  flex: 1;
  min-width: 0; /* ★ flex子要素として縮小を許可 */
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.required {
  background: #ef4444;
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 5px;
}

.form-input {
  width: 100%;
  max-width: 100%; /* ★ selectなどの幅超過を防ぐ */
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(46,154,59,0.1);
}

.form-input:disabled {
  background: #f3f4f6;
  color: #6b7280;
}

.form-note {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 5px;
}

/* ===== Vehicle List (Radio Cards) ===== */
.vehicle-list {
  padding: 20px;
}

.vehicle-item {
  display: block;
  margin-bottom: 15px;
  cursor: pointer;
}

.vehicle-item input[type="radio"] {
  display: none;
}

.vehicle-card-ui {
  display: flex;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  transition: all 0.2s;
  align-items: center;
  gap: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(46,154,59,0.15);
}
.vehicle-card-ui:active {
  border-color: var(--color-primary);
  background: rgba(46,154,59,0.06);
}

.vehicle-item input[type="radio"]:checked + .vehicle-card-ui {
  border-color: var(--color-primary);
  background: rgba(46,154,59,0.03);
}

.vehicle-img {
  width: 120px;
  min-width: 120px;
  height: 80px;
  overflow: hidden;
  border-radius: 4px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.vehicle-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.vehicle-info {
  flex: 1;
  min-width: 0;
}
.vehicle-info h4 {
  margin: 0 0 5px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.95rem;
}
.vehicle-info p {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin: 0;
  line-height: 1.4;
}

.vehicle-price {
  text-align: right;
  min-width: 100px;
}
.price-val {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--color-accent);
}
.price-unit {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.select-btn {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  background: #f3f4f6;
  color: #4b5563;
  margin-top: 8px;
}
.vehicle-item input[type="radio"]:checked + .vehicle-card-ui .select-btn {
  background: var(--color-primary);
  color: white;
}
.vehicle-item input[type="radio"]:checked + .vehicle-card-ui .select-btn::after {
  content: " ✓";
}

@media (max-width: 600px) {
  .vehicle-card-ui {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .vehicle-img {
    width: 100%;
    min-width: 100%;
    height: auto;
    aspect-ratio: 4 / 3; /* 写真の上下が切れないよう4:3で表示 */
    border-radius: 6px;
  }
  .vehicle-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .vehicle-info h4 {
    white-space: normal;
  }
  .vehicle-price {
    text-align: left;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 0;
  }
  .vehicle-price .price-val  { order: 1; }
  .vehicle-price .price-unit { order: 2; white-space: nowrap; margin-left: 4px; }
  .vehicle-price .select-btn { order: 3; margin: 0 0 0 auto; white-space: nowrap; padding: 8px 16px; }
  .vehicle-price > div:not(.select-btn) { order: 4; flex-basis: 100%; margin-top: 0 !important; }
  /* 車両カードの左右余白を詰めて、カード幅を広く使う（スマホ） */
  #vehicle-list-dynamic.vehicle-list { padding: 12px 0; }
  #vehicle-items-list { padding-left: 0 !important; padding-right: 0 !important; }
}

/* ===== Insurance Radios ===== */
.insurance-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.insurance-item {
  cursor: pointer;
}
.insurance-item input {
  display: none;
}
.ins-content {
  border: 1px solid var(--border-color);
  padding: 15px;
  border-radius: 6px;
  position: relative;
  transition: all 0.2s;
}
.insurance-item input[type="radio"]:checked + .ins-content {
  border-color: var(--color-accent);
  background: rgba(255,152,0,0.05);
}
.ins-content h4 {
  margin: 0 0 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}
.ins-content .price {
  color: var(--color-accent);
  font-weight: bold;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 10px;
}
.ins-content p {
  font-size: 0.85rem;
  margin: 0;
  color: var(--color-text-secondary);
}
.badge {
  position: absolute;
  top: -10px;
  right: 15px;
  background: var(--color-accent);
  color: white;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: bold;
}

/* ===== Green License Control ===== */
.highlight-box {
  background: #fdfdea;
  border: 1px solid #fef08a;
}
.box-title {
  color: #b45309;
  font-size: 1rem;
  margin-bottom: 10px;
}
.box-text {
  font-size: 0.9rem;
  margin-bottom: 15px;
}
.license-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: white;
  white-space: normal;
  text-align: center;
  justify-content: center;
}
.radio-label span {
  font-size: 0.9rem;
  font-weight: 600;
}
.alert-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 15px;
  margin-top: 15px;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ===== Options ===== */
.option-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.option-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--border-color);
}
.opt-desc h4 {
  margin: 0 0 5px;
}
.opt-desc p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}
.opt-desc .price {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-accent);
  margin-top: 5px;
  display: block;
}
.opt-control {
  display: flex;
  align-items: center;
}
.qty-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  background: white;
  border-radius: 4px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qty-input {
  width: 40px;
  height: 32px;
  text-align: center;
  border: none;
  font-weight: bold;
  -moz-appearance: textfield;
  appearance: textfield;
}

.step-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

/* ===== Cart Sidebar (Right) ===== */
.cart-summary {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  overflow: hidden;
  word-break: break-word;
}
.cart-summary.sticky {
  position: sticky;
  top: 20px;
}
.cart-summary h3 {
  font-size: 1.1rem;
  margin-bottom: 20px;
  text-align: center;
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 10px;
}

.cart-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 15px;
  font-size: 0.95rem;
}
.cart-row span {
  color: #4b5563;
  flex: 1;
  padding-right: 15px;
  min-width: 5em;
  word-break: keep-all;
}
.cart-row strong {
  text-align: right;
  word-break: break-word;
}
.cart-details hr {
  border: 0;
  border-top: 1px dashed var(--border-color);
  margin: 20px 0;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}
.cart-total span {
  font-weight: 600;
}
.total-price {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-accent);
  white-space: nowrap;
}

.secure-note {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  text-align: center;
  margin-top: 20px;
}

/* ===== Custom DateTime Picker ===== */
.datetime-picker {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dt-date {
  flex: 3;
  min-width: 0; /* ★ 135px → 0 に変更して縮小を許可 */
  padding: 12px 6px;
  font-size: 0.95rem;
}
.dt-hour {
  flex: 1;
  min-width: 0; /* ★ 55px → 0 に変更して縮小を許可 */
  padding: 12px 4px;
  text-align: center;
  font-size: 0.95rem;
}
.dt-min {
  width: 55px;
  padding: 12px 4px;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}
.dt-sep {
  font-size: 1rem;
  font-weight: bold;
  color: #4b5563;
  margin: 0 -2px;
}

/* Disable Insurance when green license */
.insurance-item.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ============================================================
   Responsive Mobile Tweaks (max-width: 600px)
   ============================================================ */
@media (max-width: 600px) {
  /* Progress Steps */
  .booking-progress {
    padding: 12px 5px;
    gap: 5px;
  }
  .step {
    flex-direction: column;
    text-align: center;
    gap: 4px;
    font-size: 0.7rem;
    flex: 1;
  }
  .step > span {
    font-size: 0.8rem;
  }
  .step div span.lang-en {
    font-size: 0.65em !important;
    display: block;
    line-height: 1.2;
  }

  /* Form Layout */
  .form-row {
    flex-direction: column;
    gap: 15px;
  }

  /* Step Actions */
  .step-actions {
    flex-direction: column-reverse;
    gap: 15px;
    padding: 15px 0 0 0;
  }
  .step-actions button {
    width: 100%;
  }

  /* DateTime Picker */
  .datetime-picker {
    flex-wrap: wrap;
  }
  .dt-date {
    flex: 1 1 100%;
    margin-bottom: 5px;
  }
  .dt-hour, .dt-min {
    flex: 1;
  }
  .dt-sep {
    padding: 0 5px;
  }

  /* Step 3: Options / Insurance */
  .license-toggle {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .radio-label {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .option-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .opt-control {
    align-self: flex-end;
    margin-top: 10px;
  }
}

/* ============================================================
   Multilingual (EN) Display Logic
   ★ 英語テキスト表示時のはみ出し防止を根本的に対処
   ============================================================ */
.lang-en {
  display: none;
  font-size: 0.85em;
  color: #64748b;
  margin-top: 2px;
  font-weight: 400;
}
.btn--primary .lang-en {
  color: rgba(255, 255, 255, 0.85);
}

/* EN有効化時: .lang-en要素を表示する */
body.lang-en-active .lang-en {
  display: block;
  word-break: break-word;
  overflow-wrap: break-word;
}
body.lang-en-active span.lang-en {
  display: inline;
}
body.lang-en-active .lang-en.block-lang {
  display: block;
}
body.lang-en-active .lang-en.inline-lang {
  display: inline;
  margin-left: 4px;
  margin-top: 0;
}

/* ★ EN有効化時: ボタンの折り返しを許可 */
body.lang-en-active .btn {
  white-space: normal;
  line-height: 1.4;
  height: auto;
}

/* ★ EN有効化時: ヘッダーの「安全な予約システム」を非表示にして幅超過を防ぐ */
body.lang-en-active .booking-header__secure {
  display: none;
}

/* ★ EN有効化時: 進捗バーの英語サブテキストを非表示にして崩壊を防ぐ */
body.lang-en-active .booking-progress .step div span.lang-en {
  display: none !important;
}

/* ============================================================
   Header Toggle Button Styles
   ============================================================ */
.booking-lang-toggle {
  display: flex;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  margin-left: auto;
  margin-right: 15px;
  flex-shrink: 0; /* ★ トグルボタンが縮小しないようにする */
}
.booking-lang-toggle button {
  border: none;
  background: transparent;
  color: #64748b;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}
.booking-lang-toggle button.active {
  background: white;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
