@use '../globals' as *;

/**
 * Translations Page Styles
 *
 * Styles for the translations management page including filters, table, and modals.
 *
 * @package MultilingualPressZone
 * @since 1.0.0
 */

/* ==========================================================================
   Variables
   ========================================================================== */

$primary-color: #0073aa !default;
$primary-hover: #005a87 !default;
$success-color: #00a32a !default;
$warning-color: #f0b849 !default;
$error-color: #d63638 !default;
$info-color: #2271b1 !default;

$text-primary: #1e1e1e !default;
$text-secondary: #757575 !default;
$text-light: #a7aaad !default;
$border-color: #c3c4c7 !default;
$background-light: #f0f0f1 !default;
$background-white: #ffffff !default;

$dark-bg: #1e1e1e !default;
$dark-surface: #2c2c2c !default;
$dark-text: #e4e4e4 !default;
$dark-border: #3c3c3c !default;

$spacing-xs: 4px !default;
$spacing-sm: 8px !default;
$spacing-md: 16px !default;
$spacing-lg: 24px !default;
$spacing-xl: 32px !default;

$border-radius-sm: 2px !default;
$border-radius-md: 4px !default;
$border-radius-lg: 8px !default;

$transition-fast: 0.15s ease !default;
$transition-normal: 0.3s ease !default;

/* ==========================================================================
   Page Header
   ========================================================================== */

.mpz-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: $spacing-lg;
    padding-bottom: $spacing-md;
    border-bottom: 1px solid $border-color;

    &__title {
        flex: 1;

        h1 {
            margin: 0 0 $spacing-xs 0;
            font-size: 23px;
            font-weight: 400;
            line-height: 1.3;
            color: $text-primary;
        }
    }

    &__description {
        margin: 0;
        font-size: 13px;
        color: $text-secondary;
    }

    &__actions {
        flex-shrink: 0;
        margin-left: $spacing-md;
    }
}

/* ==========================================================================
   Filters
   ========================================================================== */

.mpz-filters {
    margin-bottom: $spacing-lg;
    padding: $spacing-md;
    background: $presszone-multilingual-surface;
    border: 1px solid $presszone-multilingual-border;
    border-radius: $presszone-multilingual-radius-lg;

    @include dark-mode-class {
        background: $presszone-multilingual-surface-dark;
        border-color: $presszone-multilingual-border-dark;
    }
}

.mpz-filters__row {
    display: flex;
    flex-wrap: wrap;
    gap: $spacing-md;
    align-items: flex-end;
}

.mpz-filter-group {
    display: flex;
    flex-direction: column;
    gap: $spacing-xs;
    min-width: 0;

    &--search {
        flex: 1;
        min-width: 200px;
    }

    &--actions {
        justify-content: flex-end;
        margin-left: auto;
    }
}

.mpz-filter-label {
    font-size: 13px;
    font-weight: 600;
    color: $presszone-multilingual-text-muted;
    margin: 0;

    @include dark-mode-class {
        color: $presszone-multilingual-text-muted-dark;
    }
}

.mpz-filter-input {
    width: 100%;
    min-width: 150px;
}

.mpz-filter-select {
    width: 100%;
    min-width: 150px;
    cursor: pointer;
}

/* ==========================================================================
   Shared Filter Controls (Press.Zone Style)
   ========================================================================== */

.presszone-multilingual-filters {
    margin-bottom: $presszone-multilingual-spacing-lg;

    &__controls {
        display: flex;
        flex-wrap: wrap;
        gap: $presszone-multilingual-spacing-md;
        align-items: flex-end;

        // Target the form-group wrappers injected by Select/Input components
        >.presszone-multilingual-form-group {
            flex: 1 1 180px;
            min-width: 140px; // Slightly smaller min-width
            max-width: 350px;
            margin-bottom: 0 !important; // Force remove default group margin
        }

        // Search should grow more (Search is the last child in both Posts and Translations)
        >.presszone-multilingual-form-group:last-child {
            flex: 2 1 250px;
            max-width: none;
        }
    }
}

// Responsive stacking for narrow viewports
@media screen and (max-width: 782px) {
    .presszone-multilingual-filters__controls {
        flex-direction: column;
        align-items: stretch;

        .presszone-multilingual-filter,
        .presszone-multilingual-select,
        .presszone-multilingual-input {
            max-width: none;
            width: 100%;
        }
    }
}

/* ==========================================================================
   Table Container
   ========================================================================== */

.mpz-table-container {
    margin-bottom: $spacing-lg;
    // The Table component now renders a `presszone-multilingual-table-wrapper`
    // which owns the surface/border/radius. Keep this container as a layout hook.
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
}

/* ==========================================================================
   Translations Table
   ========================================================================== */

// Table layout is provided by `.presszone-multilingual-table--legacy`.
// Keep this class for page-specific hooks only.
.mpz-translations-table {
    font-size: 13px;
}

.mpz-translation-select-checkbox {
    margin: 0;
}

.mpz-translation-title {
    display: flex;
    align-items: center;
    gap: $spacing-xs;

    &__link {
        color: $primary-color;
        text-decoration: none;
        font-weight: 500;
        transition: color $transition-fast;

        &:hover {
            color: $primary-hover;
            text-decoration: underline;
        }

        &:focus {
            outline: 2px solid $primary-color;
            outline-offset: 2px;
            border-radius: $border-radius-sm;
        }
    }
}

