/* ===================================
   レイアウト修正CSS
   PC/モバイル表示の配置問題を解決
   =================================== */

/* ===================================
   緊急アラートセクションの中央寄せ
   =================================== */
.emergency-alert {
  text-align: center;
  padding: 2rem 1rem;
}

.alert-urgent {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  padding: 2rem;
}

.alert-urgent h3 {
  text-align: center;
  margin-bottom: 1rem;
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
}

.alert-urgent p {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: clamp(1rem, 2vw, 1.1rem);
}

.alert-urgent .btn {
  display: inline-block;
  margin: 0 auto;
}

/* ===================================
   ヘッダーナビゲーションの垂直配置修正
   =================================== */
.header {
  padding: 0;
  display: flex;
  align-items: center;
  min-height: var(--header-height, 70px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem;
  min-height: inherit;
}

.logo {
  display: flex;
  align-items: center;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 700;
  text-decoration: none;
  line-height: 1;
}

.logo-icon {
  font-size: 1.5em;
  margin-right: 0.5rem;
  display: inline-flex;
  align-items: center;
}

.nav-menu {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  height: 100%;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  height: 100%;
  text-decoration: none;
  transition: all 0.3s ease;
}

/* モバイルメニューの調整 */
@media (max-width: 767px) {
  .nav-menu {
    position: fixed;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 2rem 1rem;
    top: var(--header-height, 70px);
    left: -100%;
    width: 100%;
    height: calc(100vh - var(--header-height, 70px));
    background: white;
    transition: left 0.3s ease;
    z-index: 999;
  }
  
  .nav-menu.active {
    left: 0;
  }
  
  .nav-link {
    width: 100%;
    padding: 1rem;
    border-bottom: 1px solid #eee;
  }
}

/* ===================================
   事務所グリッドの中央寄せ（PC）
   =================================== */
#officesGrid {
  width: 100%;
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1rem;
}

@media (min-width: 1024px) {
  #officesGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 2rem;
    justify-content: center;
    align-items: start;
  }
  
  .office-card {
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
  }
}

@media (min-width: 1440px) {
  #officesGrid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1600px;
  }
}

/* ===================================
   セクション全体の中央寄せ
   =================================== */
.offices-section {
  padding: 3rem 0;
}

.offices-section .container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
}

@media (min-width: 1024px) {
  .offices-section .container {
    padding: 0 3rem;
  }
}

/* ===================================
   診断セクションの中央配置
   =================================== */
.diagnosis-section {
  padding: 3rem 0;
}

.diagnosis-section .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.diagnosis-form {
  max-width: 800px;
  margin: 0 auto;
}

/* ===================================
   債務整理タイプグリッドの中央寄せ
   =================================== */
.types-grid {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1rem;
}

@media (min-width: 768px) {
  .types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    justify-content: center;
  }
}

@media (min-width: 1024px) {
  .types-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }
  
  .type-card {
    max-width: none;
  }
}

/* ===================================
   FAQ セクションの中央配置
   =================================== */
.faq-section {
  padding: 3rem 0;
  overflow-x: hidden;
}

.faq-section .container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

.faq-container {
  max-width: 100%;
}

/* FAQアイテムのモバイル最適化 */
.faq-item {
  margin-bottom: 1rem !important;
  width: 100% !important;
  overflow: hidden !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 1rem;
  text-align: left;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: keep-all;
}

.faq-question-text {
  flex: 1;
  padding-right: 1rem;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  line-height: 1.5;
  max-width: calc(100% - 40px);
}

.faq-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  transition: transform 0.3s ease;
}

