/* デザインのベース */
body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  background-color: #0f172a;
  margin: 0;
  /* 縦並び・中央配置の魔法 */
  /* display: flex; */
  flex-direction: column; /* 子要素を縦に並べる */
  justify-content: center; /* 縦方向の中央に配置 */
  align-items: center; /* 横方向の中央に配置 */

  /* 重要なポイント */
  min-height: 100vh; /* 画面全体の高さを最低限確保する */
}

/* ----------------------------------
 * 1. 画面全体（上下左右中央配置のベース）
 * -------------------------------- */
.page-wrapper {
  display: grid;
  place-items: center; /* これだけで中身が上下左右の完全に真ん中になります */
  min-height: 100vh; /* 画面の縦幅いっぱいに広げる */
  background-color: #0d1117; /* 元の暗い背景色（お好みに合わせて調整してください） */
  padding: 1rem; /* スマホ等で画面端にピッタリくっつくのを防ぐ余白 */
  box-sizing: border-box;
}

/* ----------------------------------
 * 2. ウィンドウカード（レスポンシブ対応）
 * -------------------------------- */
.window-card {
  background-color: #ffffff;
  border-radius: 12px;

  /* 横幅のレスポンシブ設定 */
  width: 100%;
  max-width: 540px; /* PCでの最大幅（元の画像の比率） */

  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  border: 1px solid #334155;
}

/* ----------------------------------
 * 3. ウィンドウヘッダー
 * -------------------------------- */
.window-header {
  background-color: #115e59;
  padding: 1.2rem 1.5rem;
  display: flex;
  /* justify-content: space-between; */
  align-items: center;
  border-bottom: 1px solid #334155;
}

.window-title {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: 0.05em;

  /* アイコンとテキストを並べるための設定 */
  display: flex;
  align-items: center;
  gap: 6px; /* アイコンと文字の間の隙間 */
  padding-left: 10px;
}

.control-dot {
  width: 8px;
  height: 8px;
  background-color: #475569;
  border-radius: 50%;
  display: inline-block;
}

/* ----------------------------------
 * SVGアイコン専用のスタイル
 * -------------------------------- */
.title-icon {
  /* タイトル（0.85rem）よりほんの少しだけ大きく（1rem程度に）すると綺麗に見えます */
  width: 1.5rem;
  height: 1.5rem;

  /* ご指定のカラーコード */
  color: #34d399;

  /* inline-block化してサイズ崩れを防止 */
  display: inline-block;
  flex-shrink: 0; /* 画面が狭まってもアイコンが潰れないようにする */
}

/* ----------------------------------
 * 4. ウィンドウコンテンツ（スマホでの余白調整）
 * -------------------------------- */
.window-body {
  /* PCではゆったりめの余白（元の画像を再現） */
  padding: 1rem 3rem 2rem 3rem;
  text-align: center;
  box-sizing: border-box;
}

/* タイトル・フォーム・ボタン等の既存スタイル */
.card-title {
  color: #1e293b;
  margin-bottom: 2rem;
  font-size: 1.5rem;
}

.form-group {
  text-align: left;
  /* margin-bottom: 1.5rem; */

  transform: translateY(0);
  /* displayも含めてトランジションさせる。durationは合わせる */
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    display 0.3s ease;
  transition-behavior: allow-discrete; /* これが重要 */
}

.form-label {
  display: block;
  color: #475569;
  font-weight: bold;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-sizing: border-box;
  font-size: 1rem;
}

.discription {
  color: #475569;
  font-size: 0.9rem;
}

/* ----------------------------------
 * 5. メディアクエリ（スマホ用微調整）
 * -------------------------------- */
@media (max-width: 576px) {
  .window-body {
    /* PCではゆったりめの余白（元の画像を再現） */
    padding: 1rem 1rem 1rem 1rem;
  }

  .window-title {
    font-size: 1.25rem;
  }
  .window-card {
    /* padding: 2rem 1.5rem; */
    max-width: 566px;
  }
  .card-title {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
  }
}
@media (max-width: 400px) {
  .window-body {
    /* PCではゆったりめの余白（元の画像を再現） */
    padding: 1rem 1rem 1rem 1rem;
  }
  .window-title {
    font-size: 1.5rem;
  }
  .window-card {
    /* padding: 1rem 0.5rem; */
    font-size: 1.5rem;
    max-width: 390px;
  }
  .card-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
  }
}

/* ----------------------------------
 * 現在のモーダルカード（参考値）
 * -------------------------------- */
.login-container {
  background-color: #ffffff;
  border-radius: 12px;
  padding: 3rem 4rem;
  width: 100%;
  max-width: 540px; /* 画像の比率に合わせた幅 */
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  text-align: center;
}

