/* 
 * 統一フォームデザイン CSS
 * seikyu_plus のTailwindデザインをBootstrap 5ベースに統一
 * 作成日: 2025-08-22
 */

/* ===== フォーム全体のスタイル ===== */
.unified-form {
  background: #ffffff !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.unified-form:hover {
  transform: none;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15) !important;
  background: #ffffff !important;
  transition: none;
}

/* フォームの装飾的背景要素 */
.unified-form::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 128px;
  height: 128px;
  background: rgba(15, 76, 129, 0.05); /* primary color */
  border-bottom-left-radius: 100px;
  z-index: -1;
}

.unified-form::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 128px;
  height: 128px;
  background: rgba(15, 76, 129, 0.05); /* primary color */
  border-top-right-radius: 100px;
  z-index: -1;
}

/* ===== ラベルとフィールドのスタイル ===== */
.unified-form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.25rem;
  display: block;
}

/* 必須・任意ピル */
.required-pill {
  background: #f97316; /* warmOrange */
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-right: 0.5rem;
  display: inline-block;
}

.optional-pill {
  background: #6b7280;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-right: 0.5rem;
  display: inline-block;
}

/* ===== 入力フィールドのスタイル ===== */
.unified-form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #111827;
  transition: all 0.3s ease;
}

.unified-form-control:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(15, 76, 129, 0.5); /* primary color */
  background: #ffffff;
}

.unified-form-control::placeholder {
  color: #9ca3af;
}

/* セレクトボックス */
.unified-form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #111827;
  cursor: pointer;
  transition: all 0.3s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

.unified-form-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(15, 76, 129, 0.5);
  background-color: #ffffff;
}

/* テキストエリア */
.unified-form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #111827;
  resize: none;
  transition: all 0.3s ease;
  min-height: 120px;
}

.unified-form-textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(15, 76, 129, 0.5);
  background: #ffffff;
}

/* ===== チェックボックス・ラジオボタン ===== */
.unified-form-check {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
  margin-left: 1rem; /* チェックボックスの左にマージンを追加 */
}

.unified-form-check-input {
  width: 1rem;
  height: 1rem;
  margin-right: 0.75rem;
  accent-color: #0f4c81; /* primary color */
  cursor: pointer;
}

.unified-form-check-label {
  font-size: 0.875rem;
  color: #374151;
  cursor: pointer;
  line-height: 1.5;
}

/* ===== ボタンスタイル ===== */
.unified-btn-primary {
  background: linear-gradient(135deg, #0f4c81 0%, #1e40af 100%);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.875rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

.unified-btn-primary:hover {
  background: linear-gradient(135deg, #1e40af 0%, #0f4c81 100%);
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(15, 76, 129, 0.3);
}

.unified-btn-primary:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== フォームグループとレイアウト ===== */
.unified-form-group {
  margin-bottom: 1.5rem;
}

.unified-form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.unified-form-col {
  flex: 1;
}

.unified-form-col-2 {
  flex: 0 0 50%;
}

/* ===== プライバシー同意セクション ===== */
.unified-privacy-section {
  background: rgba(15, 76, 129, 0.05);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.unified-privacy-check {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.unified-privacy-check input[type="checkbox"] {
  margin-top: 0.25rem;
  width: 1rem;
  height: 1rem;
  accent-color: #0f4c81;
}

.unified-privacy-check label {
  font-size: 0.875rem;
  color: #4b5563;
  line-height: 1.5;
}

.unified-privacy-check a {
  color: #0f4c81;
  text-decoration: none;
  font-weight: 600;
}

.unified-privacy-check a:hover {
  text-decoration: underline;
}

/* ===== レスポンシブ対応 ===== */
@media (max-width: 768px) {
  .unified-form {
    padding: 1.5rem;
    border-radius: 12px;
  }

  .unified-form-row {
    flex-direction: column;
    gap: 0;
  }

  .unified-form-col,
  .unified-form-col-2 {
    flex: 1;
    margin-bottom: 1.5rem;
  }

  .unified-btn-primary {
    width: 100%;
    padding: 1rem 2rem;
  }
}

/* ===== アニメーション効果 ===== */
.unified-form-control,
.unified-form-select,
.unified-form-textarea {
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== フォーカス時のラベルアニメーション ===== */
.unified-form-group {
  position: relative;
}

.unified-form-floating {
  position: relative;
}

.unified-form-floating .unified-form-control:focus + .unified-form-label,
.unified-form-floating
  .unified-form-control:not(:placeholder-shown)
  + .unified-form-label {
  transform: translateY(-1.5rem) scale(0.85);
  color: #0f4c81;
}

.unified-form-floating .unified-form-label {
  position: absolute;
  top: 0.75rem;
  left: 1rem;
  transition: all 0.3s ease;
  pointer-events: none;
  color: #9ca3af;
}

/* ===== エラー状態のスタイル ===== */
.unified-form-control.error,
.unified-form-select.error,
.unified-form-textarea.error {
  border: 2px solid #ef4444;
  background: #fef2f2;
}

.unified-form-control.error:focus,
.unified-form-select.error:focus,
.unified-form-textarea.error:focus {
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5);
}

.unified-error-message {
  color: #ef4444;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  display: block;
}

/* ===== 成功状態のスタイル ===== */
.unified-form-control.success,
.unified-form-select.success,
.unified-form-textarea.success {
  border: 2px solid #10b981;
  background: #f0fdf4;
}

.unified-success-message {
  color: #10b981;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  display: block;
}

/* ===== ローディング状態 ===== */
.unified-btn-primary.loading {
  position: relative;
  color: transparent;
}

.unified-btn-primary.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* ===== アイコン付きフィールド ===== */
.unified-form-icon-group {
  position: relative;
}

.unified-form-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.25rem;
  height: 1.25rem;
  color: #9ca3af;
  z-index: 1;
}

.unified-form-icon-group .unified-form-control {
  padding-left: 3rem;
}

/* ===== ツールチップ ===== */
.unified-tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
}

.unified-tooltip .unified-tooltip-text {
  visibility: hidden;
  width: 200px;
  background-color: #374151;
  color: white;
  text-align: center;
  border-radius: 6px;
  padding: 8px;
  position: absolute;
  z-index: 1000;
  bottom: 125%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.75rem;
  line-height: 1.4;
}

.unified-tooltip:hover .unified-tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* ===== プログレスバー ===== */
.unified-form-progress {
  width: 100%;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  margin-bottom: 2rem;
  overflow: hidden;
}

.unified-form-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0f4c81 0%, #1e40af 100%);
  border-radius: 2px;
  transition: width 0.5s ease;
}
