/* Analysis section — print-oriented analysis form with write-in spaces.
   Moved out of AnalysisSection.razor inline <style> (global file is the reliable home for
   print-composed components; scoped .razor.css does not reach them). Status colors use
   --pp-status-* tokens from tailwind.css; the form renders inside the [data-force-light] sheet,
   so tokens resolve to their light values (zero behavior change).

   All rules are SCOPED under the .analysis-form root: generic class names (.form-header,
   .type-badge, .status-label/.status-text, .section-indicator, .task-block, .lot-info,
   .vessel-info, .highlight-yellow, .reorder-*) are shared with Custom/Topping sections and the
   already-global workorder-header.css/custom-section.css. Scoping (higher specificity than the
   unscoped global rules) prevents cross-file collisions while keeping behavior identical. */

.analysis-form {
    background: var(--pp-bg-white);
    border: var(--pp-border-heavy);
    font-family: Arial, sans-serif;
    font-size: var(--pp-font-size-sm);
    page-break-inside: avoid;
}

.analysis-form .analysis-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--pp-spacing-xl);
    color: var(--pp-text-muted);
}

/* Form Header */
.analysis-form .form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--pp-bg-header);
    border-bottom: var(--pp-border);
    padding: var(--pp-spacing-sm) var(--pp-spacing-lg);
}

.analysis-form .job-label {
    display: flex;
    align-items: center;
    gap: var(--pp-spacing-sm);
    font-size: var(--pp-font-size-md);
}