.mpz-translation-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 14px;
    cursor: help;
}

.mpz-translation-meta {
    margin-top: $spacing-xs;
    font-size: 12px;
    color: $text-secondary;
}

/* ==========================================================================
   Language Flag Display
   ========================================================================== */

.mpz-language-flag {
    display: flex;
    align-items: center;
    gap: $spacing-sm;

    &__emoji {
        font-size: 18px;
        line-height: 1;
    }

    &__name {
        font-size: 13px;
        color: $text-primary;
    }
}

/* ==========================================================================
   Language Pair Display
   ========================================================================== */

.mpz-language-pair {
    display: flex;
    align-items: center;
    gap: $spacing-sm;

    &__arrow {
        color: $text-light;
        font-size: 14px;
        line-height: 1;
    }
}

/* ==========================================================================
   Translation Time
   ========================================================================== */

.mpz-translation-time {
    font-size: 13px;
    color: $text-secondary;
    cursor: help;

    @include dark-mode-class {
        color: $presszone-multilingual-text-muted-dark;
    }
}

/* ==========================================================================
   Table Actions
   ========================================================================== */

.mpz-table-actions {
    display: flex;
    gap: $spacing-xs;
    justify-content: flex-end;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.mpz-pagination-container {
    display: flex;
    justify-content: center;
    margin-bottom: $spacing-lg;
}

.mpz-pagination {
    display: flex;
    align-items: center;
    gap: $spacing-md;
    padding: $spacing-md;
    background: $presszone-multilingual-surface;
    border: 1px solid $presszone-multilingual-border;
    border-radius: $presszone-multilingual-radius-lg;

    @include dark-mode-class {
        background: $presszone-multilingual-surface-dark;
        border-color: $presszone-multilingual-border-dark;
    }

    &__info {
        font-size: 13px;
        color: $presszone-multilingual-text-muted;
        font-weight: 600;
        min-width: 100px;
        text-align: center;

        @include dark-mode-class {
            color: $presszone-multilingual-text-muted-dark;
        }
    }
}

/* ==========================================================================
   History Table — Tooltip Overflow Fix
   ========================================================================== */

.tpz-history-table {
    td {
        overflow: visible;
    }
}

.tpz-history-chars {
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    color: $text-primary;

    @include dark-mode-class {
        color: $presszone-multilingual-text-dark;
    }
}

/* ==========================================================================
   Job Detail Modal (History Page)
   ========================================================================== */

.tpz-job-modal-body {
    display: flex;
    flex-direction: column;
    gap: $spacing-lg;
    padding: $spacing-lg 0 $spacing-sm;
}

.tpz-job-modal-status {
    display: flex;
    align-items: center;
    gap: $spacing-sm;
    padding-bottom: $spacing-md;
    border-bottom: 1px solid $border-color;

    @include dark-mode-class {
        border-bottom-color: $dark-border;
    }
}

.tpz-job-modal-id {
    font-size: 12px;
    color: $text-secondary;
    font-family: monospace;
    background: $background-light;
    padding: 2px 6px;
    border-radius: $border-radius-sm;

    @include dark-mode-class {
        background: $dark-bg;
        color: lighten($text-secondary, 15%);
    }
}

.tpz-job-modal-section {
    &__title {
        margin: 0 0 $spacing-sm 0;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: $text-secondary;

        @include dark-mode-class {
            color: lighten($text-secondary, 15%);
        }
    }

    &--error {
        .tpz-job-modal-section__title {
            color: $error-color;
        }
    }
}

.tpz-job-modal-lang-row {
    display: flex;
    align-items: center;
    gap: $spacing-sm;
    flex-wrap: wrap;
}

.tpz-job-modal-pending {
    font-size: 12px;
    color: $text-light;
    font-style: italic;

    @include dark-mode-class {
        color: darken($dark-text, 20%);
    }
}

.tpz-job-modal-post-title {
    display: flex;
    align-items: center;
    gap: $spacing-sm;
    flex-wrap: wrap;
}

.tpz-job-modal-post-links {
    display: flex;
    gap: $spacing-xs;
    flex-shrink: 0;
}

.tpz-job-modal-link {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: $border-radius-sm;
    text-decoration: none;
    font-weight: 500;
    transition: background-color $transition-fast, color $transition-fast;

    &--edit {
        background: rgba($primary-color, 0.08);
        color: $primary-color;
        border: 1px solid rgba($primary-color, 0.2);

        &:hover {
            background: rgba($primary-color, 0.15);
            color: $primary-hover;
            text-decoration: none;
        }

        @include dark-mode-class {
            background: rgba($primary-color, 0.15);
            border-color: rgba($primary-color, 0.3);
            color: lighten($primary-color, 15%);

            &:hover {
                background: rgba($primary-color, 0.25);
            }
        }
    }

    &--view {
        background: $background-light;
        color: $text-secondary;
        border: 1px solid $border-color;

        &:hover {
            background: darken($background-light, 5%);
            color: $text-primary;
            text-decoration: none;
        }

        @include dark-mode-class {
            background: $dark-surface;
            border-color: $dark-border;
            color: lighten($text-secondary, 15%);

            &:hover {
                background: lighten($dark-surface, 5%);
                color: $dark-text;
            }
        }
    }
}

.tpz-job-modal-chars {
    font-size: 13px;
    color: $text-secondary;
    font-variant-numeric: tabular-nums;

    @include dark-mode-class {
        color: lighten($text-secondary, 10%);
    }
}

.tpz-job-modal-error-msg {
    margin: 0;
    font-size: 13px;
    color: $error-color;
    background: rgba($error-color, 0.06);
    border: 1px solid rgba($error-color, 0.2);
    border-radius: $border-radius-md;
    padding: $spacing-sm $spacing-md;
    line-height: 1.5;

    @include dark-mode-class {
        background: rgba($error-color, 0.12);
        border-color: rgba($error-color, 0.3);
    }
}

/* ==========================================================================
   Translation Details Modal
   ========================================================================== */

.mpz-translation-details {
    display: flex;
    flex-direction: column;
    gap: $spacing-lg;
    max-height: 60vh;
    overflow-y: auto;
}

.mpz-detail-section {
    h3 {
        margin: 0 0 $spacing-md 0;
        font-size: 15px;
        font-weight: 600;
        color: $text-primary;
        padding-bottom: $spacing-sm;
        border-bottom: 1px solid $border-color;
    }
}

.mpz-detail-list {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: $spacing-sm $spacing-md;
    margin: 0;

    dt {
        font-weight: 600;
        color: $text-secondary;
        font-size: 13px;
    }

    dd {
        margin: 0;
        color: $text-primary;
        font-size: 13px;
    }
}

.mpz-detail-actions {
    display: flex;
    gap: $spacing-sm;

    .button {
        display: inline-flex;
        align-items: center;
        gap: $spacing-xs;
        padding: 8px 16px;
        font-size: 13px;
        text-decoration: none;
        transition: all $transition-fast;

        &:hover {
            text-decoration: none;
        }
    }
}

/* ==========================================================================
   Hash Status Notice
   ========================================================================== */

.mpz-hash-status {
    margin-top: $spacing-sm;
}

// Notices are shared in admin/src/styles/_components.scss

/* ==========================================================================
   Bulk Translate Modal
   ========================================================================== */

.mpz-bulk-translate {
    display: flex;
    flex-direction: column;
    gap: $spacing-md;

    p {
        margin: 0;
        font-size: 14px;
        color: $text-primary;
    }
}

.mpz-form-group {
    display: flex;
    flex-direction: column;
    gap: $spacing-xs;

    label {
        font-size: 13px;
        font-weight: 500;
        color: $text-primary;
        margin: 0;
    }
}

/* ==========================================================================
   Bulk Action Bar
   ========================================================================== */

@keyframes mpz-slide-down {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mpz-bulk-action-bar-container {
    min-height: 0;
}

.mpz-bulk-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: $spacing-md;
    padding: $spacing-sm $spacing-md;
    margin-bottom: $spacing-md;
    background: rgba($primary-color, 0.06);
    border: 1px solid rgba($primary-color, 0.2);
    border-radius: $presszone-multilingual-radius-lg;
    animation: mpz-slide-down 0.2s ease-out;

    @include dark-mode-class {
        background: rgba($primary-color, 0.12);
        border-color: rgba($primary-color, 0.3);
    }

    &__info {
        display: flex;
        align-items: center;
        gap: $spacing-md;
        font-size: 13px;
    }

    &__count {
        font-weight: 600;
        color: $primary-color;
    }

    &__chars {
        color: $text-secondary;

        @include dark-mode-class {
            color: $presszone-multilingual-text-muted-dark;
        }
    }

    &__actions {
        display: flex;
        align-items: center;
        gap: $spacing-sm;
    }

    &__label {
        font-size: 13px;
        font-weight: 500;
        color: $text-secondary;
        white-space: nowrap;

        @include dark-mode-class {
            color: $presszone-multilingual-text-muted-dark;
        }
    }

    &__lang-select {
        padding: 4px 28px 4px 8px;
        font-size: 13px;
        line-height: 1.4;
        color: $text-primary;
        background-color: $background-white;
        border: 1px solid $border-color;
        border-radius: $border-radius-sm;
        cursor: pointer;
        appearance: none;
        background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"%3e%3cpath fill="%23a7aaad" d="M5 6l5 5 5-5 2 1-7 7-7-7z"/%3e%3c/svg%3e');
        background-repeat: no-repeat;
        background-position: right 6px center;
        background-size: 14px;

        @include dark-mode-class {
            color: $dark-text;
            background-color: $dark-bg;
            border-color: $dark-border;
        }
    }
}

.mpz-bulk-checkbox-cell {
    width: 40px;
    text-align: center;
    vertical-align: middle;
}

.mpz-st-table-row--selected {
    background-color: rgba($primary-color, 0.04) !important;

    @include dark-mode-class {
        background-color: rgba($primary-color, 0.1) !important;
    }

    &:hover {
        background-color: rgba($primary-color, 0.07) !important;

        @include dark-mode-class {
            background-color: rgba($primary-color, 0.14) !important;
        }
    }
}

.mpz-bulk-progress-container {
    display: flex;
    flex-direction: column;
    gap: $spacing-md;
    padding: $spacing-lg $spacing-md;

    &__label {
        font-size: 14px;
        font-weight: 500;
        color: $text-primary;
        text-align: center;

        @include dark-mode-class {
            color: $presszone-multilingual-text-dark;
        }
    }
}

.mpz-bulk-stat--failed {
    color: $error-color;
    font-weight: 600;
}

/* ==========================================================================
   Bulk Translation Queue List
   ========================================================================== */

.tpz-bulk-queue {
    display: flex;
    flex-direction: column;
    gap: 0;

    // Header with progress summary + ETA + bar
    &__header {
        display: flex;
        flex-direction: column;
        gap: $spacing-xs;
        padding: $spacing-md $spacing-md $spacing-sm;
        border-bottom: 1px solid $border-color;

        @include dark-mode-class {
            border-bottom-color: $dark-border;
        }
    }

    &__summary {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
    }

    &__count {
        font-size: 14px;
        font-weight: 600;
        color: $text-primary;

        @include dark-mode-class {
            color: $presszone-multilingual-text-dark;
        }
    }

    &__eta {
        font-size: 13px;
        color: $text-secondary;
        font-variant-numeric: tabular-nums;

        @include dark-mode-class {
            color: $presszone-multilingual-text-muted-dark;
        }
    }

    &__bar-container {
        height: 4px;
        background: rgba($border-color, 0.5);
        border-radius: 2px;
        overflow: hidden;

        @include dark-mode-class {
            background: rgba($dark-border, 0.5);
        }
    }

    &__bar {
        height: 100%;
        width: 0;
        background: $primary-color;
        border-radius: 2px;
        transition: width 0.3s ease;
    }

    // Scrollable job list
    &__list {
        max-height: 360px;
        overflow-y: auto;
        padding: $spacing-xs 0;
    }

    // Individual queue item
    &__item {
        display: grid;
        grid-template-columns: 24px 1fr auto auto;
        align-items: center;
        gap: $spacing-xs;
        padding: 6px $spacing-md;
        font-size: 13px;
        transition: background-color 0.15s ease;

        &--pending {
            opacity: 0.5;
        }

        &--translating {
            background-color: rgba($primary-color, 0.05);
            opacity: 1;

            @include dark-mode-class {
                background-color: rgba($primary-color, 0.1);
            }

            .tpz-bulk-queue__item-status {
                color: transparent;
                width: 14px;
                height: 14px;
                border: 2px solid rgba($primary-color, 0.3);
                border-top-color: $primary-color;
                border-radius: 50%;
                display: inline-block;
                animation: tpz-spin 0.8s linear infinite;
            }
        }

        &--completed {
            opacity: 1;

            .tpz-bulk-queue__item-status {
                color: $success-color;
                font-weight: bold;
            }

            .tpz-bulk-queue__item-duration {
                color: $text-secondary;

                @include dark-mode-class {
                    color: $presszone-multilingual-text-muted-dark;
                }
            }
        }

        &--failed {
            opacity: 1;

            .tpz-bulk-queue__item-status {
                color: $error-color;
                font-weight: bold;
            }

            .tpz-bulk-queue__item-duration {
                color: $error-color;
                font-size: 12px;
            }
        }

        &--skipped {
            opacity: 0.4;

            .tpz-bulk-queue__item-duration {
                font-style: italic;
                color: $text-secondary;

                @include dark-mode-class {
                    color: $presszone-multilingual-text-muted-dark;
                }
            }
        }
    }

    &__item-status {
        width: 24px;
        text-align: center;
        font-size: 14px;
    }

    &__item-title {
        color: $text-primary;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;

        @include dark-mode-class {
            color: $presszone-multilingual-text-dark;
        }
    }

    &__item-lang {
        font-size: 12px;
        color: $text-secondary;
        white-space: nowrap;

        @include dark-mode-class {
            color: $presszone-multilingual-text-muted-dark;
        }
    }

    &__item-duration {
        font-size: 12px;
        font-variant-numeric: tabular-nums;
        text-align: right;
        min-width: 50px;
    }

    // Completion view
    &--done {
        .tpz-bulk-queue__list {
            border-top: 1px solid $border-color;
            margin-top: $spacing-sm;

            @include dark-mode-class {
                border-top-color: $dark-border;
            }
        }
    }

    &__done-header {
        display: flex;
        align-items: center;
        gap: $spacing-sm;
        padding: $spacing-md;
    }

    &__done-icon {
        font-size: 24px;
        color: $success-color;

        &--warning {
            color: $warning-color;
        }
    }

    &__done-title {
        font-size: 16px;
        font-weight: 600;
        margin: 0;
        color: $text-primary;

        @include dark-mode-class {
            color: $presszone-multilingual-text-dark;
        }
    }

    &__stats {
        display: flex;
        flex-wrap: wrap;
        gap: $spacing-sm $spacing-md;
        padding: 0 $spacing-md $spacing-sm;
        font-size: 13px;
    }

    &__stat {
        color: $text-secondary;

        @include dark-mode-class {
            color: $presszone-multilingual-text-muted-dark;
        }

        &--failed {
            color: $error-color;
            font-weight: 600;
        }
    }
}

@keyframes tpz-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Translate Post Modal — MPZ-style layout
   ========================================================================== */

// Tab bar rendered inside .mpz-modal-tabs by Modal.js
.mpz-modal-tabs {
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid $presszone-multilingual-border;
    padding: 0 $spacing-md;
    gap: 0;
    scrollbar-width: none;

    &::-webkit-scrollbar { display: none; }

    @include dark-mode-class {
        border-bottom-color: $presszone-multilingual-border-dark;
    }
}

// Two-column edit layout (source | translation)
.mpz-st-edit-layout {
    display: flex;
    flex-direction: column;
    gap: $spacing-md;
    padding: $spacing-md 0 $spacing-sm;
}

.mpz-st-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: $spacing-md;
    min-height: 180px;

    @media screen and (max-width: 782px) {
        grid-template-columns: 1fr;
    }
}