/*.login-container, .log-container*/
.log-container {
  background: #ffffff;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  /* width: 100%; */
  max-width: 800px;
}

.log-container {
  margin-top: 40px;
}
.log-container.debug {
  display: none;
}

.code-container {
  display: flex;
  justify-content: space-between; /* 6つの入力欄を両端に均等に分配 */
  gap: 8px; /* 入力欄同士の隙間（好みに合わせて調整） */
  max-width: 360px; /* スマホからはみ出さないための最大幅 */
  margin: 0 auto; /* 中央寄せ */
}
/* 入力欄単体のスタイル */
.code-input {
  /* width: 100%;                    親の幅（gapを引いた分）に合わせて伸縮 */
  aspect-ratio: 1 / 1; /* 綺麗な正方形を保つ */
  text-align: center; /* 文字を中央に */
  /* font-size: 24px;                入力文字を大きく見せる */
  /* border: 2px solid #ccc; */
  /* border-radius: 4px; */
  /* box-sizing: border-box;         枠線を含んだサイズ計算にする */
}

/* フォーカスしたときの見栄え */
.code-input:focus {
  border-color: #007bff;
  outline: none;
}

h2 {
  margin-bottom: 24px;
  color: #333;
  text-align: center;
  font-size: 1.5rem;
}

.field-group {
  margin-top: 20px;
  position: relative;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: #555;
}

input[type="text"] {
  width: 100%;
  padding: 12px;
  border: 2px solid #e1e4e8;
  border-radius: 8px;
  box-sizing: border-box;
  font-size: 1rem;
  transition: border-color 0.3s;
}
input[type="text"].code-input {
  font-size: 1.5rem;
}

input[type="text"]:focus {
  outline: none;
  border-color: #007bff;
}

div.error {
  color: red;
}
div.code-message {
  width: 100%;
  text-align: center;
}

button {
  width: 100%;
  padding: 0.85rem;
  background-color: #0d9488;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  margin-top: 1rem;
  transition: background-color 0.2s ease;

  /* --- 追加：中の要素を綺麗に真ん中横並びにする --- */
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px; /* スピナーと「認証中です」の間の隙間 */
}

/* 処理中（disabled）のときはホバー効果を無効化し、少し透過させる（お好みで） */
button:disabled {
  background-color: #0d9488;
  opacity: 0.7;
  cursor: not-allowed;
}

button:hover {
  background-color: #0b7a70;
}

button.cancel {
  background-color: #dc2626;
}

button.cancel:hover {
  background-color: #b91c1c;
}

#login-form {
  display: flex;
  flex-wrap: wrap; /* 画面が狭い時に折り返す設定（不要なら nowrap） */
  gap: 10px; /* ボタン同士の間隔 */
}

#api_return {
  background-color: #1e1e1e; /* ダークモード風 */
  color: #00ff00; /* ログらしいグリーン */
  padding: 10px;
  border-radius: 4px;
  font-family: monospace; /* 等幅フォント */
  font-size: 14px;
  line-height: 1.5;

  /* スクロールのための重要設定 */
  max-height: 400px; /* 縦幅の最大値 */
  overflow-y: auto; /* 溢れたらスクロールを表示 */
  border: 1px solid #333;
}

/* ローディングレイヤーの基本スタイル */
#loading-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5); /* 半透明の黒 */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  /* 初期状態は非表示 */
  visibility: hidden;
  opacity: 0;
  transition:
    opacity 0.3s,
    visibility 0.3s;
}

/* 表示状態のクラス */
#loading-layer.is-active {
  visibility: visible;
  opacity: 1;
}

/* スピナーの見た目 */
.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #fff;
  border-top-color: #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ----------------------------------
 * ローディングスピナーの作成
 * -------------------------------- */
.button-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3); /* 全体の輪郭（薄い白） */
  border-top-color: #ffffff; /* 回転する先端（不透明の白） */
  border-radius: 50%;
  animation: spin 0.8s linear infinite; /* 無限回転アニメーション */
  display: inline-block;
  flex-shrink: 0; /* 縮み防止 */
}

/* 入力が無効（未入力など）な場合のスタイル */
input[type="text"].error {
  border-color: #dc3545; /* 赤枠 */
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25); /* ほんのり赤く光らせる */
}
input[type="password"].error {
  border-color: #dc3545; /* 赤枠 */
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25); /* ほんのり赤く光らせる */
}

