/* src/public/css/receipt-ocr.css */

/* 💡 このページは表示・非表示を hidden 属性で切り替えていますが、
       下のほうで箱に display: flex などを指定しているため、そのままだと
       「hidden を付けたのに消えない」状態になります（author の display 指定が
       ブラウザ既定の display:none に勝つためです）。ここで打ち消しておきます。 */
[hidden] {
    display: none !important;
}

#ocr-app {
    max-width: 640px;
    margin: 24px auto 0;
}

/* ---------- ① アップロード欄 ---------- */

.ocr-upload-box {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    background: #f8fafc;
}

.ocr-upload-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-upload {
    background: #1e3c72;
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(30, 60, 114, 0.2);
    border: none;
}

.btn-upload-secondary {
    background: #64748b;
    box-shadow: 0 4px 10px rgba(100, 116, 139, 0.2);
}

.ocr-upload-tip {
    font-size: 0.8rem;
    color: #64748b;
    margin: 16px 0 0;
}

/* ---------- ② 書類検出・切り抜き ---------- */

.ocr-crop {
    margin-top: 20px;
}

.ocr-crop-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #111;
}

.ocr-crop-stage img {
    display: block;
    max-width: 100%;
    max-height: 480px;
    width: auto;
}

.ocr-crop-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.ocr-crop-poly {
    fill: rgba(243, 156, 18, 0.22);
    stroke: #f39c12;
    stroke-width: 0.6;
    vector-effect: non-scaling-stroke;
}

/* 見た目のドット（小さめ）。当たり判定の円の上に重ねて表示します */
.ocr-crop-handle-dot {
    fill: #ffffff;
    stroke: #f39c12;
    stroke-width: 0.6;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

/* ドラッグを実際に拾う当たり判定用の円（指でも掴みやすいよう少し広め・透明） */
.ocr-crop-handle-hit {
    fill: transparent;
    cursor: grab;
}

.ocr-crop-handle-hit:active {
    cursor: grabbing;
}

.ocr-crop-handle-hit:active + .ocr-crop-handle-dot {
    fill: #f39c12;
}

.ocr-crop-hint {
    text-align: center;
    font-size: 0.82rem;
    color: #64748b;
    margin: 12px 0 0;
}

.ocr-crop-actions {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.ocr-crop-actions .ocr-retake-btn {
    margin-top: 0;
}

.ocr-crop-skip-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.85rem;
    text-decoration: underline;
    cursor: pointer;
    padding: 8px 4px;
}

.ocr-crop-actions .ocr-run-btn {
    width: auto;
    flex: 1 1 auto;
    min-width: 180px;
    margin-top: 0;
}

/* ---------- ③ プレビュー・モード選択 ---------- */

.ocr-editor {
    margin-top: 20px;
}

.ocr-preview {
    position: relative;
    text-align: center;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 12px;
}

.ocr-preview img {
    max-width: 100%;
    max-height: 420px;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

.ocr-fallback-note {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 8px;
}

.ocr-retake-btn {
    margin-top: 12px;
    background: none;
    border: 1px solid #cbd5e1;
    color: #475569;
    border-radius: 50px;
    padding: 8px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ocr-mode-group {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ocr-mode-label {
    font-weight: bold;
    color: #1e3c72;
    font-size: 0.95rem;
}

.ocr-mode-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid #e1e5ea;
    border-radius: 10px;
    cursor: pointer;
    background: #fff;
}

.ocr-mode-option:has(input:disabled) {
    opacity: 0.55;
    cursor: not-allowed;
}

.ocr-mode-option input {
    margin-top: 4px;
}

.ocr-mode-option span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ocr-mode-option strong {
    font-size: 0.92rem;
    color: #1e293b;
}

.ocr-mode-option small {
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.5;
}

.ocr-run-btn {
    width: 100%;
    margin-top: 18px;
    background: #f39c12;
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 14px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(243, 156, 18, 0.25);
}

.ocr-run-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---------- 進捗表示 ---------- */

.ocr-progress {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #64748b;
    font-size: 0.9rem;
}

.ocr-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e1e5ea;
    border-top-color: #1e3c72;
    border-radius: 50%;
    animation: ocr-spin 0.8s linear infinite;
}

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

/* ---------- ③ 結果 ---------- */

.ocr-result {
    margin-top: 24px;
}

.ocr-result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.ocr-result-label {
    font-weight: bold;
    color: #1e3c72;
}

.ocr-copy-btn {
    background: #e8f0fe;
    color: #1e3c72;
    border: none;
    border-radius: 50px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ocr-copy-btn.is-copied {
    background: #dcfce7;
    color: #15803d;
}

.ocr-result-text {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #e1e5ea;
    border-radius: 10px;
    padding: 14px;
    font-size: 0.95rem;
    line-height: 1.7;
    resize: vertical;
    font-family: inherit;
}

/* ---------- トースト（エラー表示） ---------- */

.toast-area {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast-msg {
    background: rgba(30, 41, 59, 0.9);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.toast-msg.show {
    opacity: 1;
    transform: translateY(0);
}
