/* ============================================================
   OCR フォーム連携 — phonelife-care-theme
   フォン太版（水色 #4fc3f7 / オレンジ #ff9a3d）の世界観に合わせる
   ============================================================ */

/* ----- フォーム内のカメラ起動ボタン ----- */
.ocr-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 700;
  color: #fff;
  background: #4fc3f7;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 0 #29a5d9;
  transition: transform .1s, box-shadow .1s, background .15s;
  vertical-align: middle;
}
.ocr-trigger-btn:hover { background: #29b6f6; }
.ocr-trigger-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 #29a5d9;
}
.ocr-trigger-btn:disabled { background: #b0bec5; box-shadow: none; cursor: wait; }

@media (max-width: 480px) {
  .ocr-trigger-btn {
    display: flex;
    margin: 6px 0 0;
    padding: 8px 14px;
    font-size: 0.9rem;
    width: 100%;
    justify-content: center;
  }
}

/* ----- モーダル背景 ----- */
.ocr-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, .55);
  display: none;
  z-index: 9998;
  animation: ocrFadeIn .2s ease-out;
}
.ocr-modal-backdrop.is-open { display: block; }
@keyframes ocrFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ----- モーダル本体 ----- */
.ocr-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 24px));
  max-height: 92vh;
  overflow-y: auto;
  background: #fffaf2;
  border: 3px dashed #ffd27a;
  border-radius: 18px;
  padding: 18px 20px 22px;
  z-index: 9999;
  display: none;
  font-family: inherit;
  color: #2c3e50;
  box-shadow: 0 14px 40px rgba(0,0,0,.2);
}
.ocr-modal.is-open { display: block; }

@media (max-width: 480px) {
  .ocr-modal {
    left: 0;
    top: auto;
    bottom: 0;
    transform: none;
    width: 100%;
    max-height: 96vh;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    animation: ocrSlideUp .25s ease-out;
  }
  @keyframes ocrSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
}

.ocr-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px dotted #ffd27a;
}
.ocr-modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: #ff9a3d;
}
.ocr-modal-close {
  background: transparent;
  border: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: #888;
  cursor: pointer;
  padding: 4px 10px;
  line-height: 1;
}
.ocr-modal-close:hover { color: #2c3e50; }

.ocr-step {
  margin: 14px 0;
  padding: 10px 12px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #ffe6c2;
}
.ocr-step h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #4fc3f7;
}

/* ファイル選択風ボタン */
.ocr-file-label {
  display: inline-block;
  background: #ff9a3d;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 3px 0 #d97c1f;
  transition: transform .1s, box-shadow .1s;
}
.ocr-file-label:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 #d97c1f;
}
.ocr-file-input { display: none; }

.ocr-preview {
  display: block;
  max-width: 100%;
  max-height: 260px;
  margin: 10px auto 0;
  border-radius: 8px;
  border: 1px solid #ddd;
}

.ocr-hint {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: #888;
  line-height: 1.5;
}

