/* === VCE TRANSLATOR STYLES & THEME VARIABLES === */

/* 1. Default variables (Light theme by default) */
#vce-app,
#vce-app[data-theme="light"],
.vce-modal-overlay {
    --vce-bg: #f4f6f8;
    --vce-panel: #ffffff;
    --vce-text: #2c3338;
    --vce-text-muted: #646970;
    --vce-border: #dcdcde;
    --vce-primary: #1d2327;
    --vce-primary-hover: #3c434a;
    --vce-success: #008a20;
    --vce-warning: #dba617;
    --vce-danger: #d63638;
    --vce-var-bg: #f0f0f0;
    --vce-var-text: #2c3338;
    --vce-glos-border: #8c8f94;
    --vce-highlight-bg: #ffe399;
    --vce-highlight-text: #000000;
    --vce-diff-ins-bg: #dafbe1;
    --vce-diff-ins-text: #1a7f37;
    --vce-diff-del-bg: #ffebe9;
    --vce-diff-del-text: #cf222e;
    --vce-modal-backdrop: rgba(15, 23, 42, 0.4);
    --vce-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --vce-modal-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.15);
    
    /* Button styles - Light theme */
    --vce-btn-bg: #eaeaea;
    --vce-btn-hover: #dcdcdc;
    --vce-btn-text: #2c3338;
    --vce-btn-border: #ccd0d4;
    --vce-btn-primary-text: #ffffff;
}

/* 2. Global dark theme (Twenty Twenty-Five) */
body.vce-dark-theme {
    --wp--preset--color--base: #18181b !important; 
    --wp--preset--color--contrast: #f4f4f5 !important;
    --wp--preset--color--accent-1: #a1a1aa !important;
}

/* 3. Guaranteed recalculation of translator variables when dark theme is active on body.
   The guard selector completely prevents conflicts with old data-theme attributes */
body.vce-dark-theme #vce-app,
body.vce-dark-theme #vce-app[data-theme="dark"],
body.vce-dark-theme #vce-app[data-theme="light"],
body.vce-dark-theme .vce-modal-overlay {
    --vce-bg: #1e1e1e;
    --vce-panel: #2d2d2d;
    --vce-text: #e0e0e0;
    --vce-text-muted: #888888;
    --vce-border: #444444;
    --vce-primary: #f4f4f5;
    --vce-primary-hover: #d4d4d8;
    --vce-success: #46b450;
    --vce-warning: #ffb900;
    --vce-danger: #dc3232;
    --vce-var-bg: #3f3f46;
    --vce-var-text: #f4f4f5;
    --vce-glos-border: #71717a;
    --vce-highlight-bg: #ffd54f;
    --vce-highlight-text: #000000;
    --vce-diff-ins-bg: #1f3b25;
    --vce-diff-ins-text: #56d364;
    --vce-diff-del-bg: #441c21;
    --vce-diff-del-text: #ff7b72;
    --vce-modal-backdrop: rgba(0, 0, 0, 0.75);
    --vce-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.5), 0 1px 2px -1px rgba(0, 0, 0, 0.5);
    --vce-modal-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    
    /* Button styles - Dark theme */
    --vce-btn-bg: #3f3f46;
    --vce-btn-hover: #52525b;
    --vce-btn-text: #f4f4f5;
    --vce-btn-border: #52525b;
    --vce-btn-primary-text: #18181b;
}

/* === BASE STYLING === */
#vce-app {
    background: var(--vce-bg);
    color: var(--vce-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 16px;
    padding: 24px;
    border-radius: 12px;
    box-sizing: border-box;
    box-shadow: var(--vce-shadow);
    transition: background 0.3s, color 0.3s;
}

#vce-app * {
    box-sizing: border-box;
}

.vce-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.vce-logo {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--vce-primary), var(--vce-success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.vce-toolbar, .vce-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    background: var(--vce-panel);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--vce-border);
    flex-wrap: wrap;
    align-items: center;
    box-shadow: var(--vce-shadow);
}

.vce-panel {
    background: var(--vce-panel);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--vce-border);
    margin-bottom: 24px;
    box-shadow: var(--vce-shadow);
}

