/* ============================================================
   ADDIX Agent Hub フロント 共通スタイル
   旧 app-004-agent-hub-forms/Stylesheet.html を Vercel 版にそのまま移植 + 微調整。
   M3 (Material 3) outlined text-field / フローティングラベル / カラートークン。
============================================================ */

/* ============================================================
   M3 カラートークン
============================================================ */
:root {
  --md-bg:              #FFFFFF;
  --md-surface:         #F4F4F4;
  --md-on-surface:      #1C1B1F;
  --md-outline:         #E0E0E0;
  --md-outline-variant: #C4C4C4;
  --md-on-variant:      #6B6B6B;
  --md-error:           #B3261E;
  --md-error-bg:        #FFF5F5;
  --md-success:         #1E6B32;
  --md-success-bg:      #F0FFF4;
  --md-elevation-1:     0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.06);
  --md-elevation-2:     0 3px 6px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.06);
  --md-font:            'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --md-r-xs:            4px;
  --md-r-sm:            8px;
  --md-r-md:            16px;
  --md-r-full:          100px;
  --t:                  0.15s ease;
}

/* ============================================================
   リセット
============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--md-font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--md-on-surface);
  background: #F8F8F8;
  min-height: 100vh;
}

a { color: inherit; }

/* ============================================================
   ヘッダー
============================================================ */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--md-bg);
  border-bottom: 1px solid var(--md-outline);
}

.app-bar__logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-bar__logo-placeholder {
  font-size: 18px;
  font-weight: 700;
  color: var(--md-on-surface);
  letter-spacing: 0.05em;
}

.app-bar__title {
  font-size: 13px;
  font-weight: 400;
  color: var(--md-on-variant);
}

/* ============================================================
   メインレイアウト
============================================================ */
.main {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 16px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ============================================================
   ステッププログレス
============================================================ */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 16px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-outline-variant);
}

.step.is-active { color: var(--md-on-surface); font-weight: 700; }
.step.is-done { color: var(--md-success); }

.step__number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--md-outline-variant);
  background: var(--md-bg);
}

.step.is-active .step__number {
  border-color: var(--md-on-surface);
  background: var(--md-on-surface);
  color: var(--md-bg);
}

.step.is-done .step__number {
  border-color: var(--md-success);
  background: var(--md-success);
  color: var(--md-bg);
}

.step__connector {
  width: 40px;
  height: 2px;
  background: var(--md-outline);
  margin: 0 8px;
}

.step__connector.is-done { background: var(--md-success); }

/* ============================================================
   Surface（M3カード）
============================================================ */
.surface {
  background: var(--md-bg);
  border-radius: var(--md-r-md);
  box-shadow: var(--md-elevation-1);
  border: 1px solid var(--md-outline);
  padding: 24px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--md-on-surface);
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--md-outline);
}

.section-subtitle {
  font-size: 12px;
  font-weight: 400;
  color: var(--md-on-variant);
  margin-top: -20px;
  margin-bottom: 24px;
}

/* ============================================================
   フォーム
============================================================ */
.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: end;
}

@media (max-width: 600px) {
  .field-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   M3 Outlined Text Field
============================================================ */
.text-field {
  position: relative;
}

.text-field__input,
.text-field__select {
  width: 100%;
  padding: 16px 12px 8px 12px;
  border: 1px solid var(--md-outline);
  border-radius: var(--md-r-xs);
  font-size: 14px;
  font-family: var(--md-font);
  color: var(--md-on-surface);
  background: var(--md-bg);
  outline: none;
  transition: border var(--t);
  appearance: none;
  -webkit-appearance: none;
}

.text-field__input:focus,
.text-field__select:focus {
  border-width: 2px;
  border-color: var(--md-on-surface);
  padding: 16px 11px 8px 11px;
}

/* セレクトボックスの矢印アイコン */
.text-field__select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231C1B1F' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.text-field__select:focus { padding-right: 35px; }

/* フローティングラベル */
.text-field__label {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--md-on-variant);
  pointer-events: none;
  transition: top var(--t), font-size var(--t), color var(--t), transform var(--t);
  background: var(--md-bg);
  padding: 0 4px;
  line-height: 1;
  white-space: nowrap;
}

.text-field__input:focus + .text-field__label,
.text-field__input:not(:placeholder-shown) + .text-field__label {
  top: 0;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--md-on-surface);
}

.text-field--select .text-field__label {
  top: 0;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--md-on-variant);
}

.text-field--select .text-field__select:focus + .text-field__label {
  color: var(--md-on-surface);
}

/* date型: ラベルを常に上に */
.text-field__input[type="date"] + .text-field__label {
  top: 0;
  transform: translateY(-50%);
  font-size: 11px;
}

/* エラー状態 */
.text-field.is-error .text-field__input,
.text-field.is-error .text-field__select {
  border-color: var(--md-error);
}

.text-field__error {
  font-size: 11px;
  color: var(--md-error);
  margin-top: 4px;
  padding-left: 12px;
  display: none;
}

.text-field.is-error .text-field__error { display: block; }

/* field-wrap: ヒント+入力欄のラッパー */
.field-wrap {
  display: flex;
  flex-direction: column;
}