.faq-answer {
  display: none;
  padding: 1rem;
  background: white;
  border: 1px solid #dee2e6;
  border-top: none;
  border-radius: 0 0 8px 8px;
  margin-top: -1px;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.faq-answer.active {
  display: block;
}

.faq-answer p {
  margin: 0;
  font-size: clamp(0.85rem, 2vw, 1rem);
  line-height: 1.7;
  color: #495057;
}

/* モバイル専用調整 */
@media (max-width: 767px) {
  .faq-section {
    padding: 2rem 0;
  }
  
  .faq-section .container {
    padding: 0 0.75rem;
  }
  
  .faq-item {
    margin-bottom: 0.75rem;
  }
  
  .faq-question {
    padding: 0.875rem;
    flex-wrap: nowrap;
  }
  
  .faq-question-text {
    font-size: 0.9rem;
    padding-right: 0.5rem;
  }
  
  .faq-icon {
    width: 24px;
    height: 24px;
    font-size: 1.2rem;
  }
  
  .faq-answer {
    padding: 0.875rem;
  }
  
  .faq-answer p {
    font-size: 0.85rem;
    line-height: 1.6;
  }
}

/* iPhone SE等の小画面対応 */
@media (max-width: 375px) {
  .faq-section .container {
    padding: 0 0.5rem;
  }
  
  .faq-question {
    padding: 0.75rem;
  }
  
  .faq-question-text {
    font-size: 0.85rem;
  }
  
  .faq-answer {
    padding: 0.75rem;
  }
  
  .faq-answer p {
    font-size: 0.8rem;
  }
}

/* ===================================
   テキストの中央寄せユーティリティ
   =================================== */
.text-center {
  text-align: center !important;
}

.mx-auto {
  margin-left: auto !important;
  margin-right: auto !important;
}

/* ===================================
   モバイル最適化（スマホ表示）
   =================================== */
@media (max-width: 767px) {
  /* セクションの余白調整 */
  section {
    padding: 2rem 0;
  }
  
  .container {
    padding: 0 1rem;
  }
  
  /* カードの余白最適化 */
  .card {
    margin-bottom: 1rem;
    padding: 1.25rem;
  }
  
  /* グリッドをスタック表示に */
  .types-grid,
  #officesGrid {
    display: block;
  }
  
  .type-card,
  .office-card {
    margin-bottom: 1rem;
  }
  
  /* ボタンを全幅に */
  .btn {
    width: 100%;
    text-align: center;
  }
  
  /* 統計情報を縦並びに */
  .hero-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  
  .stat-item {
    width: 100%;
    text-align: center;
  }
  
  /* フォームグループの余白 */
  .form-group {
    margin-bottom: 1.5rem;
  }
  
  /* テーブルを横スクロール可能に */
  .comparison-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .comparison-table {
    min-width: 600px;
  }
}

/* ===================================
   iPhone SE (375px) 特別対応
   =================================== */
@media (max-width: 375px) {
  .container {
    padding: 0 0.75rem;
  }
  
  .card {
    padding: 1rem;
  }
  
  .btn {
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
  }
  
  .hero .card-title {
    font-size: 1.5rem;
  }
  
  .section-title {
    font-size: 1.3rem;
  }
}

/* ===================================
   タブレット最適化
   =================================== */
@media (min-width: 768px) and (max-width: 1023px) {
  .container {
    max-width: 100%;
    padding: 0 2rem;
  }
  
  #officesGrid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
  
  .types-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

/* ===================================
   大画面での最大幅制限
   =================================== */
@media (min-width: 1920px) {
  .container {
    max-width: 1800px;
  }
  
  #officesGrid {
    max-width: 1800px;
  }
  
  .types-grid {
    max-width: 1800px;
  }
  
  .diagnosis-section .container {
    max-width: 1000px;
  }
  
  .faq-section .container {
    max-width: 1000px;
  }
}

/* ===================================
   スムーススクロール用の余白
   =================================== */
section[id] {
  scroll-margin-top: calc(var(--header-height, 70px) + 20px);
}

/* ===================================
   フレックスボックスのフォールバック
   =================================== */
@supports not (display: grid) {
  .types-grid,
  #officesGrid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .type-card,
  .office-card {
    flex: 0 1 calc(33.333% - 2rem);
    margin: 1rem;
  }
  
  @media (max-width: 1023px) {
    .type-card,
    .office-card {
      flex: 0 1 calc(50% - 2rem);
    }
  }
  
  @media (max-width: 767px) {
    .type-card,
    .office-card {
      flex: 0 1 100%;
    }
  }
}