/* ============================
   Analysis Modal – shared styles
   Used by Index, TextTranslation, and Validation pages
   ============================ */

#analysisOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.25s ease;
}

#analysisModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.25s ease;
    overflow: hidden;
}

.analysis-modal-header {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #fafafa;
    gap: 15px;
}

.analysis-modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.analysis-modal-header .closeButton,
.suggestion-preview-header .closeButton {
    margin-left: auto;
    background: transparent;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: #555;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.analysis-modal-header .closeButton:hover,
.suggestion-preview-header .closeButton:hover {
    background-color: #f0f0f0;
    color: #111;
}

.best-badge-modal {
    background-color: #009548;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 4px;
}

/* A/B / multi-language Tab bar */
.analysis-tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e0e0e0;
    padding: 0 24px;
    background-color: #fafafa;
    overflow-x: auto;
}

.analysis-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.analysis-tab:hover {
    color: #333;
    background-color: #f0f0f0;
}

.analysis-tab.active {
    color: #009548;
    border-bottom-color: #009548;
    font-weight: 600;
}

/* Summary bar — shown between tab bar and body */
.analysis-summary-bar {
    padding: 10px 24px 12px;
    background-color: #f9fafb;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.analysis-summary-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.analysis-summary-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #555;
}

.analysis-summary-counts {
    display: flex;
    gap: 8px;
}

.analysis-count-badge {
    font-size: 13px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
}

.analysis-count-badge.error {
    background-color: #fdecea;
    color: #c62828;
}

.analysis-count-badge.warning {
    background-color: #fff8e1;
    color: #e65100;
}

.analysis-summary-text {
    margin: 0;
    font-size: 15px;
    color: #333;
    line-height: 1.6;
    text-align: left;
}

/* Modal body: text panel + annotations panel */
.analysis-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.analysis-text-panel {
    flex: 3.6;
    padding: 28px 32px;
    overflow: auto;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Section label (SOURCE TEXT / TRANSLATED TEXT) */
.analysis-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #999;
    margin-bottom: 8px;
}

/* Source text reference block */
.analysis-source-block {
    background-color: #f7f8fa;
    border: 1px solid #e4e6ea;
    border-left: 3px solid #b0b8c4;
    border-radius: 6px;
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.7;
    color: #555;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 160px;
    overflow-y: auto;
    flex-shrink: 0;
    margin-bottom: 24px;
}

/* Divider between source and translated */
.analysis-section-divider {
    border: none;
    border-top: 1px solid #e8e8e8;
    margin: 0 0 20px 0;
}

.analysis-text-content {
    font-size: 16px;
    line-height: 2;
    color: #222;
    white-space: pre-wrap;
    word-wrap: break-word;
    flex: 1;
}

.analysis-empty-state {
    color: #777;
    font-size: 14px;
}

.spreadsheet-table-wrapper {
    width: max-content;
    min-width: 100%;
    max-width: none;
    overflow: visible;
    background: #fff;
}

.spreadsheet-analysis-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #e4e6ea;
    border-radius: 8px;
    font-size: 13px;
}

.spreadsheet-analysis-table th,
.spreadsheet-analysis-table td {
    border-bottom: 1px solid #eceef2;
    border-right: 1px solid #eceef2;
    padding: 8px 10px;
    min-width: 140px;
    max-width: 280px;
    text-align: left;
    vertical-align: top;
    white-space: pre-wrap;
    word-break: break-word;
}

.spreadsheet-analysis-table th:last-child,
.spreadsheet-analysis-table td:last-child {
    border-right: none;
}

.spreadsheet-analysis-table tr:last-child td {
    border-bottom: none;
}

.spreadsheet-analysis-table thead th {
    position: sticky;
    top: 0;
    background: #f8f9fb;
    z-index: 1;
    font-weight: 700;
    font-size: 13px;
    color: #333;
}

.spreadsheet-uid-header {
    background: #f0f2f7;
}

.spreadsheet-uid-cell {
    font-weight: 700;
    background: #fbfcfe;
    min-width: 120px;
    max-width: 180px;
}

.spreadsheet-col-issues {
    margin-left: 6px;
    font-size: 11px;
    color: #666;
    font-weight: 600;
}

.spreadsheet-cell-issue.warning {
    background-color: rgba(255, 180, 0, 0.06);
}

.spreadsheet-cell-issue.error {
    background-color: rgba(220, 53, 69, 0.06);
}

.spreadsheet-analysis-table td .highlight {
    display: inline;
}

