/* ========== 商品分析頁 ========== */
.analyze-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem;
}

.analyze-hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.analyze-hero h1 {
    font-family: "Outfit", sans-serif;
    font-weight: 600;
    font-size: 1.75rem;
    color: var(--forest);
    margin-bottom: 0.5rem;
}

.analyze-hero p {
    color: var(--charcoal);
    opacity: 0.85;
    font-size: 1rem;
}

.analyze-upload {
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

.analyze-upload #btnAnalyze {
    width: 100%;
    margin-top: 1.25rem;
}

.upload-zone {
    border: 2px dashed rgba(125, 155, 118, 0.4);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: rgba(255, 255, 255, 0.6);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--sage);
    background: rgba(255, 255, 255, 0.9);
}

.upload-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.upload-placeholder p {
    color: var(--charcoal);
    font-size: 1rem;
    margin: 0.25rem 0;
}

.upload-hint {
    font-size: 0.85rem !important;
    opacity: 0.7 !important;
}

.camera-controls {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
}

.camera-header-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.upload-container {
    position: relative;
    width: 100%;
    overflow: visible;
}

.upload-preview {
    position: relative;
}

.upload-preview img,
.upload-preview video {
    max-width: 100%;
    max-height: 280px;
    border-radius: 12px;
    object-fit: contain;
}

.analyze-result h2 {
    font-size: 1.25rem;
    color: var(--forest);
    margin-bottom: 1rem;
}

.analyze-result .edit-hint {
    font-size: 0.85rem;
    font-weight: 400;
    opacity: 0.75;
}

.result-edit-form .form-group {
    margin-bottom: 1.25rem;
}

.result-edit-form .form-group:last-of-type {
    margin-bottom: 1.25rem;
}

.result-edit-form label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--charcoal);
    margin-bottom: 0.4rem;
}

.result-edit-form input,
.result-edit-form textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid rgba(125, 155, 118, 0.3);
    border-radius: 10px;
    background: var(--cream);
    color: var(--charcoal);
    transition: border-color 0.2s;
}

.result-edit-form input,
.result-edit-form select {
    background: var(--cream);
}

.result-edit-form input:focus,
.result-edit-form textarea:focus,
.result-edit-form select:focus {
    outline: none;
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(125, 155, 118, 0.1);
}

.result-edit-form textarea {
    resize: vertical;
    min-height: 120px;
}

.result-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem 2rem;
    box-shadow: var(--soft-shadow);
    border: 1px solid rgba(125, 155, 118, 0.15);
}

.result-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--forest);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.result-summary {
    font-size: 0.95rem;
    color: var(--charcoal);
    line-height: 1.7;
    white-space: pre-wrap;
}

.add-to-organize-form {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(125, 155, 118, 0.2);
}

.btn-save-product {
    display: block;
    width: 100%;
    margin-top: 1.5rem;
}

.analyze-error {
    margin-top: 1.5rem;
}

.error-msg {
    padding: 1rem 1.25rem;
    background: rgba(201, 123, 92, 0.15);
    color: var(--terracotta);
    border-radius: 12px;
    font-size: 0.95rem;
}

.analyze-debug {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(125, 155, 118, 0.2);
}

.analyze-debug h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--forest);
    margin-bottom: 0.75rem;
}

.debug-raw {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem 1.25rem;
    border-radius: 10px;
    font-size: 0.8rem;
    font-family: "SF Mono", "Monaco", "Consolas", monospace;
    overflow-x: auto;
    max-height: 320px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.loading {
    position: fixed;
    inset: 0;
    background: rgba(253, 248, 243, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 200;
}

.loading p {
    font-size: 1rem;
    color: var(--forest);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(125, 155, 118, 0.3);
    border-top-color: var(--sage);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