.field-hint {
  font-size: 11px;
  color: var(--md-on-variant);
  margin-bottom: 6px;
  padding-left: 2px;
  min-height: 16px;
}

.field-hint--below {
  margin-bottom: 0;
  margin-top: 6px;
  padding-left: 12px;
  min-height: auto;
}

.field-grid > .text-field { align-self: end; }

/* ============================================================
   チェックボックス
============================================================ */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--md-on-surface);
  line-height: 1.5;
}

.checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--md-on-surface);
  cursor: pointer;
}

/* ============================================================
   利用規約・プライバシーポリシーの同意セクション
============================================================ */
.agree-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--md-surface);
  border-radius: var(--md-r-sm);
}

.agree-link {
  color: var(--md-on-surface);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.agree-link:hover { opacity: 0.7; }

/* ============================================================
   請求先トグルセクション
============================================================ */
.billing-section {
  display: none;
  flex-direction: column;
  gap: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--md-outline);
  margin-top: 4px;
}

.billing-section.is-visible { display: flex; }

.billing-section__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--md-on-surface);
  margin-bottom: 4px;
}

/* ============================================================
   M3 Buttons
============================================================ */
.btn-filled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  padding: 0 24px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--md-font);
  color: var(--md-bg);
  background: var(--md-on-surface);
  border: none;
  border-radius: var(--md-r-full);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: opacity var(--t), box-shadow var(--t);
}

.btn-filled:hover:not(:disabled) {
  opacity: 0.85;
  box-shadow: var(--md-elevation-2);
}

.btn-filled:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-outlined {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  padding: 0 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--md-font);
  color: var(--md-on-surface);
  background: var(--md-bg);
  border: 1.5px solid var(--md-on-surface);
  border-radius: var(--md-r-full);
  cursor: pointer;
  transition: opacity var(--t), background var(--t);
}

.btn-outlined:hover:not(:disabled) {
  opacity: 0.85;
  background: var(--md-surface);
}

.btn-outlined:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  gap: 12px;
}

.btn-row .btn-outlined { flex: 1; }
.btn-row .btn-filled { flex: 2; }

/* ============================================================
   確認テーブル
============================================================ */
.confirm-table {
  width: 100%;
  border-collapse: collapse;
}

.confirm-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--md-on-variant);
  padding: 10px 12px;
  border-bottom: 1px solid var(--md-outline);
  white-space: nowrap;
  width: 35%;
  vertical-align: top;
}

.confirm-table td {
  font-size: 14px;
  color: var(--md-on-surface);
  padding: 10px 12px;
  border-bottom: 1px solid var(--md-outline);
  word-break: break-all;
}

.confirm-table tr:last-child th,
.confirm-table tr:last-child td {
  border-bottom: none;
}

/* ============================================================
   完了画面
============================================================ */
.complete-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--md-success-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
  color: var(--md-success);
}

.complete-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--md-on-surface);
  text-align: center;
  margin-bottom: 8px;
}

.complete-message {
  font-size: 13px;
  color: var(--md-on-variant);
  text-align: center;
  line-height: 1.8;
}

/* ============================================================
   エラーバナー
============================================================ */
.error-banner {
  display: none;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: var(--md-error-bg);
  border: 1px solid #F5C6CB;
  border-radius: var(--md-r-xs);
  color: var(--md-error);
  font-size: 13px;
  line-height: 1.5;
}

.error-banner.is-visible { display: flex; }

/* ============================================================
   ローディング
============================================================ */
@keyframes rotate { to { transform: rotate(360deg); } }

.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.loading-overlay.is-visible { display: flex; }

.loading-overlay__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--md-outline);
  border-top-color: var(--md-on-surface);
  border-radius: 50%;
  animation: rotate 0.9s linear infinite;
}

.loading-overlay__text {
  font-size: 14px;
  font-weight: 600;
  color: var(--md-on-surface);
}

/* ============================================================
   LP / フッター
============================================================ */
.lp {
  background: var(--md-bg);
  border-radius: var(--md-r-md);
  box-shadow: var(--md-elevation-1);
  border: 1px solid var(--md-outline);
  padding: 32px;
}

.lp h1 { font-size: 22px; margin-bottom: 16px; }
.lp h2 { font-size: 16px; margin: 24px 0 8px; }
.lp p { margin: 8px 0; color: var(--md-on-variant); }

.cta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.cta-row .btn-filled,
.cta-row .btn-outlined {
  width: auto;
  flex: 1;
  min-width: 240px;
}

.footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--md-on-variant);
  font-size: 11px;
  line-height: 1.8;
  border-top: 1px solid var(--md-outline);
}

/* ============================================================
   スマホ対応
============================================================ */
@media (max-width: 480px) {
  .app-bar { padding: 0 16px; height: 56px; }
  .main { padding: 20px 12px 48px; gap: 20px; }
  .surface, .lp { padding: 16px; }
  .btn-row { flex-direction: column; }
  .btn-row .btn-outlined,
  .btn-row .btn-filled { flex: unset; }
  .steps { gap: 0; }
  .step__connector { width: 24px; }
}