﻿.pi-page {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
.pi-form-grid,
.pi-card,
.pi-submission-card,
.pi-scroll-row {
    max-width: 100%;
    box-sizing: border-box;
}

.pi-scroll-row {
    overflow-x: auto;
}
.pi-hero {
    padding: 28px;
    border-radius: 18px;
    background: linear-gradient(135deg, #eff6ff, #ffffff);
    border: 1px solid #dbeafe;
    margin-bottom: 24px;
}

    .pi-hero h1 {
        margin: 0 0 10px;
        font-size: 34px;
        line-height: 1.1;
    }

.pi-muted {
    color: #6b7280;
    line-height: 1.6;
}

.pi-alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 600;
}

.pi-alert-success {
    background: #ecfdf5;
    border: 1px solid #10b981;
    color: #065f46;
}

.pi-alert-error {
    background: #fef2f2;
    border: 1px solid #ef4444;
    color: #991b1b;
}

.pi-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.pi-form {
    display: grid;
    gap: 18px;
}

.pi-form-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 18px;
}

.pi-form-group {
    display: grid;
    gap: 8px;
}

.pi-label {
    font-weight: 700;
    color: #111827;
}

.pi-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 15px;
}

.pi-file-input {
    padding: 12px;
    border: 1px dashed #93c5fd;
    border-radius: 10px;
    background: #eff6ff;
}

.pi-error {
    color: #b91c1c;
    font-size: 14px;
}

.pi-preview {
    display: none;
    margin-top: 12px;
}

    .pi-preview img {
        max-width: 260px;
        max-height: 260px;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
    }

.pi-btn-primary {
    justify-self: start;
    padding: 12px 18px;
    background: #2563eb;
    color: #ffffff;
    border: 0;
    border-radius: 10px;
    font-weight: 800;
    cursor: pointer;
}

    .pi-btn-primary:hover {
        background: #1d4ed8;
    }

.pi-section-title {
    margin: 30px 0 14px;
}

.pi-submission-list {
    display: grid;
    gap: 16px;
}

.pi-submission-card {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #ffffff;
    padding: 16px;
}

.pi-submission-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.pi-submission-title {
    font-weight: 800;
    color: #111827;
}

.pi-submission-meta {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
}

