/* リセットとベース */
.receipt-ocr-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #333;
    line-height: 1.6;
}

/* アニメーションヘッダー */
.conversion-animation {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 120px 20px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin-bottom: 40px;
    position: relative;
    overflow: hidden;
}

.conversion-animation::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.3; }
}

.icon-pdf, .icon-csv {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 2;
    position: relative;
}

.icon-pdf svg, .icon-csv svg {
    width: 100%;
    height: 100%;
    color: #667eea;
}

.icon-csv svg {
    color: #48bb78;
}

.arrow-container {
    width: 200px;
    height: 4px;
    position: relative;
    margin: 0 20px;
}

.arrow-line {
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.arrow-head {
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid rgba(255,255,255,0.3);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.moving-dot {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(255,255,255,0.8);
    animation: moveDot 3s ease-in-out infinite;
}

@keyframes moveDot {
    0%, 100% { left: 0; }
    50% { left: calc(100% - 12px); }
}

/* メインコンテナ */
.receipt-ocr-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

.page-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 40px;
}

/* アップロードエリア */
.upload-area {
    border: 3px dashed #e2e8f0;
    border-radius: 20px;
    padding: 60px 20px;
    text-align: center;
    background: #f8fafc;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-area.drag-over {
    border-color: #667eea;
    background: #e6f0ff;
    transform: scale(1.02);
}

.upload-icon svg {
    width: 80px;
    height: 80px;
    color: #cbd5e0;
    margin-bottom: 20px;
}

.upload-area h3 {
    font-size: 1.5rem;
    color: #4a5568;
    margin-bottom: 10px;
}

.browse-link {
    color: #667eea;
    text-decoration: underline;
    cursor: pointer;
}

/* プレビュー */
.preview-container {
    display: none;
    margin-top: 30px;
    gap: 20px;
    flex-wrap: wrap;
}

.preview-item {
    position: relative;
    width: 150px;
}

.preview-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.preview-item .remove-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 30px;
    height: 30px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

/* 会計ソフト選択 */
.software-selection {
    margin: 40px 0;
}

.software-selection h3 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    text-align: center;
}

.software-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.software-card {
    cursor: pointer;
}

.software-card input {
    display: none;
}

.card-content {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    background: white;
}

.software-card:hover .card-content {
    border-color: #cbd5e0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.software-card input:checked + .card-content {
    border-color: #667eea;
    background: #f0f4ff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.software-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 10px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: white;
}

.software-icon.freee {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.software-icon.yayoi {
    background: linear-gradient(135deg, #10b981, #059669);
}

.software-icon.mf {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.software-icon.generic {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.check-mark {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.software-card input:checked + .card-content .check-mark {
    display: flex;
}

/* 変換ボタン */
.convert-button {
    width: 100%;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.convert-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.convert-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.convert-button.loading .button-text {
    visibility: hidden;
}

.button-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.convert-button.loading .button-loader {
    display: block;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 処理中表示 */
.processing-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.processing-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    animation: progressAnimation 3s ease-in-out;
}

@keyframes progressAnimation {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 90%; }
}

/* 結果表示 */
.result-container {
    display: none;
    margin-top: 40px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.result-header {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-header h3 {
    margin: 0;
    font-size: 1.5rem;
}

.close-result {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.close-result:hover {
    background: rgba(255,255,255,0.2);
}

.result-content {
    padding: 30px;
}

.journal-info {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.journal-info h4 {
    margin-top: 0;
    color: #4a5568;
}

#journal-details {
    display: grid;
    gap: 10px;
}

.journal-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
}

.journal-item:last-child {
    border-bottom: none;
}

.download-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s;
}

.download-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.3);
}

.download-button svg {
    width: 20px;
    height: 20px;
}

.debug-info {
    margin-top: 20px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 8px;
}

.debug-info summary {
    cursor: pointer;
    font-weight: 600;
    color: #4a5568;
}

.debug-info pre {
    margin-top: 10px;
    padding: 10px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
    overflow-x: auto;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .conversion-animation {
        flex-direction: column;
        gap: 20px;
    }
    
    .arrow-container {
        width: 4px;
        height: 100px;
        margin: 20px 0;
    }
    
    .arrow-line {
        width: 100%;
        height: 100%;
    }
    
    .arrow-head {
        right: 50%;
        bottom: -8px;
        top: auto;
        transform: translateX(50%) rotate(90deg);
    }
    
    .moving-dot {
        animation: moveDotVertical 3s ease-in-out infinite;
    }
    
    @keyframes moveDotVertical {
        0%, 100% { top: 0; }
        50% { top: calc(100% - 12px); }
    }
    
    .software-cards {
        grid-template-columns: 1fr 1fr;
    }
    
    .page-title {
        font-size: 2rem;
    }
}