/* エラーフキダシの本体 */
.error-message {
  display: none; /* 初期状態は非表示 */
  position: absolute;
  top: 100%; /* inputの直下に配置 */
  left: 0;
  margin-top: 8px; /* inputとの間隔 */
  padding: 10px 15px;
  background-color: #dc3545; /* 赤色背景 */
  color: white;
  font-size: 0.85rem;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  z-index: 10; /* 他の要素の上に表示 */
}

/* フキダシの三角部分 */
.error-message::before {
  content: "";
  position: absolute;
  bottom: 100%; /* フキダシの上に配置 */
  left: 15px; /* 左側から少しずらす */
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent #dc3545 transparent; /* 下向きの三角 */
}

/* JSで .show クラスがついた時だけ表示 */
.error-message.show {
  display: block;
  position: relative;
  width: fit-content;
  margin-bottom: 5px;
}

/* QRcode */
#totp-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* padding-top: 1em;
  padding-bottom: 1em; */
}

/* ----------------------------------
 * QRコード表示エリア
 * -------------------------------- */
#qrcode {
  /* ライブラリが中に生成するimgやcanvasを確実に中央に配置 */
  display: flex;
  justify-content: center;
  align-items: center;

  /* QRコードのサイズ（生成するサイズに合わせて調整してください） */
  width: 270px;
  height: 270px;

  /* 下のメッセージとの距離を空ける（ここでお好みの間隔に調整） */
  margin-top: 1.75rem;
  margin-bottom: 1.75rem;
}

/* ----------------------------------
 * メッセージ（説明文）
 * -------------------------------- */
.qrcode-discription {
  align-self: flex-start; /* 親の center を無視して、自身を左寄せにする */
  text-align: left; /* テキスト自体も左詰めにする */

  /* 文字の見た目の微調整 */
  color: #475569;
  font-size: 0.9rem;
  line-height: 1.6;
  width: 100%; /* 横幅いっぱいに広げて左寄せを安定させる */
}

.none {
  opacity: 0;
  transform: translateY(-10px);
  display: none;
}
/* 現れるときの「初期状態」を定義する */
@starting-style {
  .form-group:not(.none) {
    opacity: 0;
    transform: translateY(-10px);
  }
}

#qrcode.none,
#totp-area.none,
#totp-register-button.none,
#totp-start-button.none {
  display: none;
}
#register-button.display_qr {
  display: none;
}

/* ----------------------------------
 * ペースト確認エリア
 * -------------------------------- */
/* モーダル全体の背面（半透明の黒で後ろの画面を暗くする） */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(
    0,
    0,
    0,
    0.6
  ); /* 背面を暗くしてダイアログを際立たせる */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 1;
  transition: opacity 0.2s ease-in-out;
}

/* 非表示状態（JSでこのクラスを制御する） */
.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none; /* クリックをスルーさせる */
}

/* ダイアログのカード本体 */
.modal-card {
  background: #ffffff;
  width: 90%;
  max-width: 440px;
  border-radius: 12px;
  overflow: hidden; /* ヘッダーの角丸を綺麗に出すため */
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  transform: scale(1);
  transition: transform 0.2s ease-in-out;
}

/* 非表示から表示される時のアニメーション用（お好みで） */
.modal-overlay.hidden .modal-card {
  transform: scale(0.9);
}

/* ヘッダー部分（画像の深緑を再現） */
.modal-header {
  background-color: #0d6355; /* 画像のポータルヘッダーの深緑 */
  padding: 14px 20px;
  color: #ffffff;
  font-weight: bold;
  font-size: 15px;
}

/* ボディ部分 */
.modal-body {
  padding: 28px 24px 20px 24px;
  text-align: center;
}

.modal-body h3 {
  margin: 0 0 10px 0;
  color: #1a202c;
  font-size: 20px;
  font-weight: 700;
}

.modal-body p {
  margin: 0;
  color: #64748b;
  font-size: 14px;
}

/* アクションボタンのエリア */
.modal-actions {
  padding: 0 24px 24px 24px;
  display: flex;
  flex-direction: column; /* 画像の配置に合わせて縦並び（横並びなら row に変更） */
  gap: 12px;
}

/* 共通ボタンスタイル */
.modal-actions button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: filter 0.2s;
}

.modal-actions button:hover {
  filter: brightness(0.9); /* ホバー時に少し暗くしてフィードバック */
}

/* 「はい」ボタン（ユーザ申請ボタンの深緑） */
.btn-submit {
  background-color: #0a9b81;
  color: #ffffff;
}

/* 「いいえ」ボタン（キャンセルボタンの赤） */
.btn-cancel {
  background-color: #dc2626;
  color: #ffffff;
}

#login-button.failed {
  background-color: #555;
}