.mpz-st-edit-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: $presszone-multilingual-text-muted;
    margin-bottom: $spacing-xs;

    @include dark-mode-class {
        color: $presszone-multilingual-text-muted-dark;
    }
}

.mpz-st-edit-grid__original-text {
    background: $presszone-multilingual-surface;
    border: 1px solid $presszone-multilingual-border;
    border-radius: $border-radius-md;
    padding: $spacing-md;
    font-size: 14px;
    line-height: 1.6;
    overflow-y: auto;
    max-height: 280px;

    @include dark-mode-class {
        background: $presszone-multilingual-surface-dark;
        border-color: $presszone-multilingual-border-dark;
    }
}

.mpz-ct-field-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: $spacing-sm;

    &:last-child { margin-bottom: 0; }
}

.mpz-ct-field-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: $presszone-multilingual-text-muted;

    @include dark-mode-class {
        color: $presszone-multilingual-text-muted-dark;
    }
}

.mpz-ct-field-value {
    font-size: 13px;
    color: $presszone-multilingual-text;
    word-break: break-word;

    @include dark-mode-class {
        color: $presszone-multilingual-text-dark;
    }

    &--title {
        font-weight: 500;
    }
}

// Right side: AI translation info panel
.mpz-tpz-translate-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 120px;
    padding: $spacing-md;
    background: $presszone-multilingual-surface;
    border: 1px solid $presszone-multilingual-border;
    border-radius: $border-radius-md;

    @include dark-mode-class {
        background: $presszone-multilingual-surface-dark;
        border-color: $presszone-multilingual-border-dark;
    }

    &__desc {
        margin: 0;
        font-size: 14px;
        line-height: 1.6;
        color: $presszone-multilingual-text;

        @include dark-mode-class {
            color: $presszone-multilingual-text-dark;
        }
    }
}