.spreadsheet-analysis-table .highlight-marker {
    font-size: 9px;
    width: 15px;
    height: 15px;
    line-height: 15px;
    vertical-align: middle;
    margin-right: 2px;
}

/* Highlighted text segments */
.highlight {
    padding: 1px 3px;
    border-radius: 3px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.highlight.error {
    background-color: #f8d7da;
    border-bottom: 2px solid #d9534f;
}

.highlight.warning {
    background-color: #fff3cd;
    border-bottom: 2px solid #e0a800;
}

.highlight.dimmed {
    opacity: 0.25;
}

.highlight.focused {
    outline: 2px solid #333;
    outline-offset: 1px;
}

/* Numbered markers inline with text */
.highlight-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    vertical-align: middle;
    margin-right: 2px;
    transition: opacity 0.2s;
}

.highlight-marker.error {
    background-color: #d9534f;
}

.highlight-marker.warning {
    background-color: #e0a800;
}

.highlight-marker.dimmed {
    opacity: 0.25;
}

.highlight-marker.focused {
    outline: 2px solid #333;
    outline-offset: 1px;
}

/* Annotations panel */
.analysis-annotations-panel {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #fafafa;
}

.analysis-annotations-panel h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #555;
}

.annotation-card {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: #fff;
    cursor: pointer;
    transition: box-shadow 0.2s, opacity 0.2s;
    border-left: 5px solid transparent;
    position: relative;
}

.annotation-card.error {
    border-left-color: #d9534f;
}

.annotation-card.warning {
    border-left-color: #e0a800;
}

.annotation-card:hover {
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1);
}

.annotation-card.dimmed {
    opacity: 0.25;
}

.annotation-card.focused {
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.18);
}

/* Header: number + severity badge */
.annotation-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.annotation-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.annotation-number.error {
    background-color: #d9534f;
}

.annotation-number.warning {
    background-color: #e0a800;
}

.annotation-severity-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
}

.annotation-severity-badge.error {
    background-color: #f8d7da;
    color: #721c24;
}

.annotation-severity-badge.warning {
    background-color: #fff3cd;
    color: #856404;
}

/* Highlighted word preview */
.annotation-highlight-preview {
    font-size: 16px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: inline-block;
}

.annotation-highlight-preview.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.annotation-highlight-preview.warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* Issue description */
.annotation-issue {
    font-size: 15px;
    color: #333;
    margin-bottom: 12px;
    line-height: 1.55;
}

.annotation-issue .inline-quote {
    background-color: #eef1f6;
    color: #2c3e50;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
}

/* Fix suggestion: wrong -> correct */
.annotation-fix {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.annotation-fix-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: 6px;
}

.annotation-fix-row.wrong {
    background-color: #fef2f2;
    color: #9b1c1c;
    text-decoration: line-through;
    text-decoration-color: #d9534f80;
}

.annotation-fix-row.correct {
    background-color: #f0fdf4;
    color: #166534;
}