.vce-input, #vce-app select, #vce-app textarea {
    padding: 10px 14px;
    border: 1px solid var(--vce-border);
    background: var(--vce-bg);
    color: var(--vce-text);
    border-radius: 6px;
    font-size: 15px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.vce-input:focus, #vce-app select:focus, #vce-app textarea:focus {
    border-color: var(--vce-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(100, 100, 100, 0.2);
}

textarea.vce-auto-resize {
    min-height: 80px;
    overflow-y: hidden;
    resize: none;
    line-height: 1.5;
}

.vce-btn {
    padding: 10px 20px;
    border: 1px solid var(--vce-btn-border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    background: var(--vce-btn-bg);
    color: var(--vce-btn-text);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.vce-btn:hover {
    background: var(--vce-btn-hover);
    border-color: var(--vce-btn-border);
}

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

.vce-btn-primary {
    background: var(--vce-primary);
    color: var(--vce-btn-primary-text);
    border-color: var(--vce-primary);
}

.vce-btn-primary:hover {
    background: var(--vce-primary-hover);
    border-color: var(--vce-primary-hover);
}

.vce-btn-success {
    background: var(--vce-success);
    color: #ffffff;
    border-color: var(--vce-success);
}

.vce-btn-success:hover {
    filter: brightness(0.9);
}

.vce-btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* === CARD LAYOUT === */
.vce-card {
    background: var(--vce-panel);
    border: 1px solid var(--vce-border);
    border-radius: 8px;
    margin-bottom: 20px;
    padding: 24px;
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    box-shadow: var(--vce-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.vce-card-left, .vce-card-right {
    flex: 1;
    min-width: 320px;
}

.vce-key {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    color: var(--vce-text-muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.vce-source-text {
    font-size: 18px;
    font-weight: 500;
    line-height: 1.6;
    margin-bottom: 16px;
}

.vce-context-box {
    font-size: 14px;
    background: var(--vce-bg);
    padding: 12px 16px;
    border-left: 4px solid var(--vce-warning);
    border-radius: 0 6px 6px 0;
    margin-bottom: 16px;
}

/* === HIGHLIGHTS === */
.vce-var {
    background: var(--vce-var-bg);
    color: var(--vce-var-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 14px;
}

.vce-glos-hl {
    border-bottom: 2px dashed var(--vce-glos-border);
    cursor: help;
    font-weight: 500;
}

.vce-search-highlight {
    background-color: var(--vce-highlight-bg);
    color: var(--vce-highlight-text);
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
}

/* === TABLES & GLOSSARY === */
.vce-glossary-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.vce-glossary-table th, .vce-glossary-table td {
    border: 1px solid var(--vce-border);
    padding: 10px 14px;
    text-align: left;
    font-size: 15px;
}

.vce-glossary-table th {
    background: var(--vce-bg);
    font-weight: 600;
}

.vce-suggestion {
    background: var(--vce-bg);
    padding: 12px;
    border-radius: 6px;
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--vce-border);
}

.vce-sug-text {
    font-size: 16px;
    flex: 1;
    margin-right: 16px;
}

.vce-sug-votes {
    display: flex;
    gap: 8px;
}

.vce-pagination {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
    align-items: center;
}

.vce-loader {
    text-align: center;
    padding: 30px;
    font-size: 18px;
    font-weight: bold;
    color: var(--vce-text-muted);
}

.vce-footer-credits {
    text-align: center;
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--vce-border);
    font-size: 13px;
    color: var(--vce-text-muted);
}

.vce-footer-credits a {
    color: var(--vce-primary);
    text-decoration: none;
    font-weight: 600;
}

.vce-footer-credits a:hover {
    text-decoration: underline;
}

/* === HISTORY & DIFFS === */
.vce-history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.vce-history-card {
    background: var(--vce-panel);
    border: 1px solid var(--vce-border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    box-shadow: var(--vce-shadow);
}

.vce-history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--vce-text-muted);
    flex-wrap: wrap;
    gap: 6px;
}

.vce-history-author {
    font-weight: 600;
    color: var(--vce-text);
}

.vce-history-badge {
    background: var(--vce-bg);
    border: 1px solid var(--vce-border);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.vce-diff {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    background: var(--vce-bg);
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--vce-border);
}

.vce-diff del {
    background-color: var(--vce-diff-del-bg);
    color: var(--vce-diff-del-text);
    text-decoration: line-through;
    padding: 0 4px;
    border-radius: 3px;
}

.vce-diff ins {
    background-color: var(--vce-diff-ins-bg);
    color: var(--vce-diff-ins-text);
    text-decoration: none;
    padding: 0 4px;
    border-radius: 3px;
}

.vce-history-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

/* === CUSTOM MODAL SYSTEM STYLES === */
.vce-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--vce-modal-backdrop);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 20px;
    animation: vceFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.vce-modal-overlay.vce-modal-closing {
    animation: vceFadeOut 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.vce-modal-wrapper {
    background: var(--vce-panel);
    border: 1px solid var(--vce-border);
    border-radius: 14px;
    box-shadow: var(--vce-modal-shadow);
    width: 100%;
    max-width: 550px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: vceSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vce-modal-wrapper.vce-modal-closing {
    animation: vceSlideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.vce-modal-header {
    display: flex;
    align-items: center;
}

.vce-modal-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--vce-text);
    line-height: 1.3;
}

.vce-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.vce-modal-message {
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
    color: var(--vce-text);
    opacity: 0.95;
}

.vce-modal-details {
    padding: 14px;
    background: var(--vce-bg);
    border-left: 4px solid var(--vce-primary);
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--vce-text);
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.vce-modal-input-wrapper {
    margin-top: 6px;
}

.vce-modal-input {
    width: 100%;
    min-height: 90px;
    font-size: 15px;
    line-height: 1.5;
    resize: vertical;
}

.vce-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

.vce-modal-btn-cancel {
    border-color: var(--vce-border);
}

.vce-modal-btn-cancel:hover {
    background: var(--vce-bg);
}

.vce-modal-btn-confirm {
    min-width: 90px;
}

/* === KEYFRAME ANIMATIONS === */
@keyframes vceFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes vceFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes vceSlideUp {
    from { transform: translateY(24px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes vceSlideDown {
    from { transform: translateY(0) scale(1); opacity: 1; }
    to { transform: translateY(16px) scale(0.98); opacity: 0; }
}

/* === MASS FIND & REPLACE === */
#vce-bulk-lang-selectors label {
    background: var(--vce-bg);
    border: 1px solid var(--vce-border);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

#vce-bulk-lang-selectors label:hover {
    border-color: var(--vce-primary);
}

#vce-bulk-lang-selectors input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    width: auto;
}

.vce-bulk-preview-table-container {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--vce-border);
    border-radius: 8px;
    margin-top: 10px;
    background: var(--vce-panel);
    scrollbar-width: thin;
}

.vce-bulk-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    color: var(--vce-text);
}

.vce-bulk-preview-table th, 
.vce-bulk-preview-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--vce-border);
    text-align: left;
    vertical-align: middle;
}

.vce-bulk-preview-table th {
    background: var(--vce-bg);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid var(--vce-border);
}

.vce-bulk-preview-table tr:last-child td {
    border-bottom: none;
}

.vce-bulk-preview-checkbox {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

/* Ensure all checkboxes under app and overlays are visible and don't shrink */
#vce-app input[type="checkbox"],
.vce-modal-overlay input[type="checkbox"] {
    -webkit-appearance: checkbox !important;
    appearance: checkbox !important;
    display: inline-block !important;
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer !important;
    opacity: 1 !important;
    visibility: visible !important;
    background: revert !important;
    border: revert !important;
    position: static !important;
    clip: auto !important;
    clip-path: none !important;
    overflow: visible !important;
}

/* Neutralise any theme ::before/::after pseudo-elements on these specific checkboxes */
#vce-bulk-match-words::before, #vce-bulk-match-words::after,
#vce-bulk-case-sensitive::before, #vce-bulk-case-sensitive::after,
#vce-bulk-case-preserving::before, #vce-bulk-case-preserving::after {
    display: none !important;
    content: none !important;
}