// Meta bar at bottom of modal content
.mpz-st-edit-meta {
    display: flex;
    align-items: center;
    gap: $spacing-sm;
    padding-top: $spacing-sm;
    border-top: 1px solid $presszone-multilingual-border;
    font-size: 13px;
    color: $presszone-multilingual-text-muted;

    @include dark-mode-class {
        border-top-color: $presszone-multilingual-border-dark;
        color: $presszone-multilingual-text-muted-dark;
    }

    &__arrow {
        color: $presszone-multilingual-text-muted;

        @include dark-mode-class {
            color: $presszone-multilingual-text-muted-dark;
        }
    }
}

// Tab checkmark (translated language indicator)
.mpz-st-tab-check {
    color: $success-color;
    font-weight: 700;
}

// Tab inactive badge
.mpz-st-tab-inactive-badge {
    display: inline-block;
    margin-inline-start: $spacing-xs;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 500;
    line-height: 1.4;
    color: $text-secondary;
    background: $background-light;
    border: 1px solid $border-color;
    border-radius: 10px;
    vertical-align: middle;
    text-transform: lowercase;

    @include dark-mode-class {
        color: $presszone-multilingual-text-muted-dark;
        background: $presszone-multilingual-surface-dark;
        border-color: $presszone-multilingual-border-dark;
    }
}

