/* style.css: 全ページ共通のベーススタイル */

:root {
  --color-primary: #5B7FEF;
  --color-primary-dark: #4863D6;
  --color-primary-light: #EEF1FE;
  --color-bg: #F3F1FC;
  --color-card: #FFFFFF;
  --color-text: #2D2A3D;
  --color-muted: #8B87A0;
  --color-border: #ECE9F7;
  --color-danger: #F16C6C;
  --color-success: #6FCF97;
  --color-star: #FBBF24;
  --radius: 20px;
  --shadow: 0 6px 20px rgba(93, 89, 158, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #F6F4FD 0%, #EFEDFB 100%);
  color: var(--color-text);
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }
.muted { color: var(--color-muted); }

/* ---- レイアウト ---- */
.app-container {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: transparent;
  padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  position: relative;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 22px 20px 6px;
  min-width: 0;
}

.top-bar h1 {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 19px;
  font-weight: 800;
  margin: 0;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-status {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  flex-shrink: 0;
  white-space: nowrap;
}
.auth-status .btn-text {
  flex-shrink: 0;
  padding: 4px 2px;
}

main {
  padding: 12px 16px 20px;
}

/* ---- 下部固定メインナビゲーション ---- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: min(100%, 430px);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -6px 20px rgba(93, 89, 158, 0.12);
  border-radius: 18px 18px 0 0;
}
.bottom-nav a {
  flex: 1 1 20%;
  min-width: 0;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 1px;
  border-radius: 12px;
  color: var(--color-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}
.bottom-nav a.active {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}
.bottom-nav .nav-icon { font-size: 19px; line-height: 1; }
.bottom-nav a,
.btn-primary,
.btn-secondary,
.btn-small { transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease; }
.bottom-nav a { flex-wrap: nowrap; }
.bottom-nav a .nav-icon,
.bottom-nav a:not(.nav-icon) { white-space: nowrap; }

/* ---- PC・タブレット向けレイアウト ---- */
@media (min-width: 768px) {
  .app-container {
    max-width: 1120px;
    padding-bottom: 112px;
  }

  .top-bar { padding: 28px 40px 12px; }
  .top-bar h1 { font-size: 24px; }
  main { padding: 24px 40px 36px; }

  .bottom-nav {
    width: min(760px, calc(100% - 48px));
    bottom: 18px;
    padding: 10px 14px;
    border: 1px solid rgba(236, 233, 247, 0.95);
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(93, 89, 158, 0.18);
  }

  .bottom-nav a {
    flex-direction: row;
    flex: 1 1 auto;
    min-height: 48px;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
  }

  .bottom-nav .nav-icon { font-size: 18px; }

  #tripList,
  #tripPickerList {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
  }

  .trip-card { margin-bottom: 0; }

  .card {
    padding: 24px;
    border: 1px solid rgba(236, 233, 247, 0.75);
  }
}

@media (min-width: 1200px) {
  .app-container { max-width: 1200px; }
  main { padding-right: 56px; padding-left: 56px; }
  .top-bar { padding-right: 56px; padding-left: 56px; }
}

/* ---- ボタン ---- */
button, .btn {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  font-size: 15px;
}
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  font-size: 16px;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(108, 141, 245, 0.45);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, #6C8DF5, #5470E8);
  color: #fff;
  padding: 15px;
  width: 100%;
  font-weight: 700;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(84, 112, 232, 0.28);
}
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }

.btn-secondary {
  background: #fff;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary-light);
  padding: 13px;
  width: 100%;
  font-weight: 700;
  border-radius: 999px;
}

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 999px;
}

.btn-danger { background: #FEF0F0; color: var(--color-danger); }
.btn-text { background: none; color: var(--color-primary); padding: 4px 8px; font-weight: 600; }
.btn-icon { background: none; color: var(--color-muted); font-size: 14px; padding: 4px 8px; border-radius: 8px; }

/* ---- カード ---- */
.card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

@media (hover: hover) {
  .card:hover { box-shadow: 0 9px 24px rgba(93, 89, 158, 0.11); }
  .bottom-nav a:hover { background: #F7F5FF; color: var(--color-primary-dark); }
  .btn-primary:hover, .btn-secondary:hover, .btn-small:hover { transform: translateY(-1px); }
}

/* ---- フォーム ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: 14px;
  font-size: 16px;
  background: #FBFAFF;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
.form-row { display: flex; gap: 10px; min-width: 0; }
.form-row .form-group { flex: 1 1 0; min-width: 0; }

.error-msg { color: var(--color-danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }

/* ---- 進捗バー ---- */
.progress-bar {
  background: var(--color-border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin: 8px 0 4px;
}
.progress-fill {
  background: linear-gradient(90deg, #7C9BFA, #5470E8);
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}
.progress-label { font-size: 12px; color: var(--color-muted); }

.badge {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
}

/* ---- 進捗ドーナツ（ホーム画面） ---- */
.progress-donut-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
}
.progress-donut { flex-shrink: 0; }
.progress-donut-track { fill: none; stroke: var(--color-border); stroke-width: 10; }
.progress-donut-fill {
  fill: none;
  stroke: url(#donutGradient);
  stroke-width: 10;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 0.4s ease;
}
.progress-donut-label {
  font-size: 20px;
  font-weight: 800;
  fill: var(--color-text);
}

/* ---- フィルタータブ ---- */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.filter-tab {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  border-radius: 999px;
  background: var(--color-primary-light);
  color: var(--color-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.filter-tab.active {
  background: var(--color-primary);
  color: #fff;
}

/* ---- スマートフォン向けレイアウト ---- */
@media (max-width: 600px) {
  .app-container { max-width: 100%; overflow-x: clip; }

  .top-bar {
    padding: 16px 16px 8px;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .top-bar h1 { font-size: 18px; }
  .auth-status { margin-left: auto; font-size: 12px; gap: 4px; }

  main { padding: 12px 14px 20px; }
  .card { min-width: 0; padding: 18px 16px; }

  /* 日付入力などの横並びフォームを縦並びにして重なりを防ぐ */
  .form-row { display: flex; flex-direction: column; gap: 0; }
  .form-row .form-group { width: 100%; min-width: 0; flex: 1 1 auto; }
  .form-group input,
  .form-group select,
  .form-group textarea { max-width: 100%; }


  /* iPhone Safariの日付入力が親要素より広がる問題を防ぐ */
  #newTripForm,
  #newTripForm .form-row,
  #newTripForm .form-group {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  #newTripForm .form-group input,
  #newTripForm .form-group input[type="date"] {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  #newTripForm .form-row .form-group + .form-group {
    margin-top: 12px;
  }

  .bottom-nav a { font-size: 10px; }
  .bottom-nav .nav-icon { font-size: 18px; }
}

@media (max-width: 380px) {
  .top-bar { padding: 14px 12px 6px; }
  .top-bar h1 { font-size: 16px; }
  main { padding: 10px 12px 16px; }
  .bottom-nav a { font-size: 9px; }
}

/* iPhoneの旅行情報フォーム：日付入力欄のはみ出し対策 */
@media (max-width: 600px) {
  #newTripForm {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  #newTripForm .form-row {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  #newTripForm .form-row .form-group {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  #newTripForm input[type="date"] {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
   #newTripForm input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 48px;
    padding: 0 8px;
    font-size: 16px;
    line-height: normal; 
    box-sizing: border-box;
    border: 1.5px solid var(--color-border);
    border-radius: 14px;
    background-color: #FBFAFF;
  }
}