/* Prepress Quality Checker Pro v4.0 — Automatic AI Workflow */

* { box-sizing: border-box; }

#prepress-checker-app {
    max-width: 1400px;
    margin: 40px auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #333;
}

/* ---------- Header ---------- */
.prepress-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 40px;
    border-radius: 14px;
    margin-bottom: 36px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, .3);
}
.prepress-header h1 { margin: 0 0 8px; font-size: 2.2em; font-weight: 700; }
.prepress-header p { margin: 0; opacity: .95; font-size: 1.05em; }

.ai-status-badge {
    display: inline-block; margin-top: 14px; padding: 7px 16px;
    border-radius: 20px; font-size: .85em; font-weight: 600;
    background: rgba(255,255,255,.18); backdrop-filter: blur(4px);
}
.ai-status-badge.ai-online strong { color: #6ee7b7; }
.ai-status-badge.ai-offline { opacity: .85; }

.engine-chip {
    display: inline-block; margin-left: 10px; padding: 3px 12px;
    border-radius: 14px; font-size: .72em; font-weight: 700; vertical-align: middle;
}
.engine-ai  { background: #ede9fe; color: #6d28d9; }
.engine-std { background: #f1f5f9; color: #475569; }

/* ---------- Layout ---------- */
.prepress-main-container {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 28px;
    margin-bottom: 32px;
}
.prepress-section {
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    border: 1px solid #e5e7eb;
    margin-bottom: 28px;
}
.prepress-section h2 {
    margin: 0 0 18px;
    font-size: 1.25em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}
.prepress-section h3 { margin: 0 0 14px; font-size: 1.05em; }
.prepress-section h3 em { color: #667eea; font-style: normal; }

/* ---------- Upload ---------- */
.upload-zone {
    border: 3px dashed #667eea;
    border-radius: 12px;
    padding: 44px 20px;
    text-align: center;
    background: linear-gradient(135deg, #f8f9ff, #f0f2ff);
    cursor: pointer;
    transition: all .25s;
    margin-bottom: 18px;
}
.upload-zone:hover { border-color: #764ba2; transform: translateY(-2px); }
.upload-zone:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 3px; }
.upload-zone.dragover { background: #e8e9ff; transform: scale(1.01); border-color: #764ba2; }
.upload-icon { font-size: 3em; margin-bottom: 10px; }
.upload-zone p { margin: 8px 0; font-size: 1.05em; font-weight: 500; }
.upload-zone small { color: #666; }
#fileInput { display: none; }

/* ---------- File grid ---------- */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
}
.file-card {
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: all .2s;
    position: relative;
    text-align: center;
}
.file-card:hover { border-color: #667eea; transform: translateY(-3px); box-shadow: 0 4px 12px rgba(102,126,234,.18); }
.file-card.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #f8f9ff, #f0f2ff);
    box-shadow: 0 6px 16px rgba(102,126,234,.28);
}
.file-thumbnail {
    width: 100%; height: 110px;
    border-radius: 8px; background: #f0f0f0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; margin-bottom: 8px;
}
.file-thumbnail img { max-width: 100%; max-height: 100%; object-fit: cover; }
.no-thumb { font-size: 2.2em; }
.file-name { font-weight: 600; font-size: .8em; word-break: break-word; margin-bottom: 3px; }
.file-dims { font-size: .72em; color: #666; }
.remove-btn {
    position: absolute; top: 5px; right: 5px;
    background: #ef4444; color: #fff; border: none;
    width: 22px; height: 22px; border-radius: 50%;
    cursor: pointer; font-size: 13px; line-height: 1;
    opacity: 0; transition: opacity .15s;
}
.file-card:hover .remove-btn { opacity: 1; }

/* ---------- Instant analysis card ---------- */
.file-info-card {
    background: linear-gradient(135deg, #f8f9ff, #f0f2ff);
    border-radius: 12px;
    padding: 18px;
    border-left: 4px solid #667eea;
    margin-bottom: 18px;
}
.file-info-header {
    display: flex; align-items: center; gap: 14px; margin-bottom: 16px;
}
.file-info-header img {
    width: 56px; height: 56px; object-fit: cover;
    border-radius: 8px; border: 1px solid #ddd;
}
.file-info-header h3 { margin: 0 0 3px; font-size: 1em; word-break: break-all; }
.file-meta { font-size: .82em; color: #666; }
.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.info-item { display: flex; flex-direction: column; }
.info-label { font-size: .75em; color: #666; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .3px; }
.info-value { font-weight: 700; font-size: .95em; }

/* Quality chips */
.q-chip {
    display: inline-block; padding: 2px 10px; border-radius: 20px;
    font-size: .85em; font-weight: 700;
}
.q-excellent { background: #dcfce7; color: #065f46; }
.q-good      { background: #fef3c7; color: #92400e; }
.q-fair      { background: #ffedd5; color: #9a3412; }
.q-poor      { background: #fee2e2; color: #7f1d1d; }

/* ---------- Size inputs ---------- */
.print-size-card {
    background: #fff; border: 1px solid #e5e7eb;
    border-radius: 12px; padding: 18px; margin-bottom: 18px;
}
.unit-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.unit-btn {
    flex: 1; padding: 9px; border: 2px solid #e5e7eb; background: #fff;
    border-radius: 8px; cursor: pointer; font-weight: 600; color: #666;
    transition: all .15s;
}
.unit-btn:hover { border-color: #667eea; color: #667eea; }
.unit-btn.active { background: #667eea; border-color: #667eea; color: #fff; }

.size-inputs {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: end;
}
.linked-icon {
    font-size: 1.2em; padding-bottom: 12px; cursor: help;
    color: #667eea;
}
.size-input-group { display: flex; flex-direction: column; }
.size-input-group label { font-weight: 600; margin-bottom: 6px; font-size: .9em; }
.unit-suffix { color: #999; font-weight: 400; }
.size-input-group input {
    padding: 12px; border: 2px solid #e5e7eb; border-radius: 8px;
    font-size: 1.05em; transition: border-color .15s;
}
.size-input-group input:focus {
    outline: none; border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,.12);
}
.aspect-note {
    margin: 12px 0 0; font-size: .82em; color: #667eea;
    background: #f8f9ff; padding: 8px 12px; border-radius: 8px;
}

/* ---------- Live quality ---------- */
.quality-card {
    background: #fff; border: 1px solid #e5e7eb;
    border-radius: 12px; padding: 18px; margin-bottom: 18px;
}
.quality-display {
    border-radius: 10px; padding: 20px; text-align: center;
    margin-bottom: 14px; transition: all .3s;
    background: #f8f9ff; border: 2px solid #e5e7eb;
}
.quality-display.excellent { background: linear-gradient(135deg,#f0fdf4,#dcfce7); border-color: #10b981; }
.quality-display.good      { background: linear-gradient(135deg,#fffbf0,#fef3c7); border-color: #f59e0b; }
.quality-display.fair      { background: linear-gradient(135deg,#fff7ed,#ffedd5); border-color: #fb923c; }
.quality-display.poor      { background: linear-gradient(135deg,#fef2f2,#fee2e2); border-color: #ef4444; }
.quality-badge { font-size: 1.2em; font-weight: 700; }
.quality-dpi { font-size: 2.6em; font-weight: 800; color: #4c51bf; margin: 8px 0; }
.quality-dpi span { font-size: .45em; }
.quality-description { font-size: .95em; }

.dimensions-summary { background: #f9f9f9; border-radius: 8px; padding: 12px 14px; }
.summary-row {
    display: flex; justify-content: space-between;
    padding: 7px 0; border-bottom: 1px solid #eee; font-size: .92em;
}
.summary-row:last-child { border: none; }
.summary-row strong { color: #4c51bf; }

/* ---------- AI buttons ---------- */
.ai-actions { display: flex; gap: 12px; }

/* All selectors ID-scoped (#prepress-checker-app) so WordPress theme
   button rules can never override them, and key properties are locked
   with !important as a final defense against aggressive themes. */
#prepress-checker-app .btn {
    padding: 13px 22px;
    border: none !important;
    border-radius: 9px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
    text-align: center;
    text-decoration: none !important;
    text-shadow: none !important;
    box-shadow: none;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
}
#prepress-checker-app .btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}
#prepress-checker-app .btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2) !important;
    color: #fff !important;
}
#prepress-checker-app .btn-primary:hover:not(:disabled) {
    box-shadow: 0 8px 16px rgba(102,126,234,.3);
    transform: translateY(-2px);
    color: #fff !important;
}
#prepress-checker-app .btn-secondary {
    background: #e5e7eb !important;
    color: #1f2937 !important;
}
#prepress-checker-app .btn-secondary:hover:not(:disabled) { background: #d1d5db !important; }

/* Dark red theme — AI Recommend */
#prepress-checker-app .btn-ai {
    flex: 1;
    background: linear-gradient(135deg, #7f1d1d, #991b1b) !important;
    color: #ffffff !important;
    border: 1px solid #7f1d1d !important;
}
#prepress-checker-app .btn-ai:hover:not(:disabled) {
    background: linear-gradient(135deg, #991b1b, #b91c1c) !important;
    box-shadow: 0 8px 16px rgba(153,27,27,.35);
    transform: translateY(-2px);
    color: #ffffff !important;
}

/* Dark red theme (deeper accent) — AI Auto Fix */
#prepress-checker-app .btn-ai-fix {
    flex: 1;
    background: linear-gradient(135deg, #991b1b, #c2410c) !important;
    color: #ffffff !important;
    border: 1px solid #991b1b !important;
}
#prepress-checker-app .btn-ai-fix:hover:not(:disabled) {
    background: linear-gradient(135deg, #b91c1c, #ea580c) !important;
    box-shadow: 0 8px 16px rgba(194,65,12,.35);
    transform: translateY(-2px);
    color: #ffffff !important;
}

/* Keyboard focus ring for all buttons (accessibility) */
#prepress-checker-app .btn:focus-visible {
    outline: 3px solid #fca5a5;
    outline-offset: 2px;
}
#prepress-checker-app .btn-primary:focus-visible,
#prepress-checker-app .btn-secondary:focus-visible {
    outline-color: #a5b4fc;
}

#prepress-checker-app .btn-large { font-size: 1.15em; padding: 16px 30px; width: 100%; }
.btn-mini {
    margin-top: 8px; padding: 6px 14px; font-size: .8em;
    background: #667eea; color: #fff; border: none; border-radius: 6px;
    cursor: pointer; font-weight: 600;
}
.btn-mini:hover { background: #5a67d8; }

/* ---------- AI Recommend panel ---------- */
.recommend-panel {
    margin-top: 18px; border-radius: 12px; overflow: hidden;
    border: 1px solid #e5e7eb;
}
.rec-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 18px; flex-wrap: wrap; gap: 12px;
}
.rec-header.rec-suitable { background: linear-gradient(135deg,#f0fdf4,#dcfce7); }
.rec-header.rec-adjust   { background: linear-gradient(135deg,#fffbf0,#fef3c7); }
.rec-verdict { font-size: 1.1em; font-weight: 800; }
.rec-confidence { display: flex; align-items: center; gap: 10px; }
.confidence-label { font-size: .78em; color: #666; font-weight: 600; }
.confidence-bar {
    width: 110px; height: 10px; background: #e5e7eb;
    border-radius: 6px; overflow: hidden;
}
.confidence-fill {
    height: 100%; border-radius: 6px;
    background: linear-gradient(90deg,#06b6d4,#10b981);
    transition: width .6s ease;
}
.confidence-pct { font-weight: 800; color: #0d9488; }
.rec-body { padding: 18px; background: #fff; }
.rec-quality { margin-bottom: 10px; font-size: .95em; }
.rec-reason {
    background: #f8f9ff; padding: 14px; border-radius: 8px;
    border-left: 3px solid #667eea; line-height: 1.6; font-size: .93em;
    margin: 0 0 16px;
}
.rec-sizes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.rec-size-box {
    padding: 14px; border-radius: 10px; border: 2px solid #e5e7eb;
    display: flex; flex-direction: column; gap: 4px; text-align: center;
}
.rec-size-box.recommended { border-color: #10b981; background: #f0fdf4; }
.rec-size-label { font-size: .75em; color: #666; text-transform: uppercase; font-weight: 700; }
.rec-size-box strong { font-size: 1.2em; }
.rec-size-dpi { font-size: .85em; color: #667eea; font-weight: 700; }
.rec-apps { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rec-apps-label { font-weight: 700; font-size: .88em; }
.app-chip {
    background: #f0f2ff; color: #4c51bf; padding: 5px 12px;
    border-radius: 20px; font-size: .82em; font-weight: 600;
}

/* ---------- Processing ---------- */
.processing-status {
    text-align: center; padding: 50px 20px;
}
.spinner {
    width: 46px; height: 46px; margin: 0 auto 18px;
    border: 4px solid #e5e7eb; border-top-color: #667eea;
    border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#processingStep { font-size: 1.05em; font-weight: 600; color: #4c51bf; }

.enhancement-list {
    background: linear-gradient(135deg,#faf5ff,#f3e8ff);
    border-radius: 12px; padding: 18px; margin-bottom: 22px;
    border-left: 4px solid #8b5cf6;
}
.enhancement-list h4 { margin: 0 0 10px; }
.enhancement-list ul { margin: 0; padding-left: 4px; list-style: none; }
.enhancement-list li { padding: 4px 0; font-size: .92em; }

/* ---------- Before / After ---------- */
.before-after-container {
    display: grid; grid-template-columns: 1fr auto 1fr;
    gap: 18px; align-items: start;
}
.preview-panel h4 { text-align: center; margin: 0 0 10px; }
.preview-image {
    width: 100%; height: 340px; background:
        repeating-conic-gradient(#f0f0f0 0% 25%, #fafafa 0% 50%) 0 / 20px 20px;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    overflow: hidden; border: 2px solid #e5e7eb; margin-bottom: 10px;
}
.preview-image img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.preview-info {
    background: #f9f9f9; padding: 10px 12px; border-radius: 8px;
    font-size: .88em; text-align: center; line-height: 1.6;
}
.upscale-badge {
    display: inline-block; margin-top: 4px; padding: 3px 10px;
    background: #dcfce7; color: #065f46; border-radius: 12px;
    font-weight: 700; font-size: .85em;
}
.upscale-badge.no-upscale { background: #f0f2ff; color: #4c51bf; }
.comparison-divider {
    display: flex; align-items: center; height: 340px;
    font-size: 1.6em; color: #667eea; font-weight: 800;
}
.zoom-hint { text-align: center; color: #888; font-size: .85em; margin: 10px 0 0; }

/* ---------- Verification report ---------- */
.verification-report {
    margin-top: 26px; background: linear-gradient(135deg,#f0fdfa,#ccfbf1);
    border-radius: 12px; padding: 22px; border-left: 4px solid #0d9488;
}
.verification-report h3 { margin: 0 0 16px; }
.report-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
    margin-bottom: 16px;
}
.report-item {
    background: #fff; border-radius: 8px; padding: 12px;
    display: flex; flex-direction: column; gap: 4px;
}
.report-label { font-size: .72em; color: #666; text-transform: uppercase; font-weight: 700; letter-spacing: .3px; }
.report-value { font-weight: 800; font-size: 1em; }
.report-apps { padding-top: 4px; }

/* ---------- Download ---------- */
.download-section {
    margin-top: 26px; background: linear-gradient(135deg,#f8f9ff,#f0f2ff);
    border-radius: 12px; padding: 22px;
}
.download-section h3 { margin: 0 0 14px; }
.pre-download-summary {
    display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px;
}
.download-format {
    display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 12px 16px; margin-bottom: 16px;
}
.download-format .format-label { font-weight: 700; font-size: .9em; }
.download-format label {
    display: flex; align-items: center; gap: 6px;
    font-weight: 600; font-size: .92em; cursor: pointer; margin: 0;
}
.download-format input[type="radio"] { accent-color: #991b1b; cursor: pointer; }
.download-format small { color: #888; font-weight: 400; }
.summary-chip {
    background: #fff; border: 1px solid #e5e7eb;
    padding: 8px 14px; border-radius: 20px;
    font-size: .88em; font-weight: 700;
}
.download-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.checkout-section {
    margin-top: 24px; padding-top: 24px; border-top: 2px solid #e5e7eb;
}

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: #999; }
.empty-state-icon { font-size: 2.8em; margin-bottom: 12px; }
.empty-state p { margin: 0; font-size: 1.05em; line-height: 1.7; }

/* ---------- Zoom modal ---------- */
.zoom-modal {
    position: fixed; inset: 0; z-index: 99999;
    background: rgba(0,0,0,.88);
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out;
}
.zoom-modal img {
    max-width: 94vw; max-height: 92vh; object-fit: contain;
    border-radius: 8px;
}
.zoom-close {
    position: absolute; top: 18px; right: 28px;
    color: #fff; font-size: 2.4em; cursor: pointer; line-height: 1;
}

/* ---------- Toasts ---------- */
#toastContainer {
    position: fixed; bottom: 24px; right: 24px; z-index: 99998;
    display: flex; flex-direction: column; gap: 10px;
}
.toast {
    background: #333; color: #fff; padding: 12px 20px;
    border-radius: 10px; font-size: .92em; font-weight: 600;
    opacity: 0; transform: translateY(14px);
    transition: all .3s ease; max-width: 320px;
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #059669; }
.toast-error   { background: #dc2626; }
.toast-info    { background: #4c51bf; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .prepress-main-container { grid-template-columns: 1fr; }
    .report-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    #prepress-checker-app { padding: 12px; }
    .prepress-header { padding: 24px; }
    .prepress-header h1 { font-size: 1.6em; }
    .prepress-section { padding: 18px; }
    .info-grid { grid-template-columns: repeat(2, 1fr); }
    .before-after-container { grid-template-columns: 1fr; }
    .comparison-divider { height: auto; justify-content: center; transform: rotate(90deg); }
    .preview-image { height: 260px; }
    .rec-sizes { grid-template-columns: 1fr; }
    .download-buttons { grid-template-columns: 1fr; }
    .ai-actions { flex-direction: column; }
}
@media (max-width: 480px) {
    .info-grid { grid-template-columns: 1fr; }
    .report-grid { grid-template-columns: 1fr; }
    .files-grid { grid-template-columns: repeat(2, 1fr); }
    .size-inputs { grid-template-columns: 1fr; }
    .linked-icon { display: none; }
}