.presszone-multilingual-tabs__item--inactive {
    opacity: 0.65;
}

// Edit link inside modal translation side
.mpz-ct-edit-link {
    margin-top: $spacing-sm;
}

.mpz-ct-edit-link__anchor {
    color: $primary-color;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;

    &:hover {
        text-decoration: underline;
    }

    @include dark-mode-class {
        color: lighten($primary-color, 15%);
    }
}

// Generating / translating spinner state
.mpz-ct-generating {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: $spacing-md;
    background: $presszone-multilingual-surface;
    border: 1px solid $presszone-multilingual-border;
    border-radius: $border-radius-md;
    padding: $spacing-lg;

    @include dark-mode-class {
        background: $presszone-multilingual-surface-dark;
        border-color: $presszone-multilingual-border-dark;
    }
}

.mpz-ct-generating__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid $presszone-multilingual-border;
    border-top-color: $primary-color;
    border-radius: 50%;
    animation: mpz-spin 0.8s linear infinite;

    @include dark-mode-class {
        border-color: $presszone-multilingual-border-dark;
        border-top-color: lighten($primary-color, 15%);
    }
}

.mpz-ct-generating__text {
    color: $presszone-multilingual-text-muted;
    font-size: 14px;
    margin: 0;

    @include dark-mode-class {
        color: $presszone-multilingual-text-muted-dark;
    }
}