.analysis-form .type-badge {
    display: inline-block;
    padding: 2px var(--pp-spacing-sm);
    background: var(--pp-status-info-bg);
    color: var(--pp-status-info-text);
    border-radius: var(--pp-radius-sm);
    font-size: var(--pp-font-size-xs);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.analysis-form .status-label {
    font-size: var(--pp-font-size-md);
}

.analysis-form .status-text {
    color: var(--pp-text-secondary);
}

.analysis-form .section-indicator {
    margin-left: var(--pp-spacing-md, 8px);
    padding: 2px 8px;
    background: #e2e8f0;
    color: #475569;
    font-size: var(--pp-font-size-xs, 11px);
    font-weight: 600;
    border-radius: 4px;
}

/* Reorder Controls */
.analysis-form .reorder-controls {
    display: flex;
    align-items: center;
    gap: var(--pp-spacing-sm);
    padding: var(--pp-spacing-xs) var(--pp-spacing-lg);
    background: #f0f9ff;
    border-bottom: var(--pp-border-light);
}

.analysis-form .reorder-btn,
.analysis-form .reset-btn {
    padding: 4px 10px;
    font-size: var(--pp-font-size-xs);
    font-weight: 600;
    border: 1px solid #0ea5e9;
    border-radius: var(--pp-radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.analysis-form .reorder-btn {
    background: #0ea5e9;
    color: white;
}

.analysis-form .reorder-btn:hover {
    background: #0284c7;
}

.analysis-form .reset-btn {
    background: white;
    color: #0ea5e9;
}

.analysis-form .reset-btn:hover {
    background: #f0f9ff;
}

.analysis-form .reorder-arrows {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.analysis-form .arrow-btn {
    width: 24px;
    height: 20px;
    padding: 0;
    font-size: 10px;
    background: #e0e7ff;
    border: 1px solid #6366f1;
    border-radius: 3px;
    cursor: pointer;
    color: #4338ca;
    transition: background 0.15s;
}

.analysis-form .arrow-btn:hover:not(:disabled) {
    background: #c7d2fe;
}

.analysis-form .arrow-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.analysis-form .task-block.reorder-active {
    position: relative;
    padding-left: 36px;
}

/* Sticker Option */
.analysis-form .sticker-option {
    display: flex;
    align-items: center;
    gap: var(--pp-spacing-sm);
    padding: var(--pp-spacing-sm) var(--pp-spacing-lg);
    background: #f0fdf4;
    border-bottom: var(--pp-border-light);
    font-size: var(--pp-font-size-sm);
}

.analysis-form .sticker-check-label {
    display: inline-flex;
    align-items: center;
    gap: var(--pp-spacing-sm);
    cursor: pointer;
    user-select: none;
}

.analysis-form .sticker-check-label input[type=checkbox] {
    width: 14px;
    height: 14px;
    accent-color: #16a34a;
    cursor: pointer;
}

.analysis-form .sticker-label-text {
    font-weight: 600;
    color: var(--pp-status-success-text);
}

.analysis-form .sticker-toggle-link {
    background: transparent;
    border: none;
    padding: 0;
    margin-left: auto;
    color: var(--pp-status-success-text);
    font-size: var(--pp-font-size-xs);
    text-decoration: underline;
    cursor: pointer;
}

.analysis-form .sticker-toggle-link:hover {
    color: #14532d;
}

/* Task Block */
.analysis-form .task-block {
    border-bottom: var(--pp-border);
    /* Keep each lot's analysis block intact when the section overflows a page */
    break-inside: avoid;
    page-break-inside: avoid;
}

.analysis-form .task-block:last-child {
    border-bottom: none;
}

/* Lot Header */
.analysis-form .lot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px var(--pp-spacing-lg);
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    gap: var(--pp-spacing-xs);
}

.analysis-form .lot-info {
    display: flex;
    align-items: center;
    gap: var(--pp-spacing-xs);
    font-size: var(--pp-font-size-sm);
}

.analysis-form .highlight-yellow {
    background: var(--pp-bg-highlight);
    padding: 1px var(--pp-spacing-xs);
    font-weight: bold;
    color: #000;
}

.analysis-form .lot-details {
    color: var(--pp-text-secondary);
}

.analysis-form .lot-appellation {
    color: var(--pp-text-muted);
    font-size: var(--pp-font-size-sm);
}

.analysis-form .task-badges {
    display: flex;
    gap: var(--pp-spacing-sm);
}

.analysis-form .panel-badge {
    padding: 2px var(--pp-spacing-sm);
    background: var(--pp-bg-card);
    border-radius: var(--pp-radius-sm);
    font-size: var(--pp-font-size-xs);
    font-weight: 600;
    color: var(--pp-text-secondary);
}

.analysis-form .source-badge {
    padding: 2px var(--pp-spacing-sm);
    border-radius: var(--pp-radius-sm);
    font-size: var(--pp-font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
}

.analysis-form .source-badge--lab {
    background: var(--pp-status-info-bg);
    color: var(--pp-status-info-text);
}

.analysis-form .source-badge--field {
    background: var(--pp-status-success-bg);
    color: var(--pp-status-success-text);
}

/* Vessel Info */
.analysis-form .vessel-info {
    padding: 2px var(--pp-spacing-lg);
    font-size: var(--pp-font-size-xs);
    color: var(--pp-text-secondary);
    background: var(--pp-bg-white);
}

/* Tests Grid - Compact horizontal layout */
.analysis-form .tests-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: var(--pp-spacing-sm) var(--pp-spacing-lg);
    background: var(--pp-bg-white);
}

.analysis-form .test-item {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    font-size: var(--pp-font-size-sm);
    padding: 2px 6px;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    background: #fafafa;
}

.analysis-form .test-item.test-completed {
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.analysis-form .test-label {
    font-weight: 600;
    color: #374151;
    font-size: var(--pp-font-size-xs);
}

.analysis-form .test-result {
    font-weight: 700;
    color: var(--pp-status-info-text);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: center;
}

.analysis-form .test-result .result-blank {
    color: #9ca3af;
    font-weight: normal;
}

.analysis-form .test-unit {
    font-size: 9px;
    color: var(--pp-text-muted);
}

/* Print styles */
@media print {
    .analysis-form {
        border: 2px solid #000 !important;
        page-break-inside: avoid;
    }

    .analysis-form .form-header {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .analysis-form .highlight-yellow {
        background: #ffeb3b !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .analysis-form .test-item {
        border: 1px solid #666 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .analysis-form .test-item.test-completed {
        background: #ecfdf5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .analysis-form .sticker-option {
        background: #f0fdf4 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .analysis-form .type-badge {
        background: var(--pp-status-info-bg) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .analysis-form .lot-header {
        background: #f8fafc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
