/**
 * ジムショ UX向上 共通CSS
 * ボタンフィードバック、チェックマーク遷移、フォーカス、アクセシビリティ、
 * オフラインバー、印刷最適化
 */

/* ── ボタンクリックフィードバック ── */
.btn:active,
.action-btn:active,
.btn-gen:active,
.btn-dl:active,
.auth-submit:active,
.plan-card__btn:active,
.add-btn:active,
.toggle-btn:active,
.mode-btn:active {
  transform: scale(0.97);
}

/* transition を付与 */
.btn,
.action-btn,
.btn-gen,
.btn-dl,
.auth-submit,
.plan-card__btn,
.add-btn {
  transition: opacity 0.2s, transform 0.1s ease, background 0.2s;
}

/* ── フォーカス可視化 (アクセシビリティ) ── */
:focus-visible {
  outline: 2px solid #0071e3;
  outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

/* ── ローディングスピナー (ボタン内) ── */
.btn--loading,
.action-btn--loading,
.btn-gen--loading,
.btn-dl--loading,
.auth-submit--loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn--loading::after,
.action-btn--loading::after,
.btn-gen--loading::after,
.btn-dl--loading::after,
.auth-submit--loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ux-spin 0.6s linear infinite;
}

/* アウトラインボタンのスピナーは暗い色 */
.action-btn--outline.action-btn--loading::after,
.btn--outline.btn--loading::after {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: #1d1d1f;
}

@keyframes ux-spin {
  to { transform: rotate(360deg); }
}

/* ── チェックマーク成功表示 ── */
.btn--success,
.action-btn--primary.btn--success,
.btn-gen.btn--success,
.btn-dl.btn--success {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  background: #16a34a !important;
  border-color: #16a34a !important;
}

.btn--success::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 16px;
  margin: -10px 0 0 -5px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
  animation: ux-checkPop 0.3s ease;
}

@keyframes ux-checkPop {
  0% { opacity: 0; transform: rotate(45deg) scale(0.5); }
  60% { transform: rotate(45deg) scale(1.1); }
  100% { opacity: 1; transform: rotate(45deg) scale(1); }
}

/* ── 二重送信防止：disabled状態 ── */
.btn[disabled],
.action-btn[disabled],
.btn-gen[disabled],
.auth-submit[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── エラーメッセージスタイル ── */
.ux-error-msg {
  font-size: 0.82rem;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 8px;
  line-height: 1.6;
  animation: ux-fadeIn 0.2s ease;
}

.ux-success-msg {
  font-size: 0.82rem;
  color: #16a34a;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 8px;
  line-height: 1.6;
  animation: ux-fadeIn 0.2s ease;
}

@keyframes ux-fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Proツール制限バナー改善 ── */
.ux-pro-banner {
  background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
  border: 1.5px solid #bfdbfe;
  border-radius: 14px;
  padding: 20px 24px;
  text-align: center;
  margin: 16px 0;
}

.ux-pro-banner__title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1d4ed8;
  margin-bottom: 6px;
}

.ux-pro-banner__desc {
  font-size: 0.82rem;
  color: #636366;
  line-height: 1.7;
  margin-bottom: 14px;
}

.ux-pro-banner__btn {
  display: inline-block;
  background: #0071e3;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 980px;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.1s;
}

.ux-pro-banner__btn:hover {
  opacity: 0.85;
}

.ux-pro-banner__btn:active {
  transform: scale(0.97);
}

/* ── オフライン通知バー ── */
.ux-offline-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  background: #dc2626;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.ux-offline-bar.is-visible {
  transform: translateY(0);
}

/* ── 印刷最適化 ── */
@media print {
  .nav,
  .footer,
  .actions-bar,
  .seo-section,
  .tool-header,
  .ux-pro-banner,
  .ux-offline-bar,
  .ux-toast,
  #toolbox-pro-gate {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt;
  }

  .invoice-preview,
  .result-panel {
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
  }

  a[href]::after {
    content: none !important;
  }
}

/* ── スキップリンク（スクリーンリーダー用） ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── バリデーションエラー時のinput枠 ── */
.ux-input-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
  animation: ux-shake 0.3s ease;
}

@keyframes ux-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ── トーストメッセージ（操作完了の通知） ── */
.ux-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1d1d1f;
  color: #fff;
  padding: 12px 24px;
  border-radius: 980px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 9999;
  transition: transform 0.3s ease;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.ux-toast.is-visible {
  transform: translateX(-50%) translateY(0);
}