@keyframes mpz-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .mpz-ct-generating__spinner {
        animation: none;
    }
}

// Error state for translate info panel
.mpz-tpz-translate-info--error {
    border-color: rgba($error-color, 0.3);
    background: rgba($error-color, 0.06);

    .mpz-tpz-translate-info__desc {
        color: $error-color;
    }

    @include dark-mode-class {
        border-color: rgba($error-color, 0.4);
        background: rgba($error-color, 0.12);
    }
}

.mpz-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.4;
    color: $text-primary;
    background-color: $background-white;
    border: 1px solid $border-color;
    border-radius: $border-radius-sm;
    cursor: pointer;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"%3e%3cpath fill="%23a7aaad" d="M5 6l5 5 5-5 2 1-7 7-7-7z"/%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 36px;
    transition: border-color $transition-fast;

    &:focus {
        border-color: $primary-color;
        outline: none;
        box-shadow: 0 0 0 1px $primary-color;
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .mpz-page-header {
        border-bottom-color: $dark-border;

        &__title h1 {
            color: $dark-text;
        }

        &__description {
            color: lighten($text-secondary, 10%);
        }
    }

    .mpz-filters {
        background: $dark-surface;
        border-color: $dark-border;
    }

    .mpz-filter-label {
        color: $dark-text;
    }

    .mpz-filter-input,
    .mpz-filter-select,
    .mpz-select {
        color: $dark-text;
        background-color: $dark-bg;
        border-color: $dark-border;

        &:focus {
            border-color: lighten($primary-color, 15%);
            box-shadow: 0 0 0 1px lighten($primary-color, 15%);
        }
    }

    .mpz-table-container {
        background: $dark-surface;
        border-color: $dark-border;
    }

    .mpz-translations-table {
        thead {
            background-color: $dark-bg;
            border-bottom-color: $dark-border;

            th {
                color: $dark-text;
            }
        }

        tbody {
            tr {
                border-bottom-color: $dark-border;

                &:hover {
                    background-color: lighten($dark-surface, 3%);
                }
            }

            td {
                color: $dark-text;
            }
        }
    }

    .mpz-translation-title__link {
        color: lighten($primary-color, 15%);

        &:hover {
            color: lighten($primary-hover, 15%);
        }
    }

    .mpz-translation-meta {
        color: lighten($text-secondary, 10%);
    }

    .mpz-language-flag__name {
        color: $dark-text;
    }

    .mpz-pagination {
        background: $dark-surface;
        border-color: $dark-border;

        &__info {
            color: lighten($text-secondary, 10%);
        }
    }

    .mpz-detail-section h3 {
        color: $dark-text;
        border-bottom-color: $dark-border;
    }

    .mpz-detail-list {
        dt {
            color: lighten($text-secondary, 10%);
        }

        dd {
            color: $dark-text;
        }
    }

    .mpz-notice {
        &--success {
            color: lighten($success-color, 20%);
            background-color: rgba($success-color, 0.15);
            border-color: rgba($success-color, 0.3);
        }

        &--warning {
            color: lighten($warning-color, 10%);
            background-color: rgba($warning-color, 0.15);
            border-color: rgba($warning-color, 0.3);
        }

        &--error {
            color: lighten($error-color, 20%);
            background-color: rgba($error-color, 0.15);
            border-color: rgba($error-color, 0.3);
        }

        &--info {
            color: lighten($info-color, 20%);
            background-color: rgba($info-color, 0.15);
            border-color: rgba($info-color, 0.3);
        }
    }

    .mpz-form-group label {
        color: $dark-text;
    }

    .mpz-bulk-translate p {
        color: $dark-text;
    }

    .mpz-bulk-action-bar {
        background: rgba($primary-color, 0.12);
        border-color: rgba($primary-color, 0.3);

        &__count {
            color: lighten($primary-color, 15%);
        }

        &__chars {
            color: lighten($text-secondary, 10%);
        }

        &__lang-select {
            color: $dark-text;
            background-color: $dark-bg;
            border-color: $dark-border;
        }
    }

    .mpz-st-table-row--selected {
        background-color: rgba($primary-color, 0.1) !important;

        &:hover {
            background-color: rgba($primary-color, 0.14) !important;
        }
    }

    .mpz-bulk-progress-container__label {
        color: $dark-text;
    }
}