/* モーダル内サムネイル一覧 */
.ocr-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  min-height: 0;
}
.ocr-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #ffd27a;
  background: #fff;
}
.ocr-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ocr-thumb-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: 0;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.ocr-thumb-del:hover { background: #c62828; }
.ocr-thumb-num {
  position: absolute;
  bottom: 2px;
  left: 2px;
  background: #ff9a3d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}

/* フォーム側のサムネイル（モーダル外） */
.pl-photo-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.pl-photo-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #ddd;
}
.pl-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pl-photo-thumb-num {
  position: absolute;
  bottom: 2px;
  left: 2px;
  background: rgba(255,154,61,0.95);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
}
.pl-photo-note {
  font-size: 0.78rem;
  color: #888;
  margin: 4px 0 0;
  line-height: 1.5;
}

.ocr-run-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: #4fc3f7;
  color: #fff;
  border: 0;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 0 #29a5d9;
  margin-top: 8px;
}
.ocr-run-btn:active { transform: translateY(3px); box-shadow: 0 0 0 #29a5d9; }
.ocr-run-btn:disabled { background: #b0bec5; box-shadow: none; cursor: wait; }

/* AI推定ボタン（紫グラデで「特別感」） */
.ocr-ai-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 10px;
  background: linear-gradient(135deg, #9c27b0 0%, #673ab7 100%);
  color: #fff;
  border: 0;
  border-radius: 12px;
  font-size: 1.02rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 0 #4a148c;
  position: relative;
}
.ocr-ai-btn::before {
  content: '✨ ';
  position: absolute;
  left: 12px;
  top: 14px;
  font-size: 1rem;
}
.ocr-ai-btn:active { transform: translateY(3px); box-shadow: 0 0 0 #4a148c; }
.ocr-ai-btn:disabled { background: #b0bec5; box-shadow: none; cursor: wait; }

/* AI推定結果カード */
.ocr-ai-result {
  background: linear-gradient(135deg, #f3e5f5 0%, #fff8e1 100%);
  border: 2px solid #ce93d8;
  border-radius: 12px;
  padding: 14px 16px;
}
.ocr-ai-summary {
  font-size: 1.05rem;
  margin-bottom: 6px;
  color: #2c3e50;
}
.ocr-ai-summary strong {
  color: #6a1b9a;
  font-size: 1.1rem;
}
.ocr-ai-reason {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 6px;
  line-height: 1.5;
}
.ocr-ai-meta {
  font-size: 0.78rem;
  color: #888;
  margin-bottom: 10px;
}
.ocr-ai-apply {
  display: block;
  width: 100%;
  background: #ff9a3d !important;
  color: #fff !important;
  border: 0 !important;
  font-family: inherit !important;
  font-weight: 800 !important;
  text-align: center;
  padding: 10px !important;
}
.ocr-ai-apply:hover { background: #ef6c00 !important; }

/* AI推定結果に添える「底面シール型番もあると確実」 */
.ocr-ai-confirm {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fffaf2;
  border: 1px dashed #ffc107;
  border-radius: 8px;
  font-size: 0.78rem;
  color: #555;
  line-height: 1.6;
}
.ocr-ai-confirm strong { color: #ff9a3d; }

/* モーダル冒頭の優しいヒント */
.ocr-tip-top {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: #e8f5e9;
  border-left: 4px solid #66bb6a;
  border-radius: 0 6px 6px 0;
  font-size: 0.82rem;
  color: #2c3e50;
  line-height: 1.55;
}
.ocr-tip-top strong { color: #388e3c; }

/* HP問い合わせセクション上部の AI訴求バナー */
.ai-feature-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px auto 24px;
  max-width: 640px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #f3e5f5 0%, #e3f2fd 50%, #fff8e1 100%);
  border: 2px solid #ce93d8;
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(156, 39, 176, .12);
  position: relative;
  overflow: hidden;
}
.ai-feature-banner::before {
  content: '';
  position: absolute;
  top: -40%;
  left: -20%;
  width: 50%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.25), transparent);
  transform: rotate(20deg);
  animation: aiBannerShine 14s ease-in-out infinite;
  pointer-events: none;
}
@keyframes aiBannerShine {
  0%, 92%, 100% { transform: rotate(20deg) translateX(-200%); }
  96%           { transform: rotate(20deg) translateX(400%); }
}
.ai-feature-icon {
  font-size: 2rem;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(156,39,176,.3));
}
.ai-feature-text { flex: 1; min-width: 0; }
.ai-feature-text strong {
  display: block;
  color: #6a1b9a;
  font-size: 1.0rem;
  font-weight: 800;
  margin-bottom: 2px;
}
.ai-feature-text small {
  display: block;
  color: #555;
  font-size: 0.78rem;
  line-height: 1.5;
}
@media (max-width: 480px) {
  .ai-feature-banner {
    margin: 12px 8px 18px;
    padding: 12px 14px;
    gap: 10px;
  }
  .ai-feature-icon { font-size: 1.6rem; }
  .ai-feature-text strong { font-size: 0.95rem; }
}

.ocr-progress {
  font-size: 0.82rem;
  color: #666;
  margin: 8px 0 4px;
  min-height: 1.2em;
}
.ocr-progress-bar {
  height: 6px;
  background: #ffe6c2;
  border-radius: 3px;
  overflow: hidden;
  display: none;
}
.ocr-progress-bar.is-active { display: block; }
.ocr-progress-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #4fc3f7, #ff9a3d);
  width: 0%;
  transition: width .25s;
}

.ocr-candidates { margin-top: 8px; }
.ocr-candidate {
  display: inline-block;
  margin: 4px 6px 4px 0;
  padding: 8px 12px;
  background: #fff3cd;
  border: 2px solid #ffd27a;
  border-radius: 8px;
  font-family: 'Kosugi Maru', monospace;
  font-size: 0.88rem;
  cursor: pointer;
  color: #2c3e50;
}
.ocr-candidate:hover { background: #ffe082; }
.ocr-candidate:active { background: #ffd27a; }

.ocr-empty {
  font-size: 0.85rem;
  color: #999;
  font-style: italic;
  padding: 8px 0;
}

.ocr-help {
  margin: 10px 0 0;
  padding: 8px 10px;
  background: #e3f2fd;
  border-left: 4px solid #4fc3f7;
  border-radius: 0 6px 6px 0;
  font-size: 0.78rem;
  color: #555;
  line-height: 1.5;
}

.ocr-result-banner {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fff3e0;
  border: 2px solid #ff9a3d;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #2c3e50;
  font-weight: 600;
  display: none;
}
.ocr-result-banner.is-shown { display: block; }
.ocr-result-banner strong { color: #ff9a3d; font-size: 1.05rem; }