.pi-scroll-row {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.pi-scroll-item {
    min-width: 150px;
    flex-shrink: 0;
    padding: 12px;
    border-radius: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    overflow-wrap: anywhere;
    word-break:break-all;
}

.pi-scroll-item-wide {
    min-width: 0; /* 🔥 allows shrink */
    max-width: 260px; /* optional cap */
    flex: 1; /* allows flexible width */
}

.pi-item-label {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
    font-weight: 700;
}

.pi-item-value {
    color: #111827;
    word-break: break-word;
    overflow-wrap: anywhere; /* 🔥 critical */
}
    .pi-item-value a {
        word-break: break-all;
        overflow-wrap: anywhere;
    }
.pi-thumb {
    max-width: 130px;
    max-height: 130px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.pi-status {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
}

.pi-action-link {
    color: #2563eb;
    font-weight: 800;
    text-decoration: none;
}

    .pi-action-link:hover {
        text-decoration: underline;
    }
.pi-status-pending {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

.pi-status-processing {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
}

.pi-status-completed {
    background: #ecfdf5;
    border-color: #10b981;
    color: #065f46;
}

.pi-status-failed {
    background: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
}
.pi-scroll-item {
    min-width: 220px;
}

.pi-scroll-item-wide {
    min-width: 320px;
}
.pi-word-wrap {
    display: block;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}
.pi-item-value a.pi-word-wrap {
    display: inline-block;
    max-width: 100%;
}
.pi-scroll-item-wide {
    flex: 1 1 420px;
    min-width: 320px;
}
.pi-url-wrap {
    width: 100%;
}

.pi-url-link {
    display: inline-block;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.5;
}
.pi-title-wrap {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.5;
}
.pi-submission-list {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.pi-submission-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.pi-submission-top,
.pi-scroll-row {
    max-width: 100%;
    box-sizing: border-box;
}

.pi-scroll-row {
    overflow-x: auto;
}

.pi-scroll-item {
    min-width: 150px;
    max-width: 260px;
    box-sizing: border-box;
}

.pi-scroll-item-wide {
    min-width: 0;
    max-width: 280px;
    flex: 0 0 280px;
}
@media (max-width: 760px) {
    .pi-form-grid {
        grid-template-columns: 1fr;
    }

    .pi-hero h1 {
        font-size: 28px;
    }
}
.pi-submission-description {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.pi-description-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
}

.pi-description-title {
    font-size: .95rem;
    font-weight: 600;
    color: #111827;
}

.pi-description-optional {
    color: var(--color-text-muted);
    font-size: .8rem;
    font-weight: 600;
}

.pi-description-guidance {
    margin: 0;
    padding: .75rem .85rem;
    border: 1px solid #bfdbfe;
    border-radius: .75rem;
    background: #eff6ff;
    color: #334155;
    font-size: .82rem;
    line-height: 1.5;
}

.pi-description-guidance strong {
    color: #1d4ed8;
}

.pi-description-guidance-page {
    margin-bottom: 1rem;
}

.pi-description-edit-btn {
    margin-left: auto; /* pushes icon to the far right */

    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    transition: all .2s ease;
}

    .pi-description-edit-btn:hover {
        background: #f3f4f6;
        border-color: #d1d5db;
    }
.pi-description-actions {
    display: flex;
    gap: .75rem;
}
.pi-spacer {
    flex: 1;
}
.pi-kpr-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top:.25rem;
}

.pi-kpr-item {
    min-height: 90px;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

    .pi-kpr-item span {
        margin-bottom: .35rem;
        font-size: .85rem;
        color: #6b7280;
    }

    .pi-kpr-item strong {
        font-size: 1.1rem;
        font-weight: 700;
    }

.pi-profitability-range {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pi-analysis-progress {
    margin-top: 1rem;
    padding: .75rem 1rem;
    border-radius: 10px;
    background: #eef2ff;
    color: #4338ca;
    font-weight: 600;
}
.pi-btn-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.pi-processing-banner {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1000;
    margin-bottom: 24px;
    padding: 18px 24px;
    background: #eef6ff;
    border: 1px solid #bfdbfe;
    border-left: 6px solid #2563eb;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

.pi-processing-content {
    display: flex;
    align-items: center;
    gap: 18px;
}

    .pi-processing-content h2 {
        margin: 0 0 4px;
        font-size: 1.1rem;
    }

    .pi-processing-content p {
        margin: 0;
        color: #475569;
    }

.pi-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #dbeafe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: piSpin .8s linear infinite;
}

@keyframes piSpin {
    to {
        transform: rotate(360deg);
    }
}
.pi-processing-banner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    padding: 18px 28px;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .16);
}

    .pi-processing-banner.is-visible {
        display: block !important;
    }

.pi-processing-content {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

    .pi-processing-content h2 {
        margin: 0 0 4px;
        font-size: 1.05rem;
        color: #0f172a;
    }

    .pi-processing-content p {
        margin: 0;
        color: #475569;
        line-height: 1.45;
    }

.pi-spinner {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border: 3px solid #dbeafe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: piSpin .8s linear infinite;
}

body.pi-analysis-running {
    padding-top: 96px;
}
.pi-image-preview-link img {
    cursor: zoom-in;
    transition: transform .2s ease;
}

.pi-image-preview-link:hover img {
    transform: scale(1.02);
}

.pi-image-link {
    font-weight: 600;
    text-decoration: none;
}

.pi-image-link:hover {
        text-decoration: underline;
    }

/* Product analysis workflow/status page */
.pi-analysis-status-content {
    display: grid;
    gap: 18px;
}

.pi-analysis-complete,
.pi-analysis-waiting {
    padding: 56px 32px;
    text-align: center;
    background: var(--pi-card, #fff);
    border: 1px solid var(--pi-border, #e5e7eb);
    border-radius: 28px;
    box-shadow: var(--pi-shadow, 0 18px 48px rgba(16, 24, 40, .07));
}

.pi-complete-icon,
.pi-analysis-state-icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin: 0 auto 18px;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: 800;
}

.pi-complete-icon {
    background: var(--pi-green-bg, #ecfdf3);
    color: #15803d;
}

.pi-analysis-state-icon {
    background: #eff6ff;
    color: var(--pi-primary, #2563eb);
}

.pi-analysis-waiting.is-processing .pi-analysis-state-icon {
    background: #eff6ff;
}

.pi-analysis-complete .pi-eyebrow,
.pi-analysis-waiting .pi-eyebrow {
    text-align: center;
}

.pi-analysis-complete h2,
.pi-analysis-waiting h2 {
    margin: 6px 0 10px;
    color: var(--pi-text, #101828);
    font-size: clamp(1.55rem, 3vw, 1.9rem);
    letter-spacing: -.025em;
}

.pi-analysis-complete p,
.pi-analysis-waiting p {
    max-width: 640px;
    margin: 0 auto 24px;
    color: var(--pi-muted, #667085);
    line-height: 1.65;
}

.pi-analysis-complete .pi-analysis-lead,
.pi-analysis-waiting .pi-analysis-lead {
    margin-bottom: 6px;
    color: var(--pi-text, #101828);
    font-size: 1.05rem;
    font-weight: 700;
}

.pi-analysis-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pi-analysis-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.pi-analysis-meta-card {
    min-width: 0;
    margin-bottom: 0;
}

.pi-meta-list {
    margin: 18px 0 0;
}

.pi-meta-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--pi-border, #e5e7eb);
}

.pi-meta-item:first-child {
    padding-top: 0;
}

.pi-meta-item:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.pi-meta-item dt {
    margin-bottom: 5px;
    color: var(--pi-muted, #667085);
    font-size: .75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .045em;
}

.pi-meta-item dd {
    margin: 0;
    color: var(--pi-text, #101828);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.pi-meta-description {
    white-space: pre-wrap;
}

.pi-analysis-source-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.pi-analysis-source-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(160px, 240px);
    gap: 24px;
    align-items: center;
    padding: 24px;
    background: var(--pi-card, #fff);
    border: 1px solid var(--pi-border, #e5e7eb);
    border-radius: 28px;
    box-shadow: var(--pi-shadow, 0 18px 48px rgba(16, 24, 40, .07));
}

.pi-analysis-source-card h2 {
    margin: 0;
    color: var(--pi-text, #101828);
    letter-spacing: -.025em;
}

.pi-analysis-source-card .pi-product-image {
    width: 100%;
    height: 190px;
    border-radius: 18px;
    object-fit: contain;
    background: var(--pi-soft, #f8fafc);
}

.pi-analysis-url-card {
    grid-template-columns: 1fr;
    align-content: center;
}

.pi-analysis-url-card .pi-url-link {
    padding: 16px;
    border: 1px solid var(--pi-border, #e5e7eb);
    border-radius: 14px;
    background: var(--pi-soft, #f8fafc);
}

@media (max-width: 760px) {
    .pi-analysis-complete,
    .pi-analysis-waiting {
        padding: 40px 20px;
        border-radius: 22px;
    }

    .pi-analysis-meta-grid,
    .pi-analysis-source-grid,
    .pi-analysis-source-card {
        grid-template-columns: 1fr;
    }

    .pi-analysis-actions,
    .pi-analysis-actions .pi-btn {
        width: 100%;
    }

    .pi-analysis-source-card {
        padding: 18px;
        border-radius: 22px;
    }

    .pi-analysis-source-card .pi-product-image {
        height: auto;
        max-height: 280px;
    }
}
[data-analysis-watch] [hidden] {
    display: none !important;
}