// Explicit dark mode class (WordPress admin color scheme)
body.admin-color-midnight,
body.admin-color-ectoplasm {
    .mpz-page-header {
        border-bottom-color: $dark-border;

        &__title h1 {
            color: $dark-text;
        }

        &__description {
            color: lighten($text-secondary, 10%);
        }
    }

    .mpz-filters {
        background: $dark-surface;
        border-color: $dark-border;
    }

    .mpz-filter-label {
        color: $dark-text;
    }

    .mpz-filter-input,
    .mpz-filter-select,
    .mpz-select {
        color: $dark-text;
        background-color: $dark-bg;
        border-color: $dark-border;

        &:focus {
            border-color: lighten($primary-color, 15%);
            box-shadow: 0 0 0 1px lighten($primary-color, 15%);
        }
    }

    .mpz-table-container {
        background: $dark-surface;
        border-color: $dark-border;
    }

    .mpz-translations-table {
        thead {
            background-color: $dark-bg;
            border-bottom-color: $dark-border;

            th {
                color: $dark-text;
            }
        }

        tbody {
            tr {
                border-bottom-color: $dark-border;

                &:hover {
                    background-color: lighten($dark-surface, 3%);
                }
            }

            td {
                color: $dark-text;
            }
        }
    }

    .mpz-translation-title__link {
        color: lighten($primary-color, 15%);

        &:hover {
            color: lighten($primary-hover, 15%);
        }
    }

    .mpz-pagination {
        background: $dark-surface;
        border-color: $dark-border;

        &__info {
            color: lighten($text-secondary, 10%);
        }
    }

    .mpz-detail-section h3 {
        color: $dark-text;
        border-bottom-color: $dark-border;
    }

    .mpz-detail-list {
        dt {
            color: lighten($text-secondary, 10%);
        }

        dd {
            color: $dark-text;
        }
    }

    .mpz-bulk-action-bar {
        background: rgba($primary-color, 0.12);
        border-color: rgba($primary-color, 0.3);

        &__count {
            color: lighten($primary-color, 15%);
        }

        &__chars {
            color: lighten($text-secondary, 10%);
        }

        &__lang-select {
            color: $dark-text;
            background-color: $dark-bg;
            border-color: $dark-border;
        }
    }

    .mpz-st-table-row--selected {
        background-color: rgba($primary-color, 0.1) !important;

        &:hover {
            background-color: rgba($primary-color, 0.14) !important;
        }
    }

    .mpz-bulk-progress-container__label {
        color: $dark-text;
    }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media screen and (max-width: 1200px) {
    .mpz-filters__row {
        flex-wrap: wrap;
    }

    .mpz-filter-group {
        min-width: 150px;

        &--search {
            flex: 1 1 100%;
            max-width: 100%;
        }
    }
}

@media screen and (max-width: 782px) {
    .mpz-page-header {
        flex-direction: column;
        align-items: stretch;

        &__actions {
            margin-left: 0;
            margin-top: $spacing-md;
        }
    }

    .mpz-filters__row {
        flex-direction: column;
    }

    .mpz-filter-group {
        width: 100%;
        min-width: 0;

        &--actions {
            margin-left: 0;
        }
    }

    .mpz-translations-table {
        font-size: 12px;

        thead {
            th {
                padding: $spacing-xs $spacing-sm;
            }
        }

        tbody {
            td {
                padding: $spacing-sm;
            }
        }
    }

    .mpz-bulk-action-bar {
        flex-direction: column;
        align-items: stretch;
        gap: $spacing-sm;

        &__actions {
            flex-wrap: wrap;
        }
    }

    .mpz-table-actions {
        flex-direction: column;
        gap: $spacing-xs;
    }

    .mpz-detail-list {
        grid-template-columns: 1fr;
        gap: $spacing-xs;

        dt {
            font-weight: 600;
            margin-top: $spacing-sm;

            &:first-child {
                margin-top: 0;
            }
        }
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

// High contrast mode support
@media (prefers-contrast: high) {
    .mpz-translations-table {
        border: 2px solid currentColor;

        thead th,
        tbody td {
            border: 1px solid currentColor;
        }
    }

    .mpz-filter-input,
    .mpz-filter-select,
    .mpz-select {
        border-width: 2px;

        &:focus {
            outline: 2px solid currentColor;
            outline-offset: 2px;
        }
    }
}

// Reduced motion support
@media (prefers-reduced-motion: reduce) {

    .mpz-translations-table tbody tr,
    .mpz-translation-title__link,
    .mpz-filter-input,
    .mpz-filter-select,
    .mpz-select,
    .mpz-notice {
        transition: none;
    }

    .mpz-bulk-action-bar {
        animation: none;
    }
}

/* ==========================================================================
   Skeleton Loading State
   ========================================================================== */

.skeleton {
    background: linear-gradient(90deg,
            $background-light 25%,
            lighten($background-light, 5%) 50%,
            $background-light 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: $border-radius-sm;

    @include dark-mode-class {
        background: linear-gradient(90deg,
                $dark-surface 25%,
                lighten($dark-surface, 5%) 50%,
                $dark-surface 75%);
        background-size: 200% 100%;
    }
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin: 4px 0;
}

.skeleton-badge {
    height: 24px;
    border-radius: $border-radius-md;
}

/* ==========================================================================
   Table Loading Overlay
   ========================================================================== */

.translations-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba($background-white, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: $spacing-md;
    z-index: 10;

    @include dark-mode-class {
        background: rgba($dark-bg, 0.9);
    }
}

.translations-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid $border-color;
    border-top-color: $primary-color;
    border-radius: 50%;
    animation: spin 1s linear infinite;

    @include dark-mode-class {
        border-color: $dark-border;
        border-top-color: lighten($primary-color, 15%);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Status Bar
   ========================================================================== */

.translations-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: $spacing-sm $spacing-md;
    background: $background-light;
    border-top: 1px solid $border-color;
    font-size: 12px;
    color: $text-secondary;

    @include dark-mode-class {
        background: $dark-surface;
        border-top-color: $dark-border;
        color: lighten($text-secondary, 10%);
    }

    &.is-stale {
        background: rgba($warning-color, 0.1);
        border-top-color: $warning-color;
    }

    &.is-refreshing {
        background: rgba($info-color, 0.1);
        border-top-color: $info-color;
    }
}

.status-updated {
    display: flex;
    align-items: center;
    gap: $spacing-xs;
}

.status-refreshing {
    display: flex;
    align-items: center;
    gap: $spacing-xs;
    color: $info-color;
    font-weight: 500;
}

.spinner-small {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.status-stale-badge {
    padding: 2px 8px;
    background: $warning-color;
    color: darken($warning-color, 40%);
    border-radius: $border-radius-sm;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* ==========================================================================
   Refresh Button
   ========================================================================== */

.translations-refresh-btn {
    margin-top: $spacing-md;
    padding: 8px 16px;
    background: $background-white;
    border: 1px solid $border-color;
    border-radius: $border-radius-md;
    font-size: 13px;
    color: $text-secondary;
    cursor: pointer;
    transition: all $transition-fast;

    @include dark-mode-class {
        background: $dark-surface;
        border-color: $dark-border;
        color: lighten($text-secondary, 10%);
    }

    &:hover:not(:disabled) {
        background: $background-light;
        border-color: $primary-color;
        color: $primary-color;

        @include dark-mode-class {
            background: lighten($dark-surface, 5%);
        }
    }

    &:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

    &.is-refreshing {
        .spinner-small {
            display: inline-block;
            margin-right: $spacing-xs;
        }
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {

    .mpz-page-header__actions,
    .mpz-filters,
    .mpz-table-actions,
    .mpz-pagination-container,
    .mpz-bulk-action-bar-container,
    .mpz-bulk-checkbox-cell {
        display: none;
    }

    .mpz-translations-table {
        border: 1px solid #000;

        thead,
        tbody tr {
            border: 1px solid #000;
        }

        td,
        th {
            padding: 4px 8px;
        }
    }
}

/* ==========================================================================
   Translation Progress Indicators
   ========================================================================== */

/* Row-level status */
.tpz-translation-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    line-height: 1.4;

    &--active {
        color: $primary-color;
    }

    &--done {
        color: $success-color;
    }

    &--failed {
        color: $error-color;
    }

    &__icon {
        font-size: 16px;
        font-weight: 700;
    }
}

/* Modal progress states */
.tpz-modal-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 24px;
    min-height: 180px;

    &__spinner {
        margin-bottom: 16px;

        .presszone-multilingual-spinner-with-text {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 12px;
        }

        .presszone-multilingual-spinner--lg {
            width: 36px;
            height: 36px;
        }

        .presszone-multilingual-spinner-with-text__label {
            font-size: 15px;
            font-weight: 500;
            color: var(--mpz-text-primary, #1d2327);
        }
    }

    &__icon {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        font-weight: 700;
        margin-bottom: 12px;
        color: #fff;
        background: $success-color;

        &--error {
            background: $error-color;
        }
    }

    &__title {
        font-size: 16px;
        font-weight: 600;
        margin: 0 0 8px;
        color: var(--mpz-text-primary, #1d2327);
    }

    &__detail {
        font-size: 13px;
        color: var(--mpz-text-secondary, #646970);
        margin: 0 0 12px;
        max-width: 400px;
    }

    &__stats {
        font-size: 12px;
        color: var(--mpz-text-tertiary, #8c8f94);
        padding-top: 8px;
        border-top: 1px solid var(--mpz-border-light, #e0e0e0);
        width: 100%;
        max-width: 300px;
    }
}

/* Translate All — per-language results list */
.mpz-translate-all-results {
    display: flex;
    flex-direction: column;
    gap: $spacing-xs;
    width: 100%;
    max-width: 360px;
    margin-top: $spacing-sm;
}

.mpz-translate-all-result {
    display: flex;
    align-items: center;
    gap: $spacing-sm;
    padding: $spacing-xs $spacing-sm;
    font-size: 13px;
    border-radius: $border-radius-sm;
    background: $background-light;

    @include dark-mode-class {
        background: $dark-surface;
    }

    &__lang {
        flex: 1;
        font-weight: 500;
        color: $text-primary;

        @include dark-mode-class {
            color: $dark-text;
        }
    }

    &__status {
        font-weight: 700;
        font-size: 14px;

        &--ok {
            color: $success-color;
        }

        &--fail {
            color: $error-color;
        }
    }

    &__link {
        font-size: 12px;
        color: $primary-color;
        text-decoration: none;

        &:hover {
            text-decoration: underline;
        }
    }

    &__error {
        font-size: 11px;
        color: $error-color;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

.mpz-st-tab-check--failed {
    color: $error-color;
}

/* Inactive language badge — visually dimmed to distinguish from active missing langs */
.mpz-badge--inactive-lang {
    opacity: 0.55;
    border-style: dashed;
    cursor: help;
}