.annotation-fix-icon {
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.annotation-fix-row.wrong .annotation-fix-icon {
    color: #d9534f;
}

.annotation-fix-row.correct .annotation-fix-icon {
    color: #009548;
}

/* Collapsible context */
.annotation-context {
    border-top: 1px solid #f0f0f0;
    padding-top: 8px;
    margin-top: 4px;
}

.annotation-context summary {
    font-size: 12px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    user-select: none;
}

.annotation-context summary:hover {
    color: #555;
}

.annotation-context-row {
    display: flex;
    gap: 8px;
    font-size: 13px;
    color: #555;
    margin-top: 6px;
    line-height: 1.4;
}

.annotation-context-label {
    font-weight: 600;
    color: #777;
    font-size: 11px;
    text-transform: uppercase;
    min-width: 75px;
    flex-shrink: 0;
    padding-top: 1px;
}

/* Interactive fix-rows (clickable accept/decline) */
.annotation-fix-row.interactive {
    cursor: pointer;
    transition: all 0.15s ease;
    border: 2px solid transparent;
    position: relative;
}

.annotation-fix-row.interactive:hover {
    border-color: #ccc;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.annotation-fix-row.wrong.interactive:hover {
    border-color: #f5c6cb;
}

.annotation-fix-row.correct.interactive:hover {
    border-color: #b7eb8f;
}

/* Active state: the chosen row gets emphasized */
.annotation-fix-row.interactive.active {
    border-color: currentColor;
    font-weight: 600;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}

/* The non-chosen row fades out */
.annotation-card.suggestion-accepted .annotation-fix-row.wrong {
    opacity: 0.35;
    text-decoration: line-through;
    text-decoration-color: #d9534f80;
}

.annotation-card.suggestion-declined .annotation-fix-row.correct {
    opacity: 0.35;
}

/* Accepted card visual state */
.annotation-card.suggestion-accepted {
    border-left: 3px solid #009548;
    background: #f0fdf4;
}

.annotation-card.suggestion-accepted .annotation-fix-row.correct {
    font-weight: 600;
}

/* Declined card visual state */
.annotation-card.suggestion-declined {
    opacity: 0.4;
    border-left: 3px solid #ccc;
}

/* Suggestion states should remain visible even when dimmed by focus */
.annotation-card.suggestion-accepted.dimmed {
    opacity: 0.55;
}

.annotation-card.suggestion-declined.dimmed {
    opacity: 0.25;
}

/* Status indicator badge on accepted/declined cards */
.annotation-card.suggestion-accepted::after {
    content: '\2713 Accepted';
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #166534;
    background: #dcfce7;
    padding: 2px 8px;
    border-radius: 4px;
}

.annotation-card.suggestion-declined::after {
    content: '\2717 Declined';
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #9b1c1c;
    background: #fee2e2;
    padding: 2px 8px;
    border-radius: 4px;
}

/* Apply suggestions button */
.apply-suggestions-btn {
    display: block;
    width: auto;
    margin: 12px 16px;
    padding: 10px 24px;
    background: #009548;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.apply-suggestions-btn:hover:not(:disabled) {
    background: #007a3a;
}

.apply-suggestions-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.apply-suggestions-btn.applied {
    background: #166534;
}

.apply-suggestions-btn.partial {
    background: #b45309;
}

/* ============================
   Suggestion Preview Overlay
   ============================ */

.suggestion-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.97);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.suggestion-preview-overlay.visible {
    opacity: 1;
}

.suggestion-preview-panel {
    width: 95%;
    max-width: 1100px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

.suggestion-preview-header {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #fafafa;
}

.suggestion-preview-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
    flex: 1;
}

.suggestion-preview-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 24px;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    font-size: 13px;
    color: #92400e;
    line-height: 1.5;
}

.suggestion-preview-notice-icon {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.suggestion-preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: row;
    gap: 24px;
}

.suggestion-preview-text-side {
    flex: 3;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.suggestion-preview-changes-side {
    flex: 1.2;
    min-width: 220px;
    max-width: 320px;
}

.suggestion-preview-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.suggestion-preview-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #999;
}

.suggestion-preview-text {
    padding: 16px;
    border: 1px solid #e4e6ea;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    color: #333;
    background: #f9fafb;
    flex: 1;
}

.suggestion-preview-text.corrected {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.preview-change-highlight {
    background-color: #dcfce7;
    border-bottom: 2px solid #009548;
    padding: 1px 3px;
    border-radius: 3px;
    color: #166534;
    font-weight: 600;
}

.suggestion-preview-changes {
    border-top: none;
    border-left: 1px solid #e0e0e0;
    padding-left: 20px;
    padding-top: 0;
}

.suggestion-preview-changes h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #777;
}

.suggestion-preview-change-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
}

.suggestion-preview-change-item .from {
    text-decoration: line-through;
    color: #9b1c1c;
    background: #fee2e2;
    padding: 1px 6px;
    border-radius: 3px;
}

.suggestion-preview-change-item .arrow {
    color: #999;
}

.suggestion-preview-change-item .to {
    color: #166534;
    background: #dcfce7;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.suggestion-preview-change-item .row-label {
    font-size: 11px;
    color: #666;
    background: #f3f4f6;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

.suggestion-preview-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
}

.suggestion-preview-btn {
    padding: 10px 24px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.suggestion-preview-btn.cancel {
    background: #fff;
    color: #555;
}

.suggestion-preview-btn.cancel:hover {
    background: #f5f5f5;
}

.suggestion-preview-btn.confirm {
    background: #009548;
    color: #fff;
    border-color: #009548;
    font-weight: 600;
}

.suggestion-preview-btn.confirm:hover {
    background: #007a3a;
}

.suggestion-preview-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================
   Toast Notification
   ============================ */

.validation-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 90vw;
    text-align: center;
}

.validation-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.validation-toast--success {
    background: #166534;
}

.validation-toast--warning {
    background: #b45309;
}
