@use '../globals' as *;

/**
 * Languages Page Styles
 *
 * Styles for the languages management interface.
 *
 * @package MultilingualPressZone
 */

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

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

    h1 {
        margin: 0;
        font-size: 24px;
        font-weight: 600;
    }
}

/* ==========================================================================
   Languages Table
   ========================================================================== */

.mpz-languages-table-container {
    background: $background-white;
    border: 1px solid $border-color;
    border-radius: $border-radius-md;
    overflow: hidden;
}

.mpz-languages-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;

    thead {
        background: $background-light;
        border-bottom: 1px solid $border-color;

        th {
            padding: $spacing-sm $spacing-md;
            text-align: left;
            font-weight: 600;
            color: $text-secondary;
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
    }

    tbody {
        tr {
            border-bottom: 1px solid $border-color;
            transition: background-color $transition-fast;

            &:hover {
                background: rgba(0, 0, 0, 0.02);
            }

            &:last-child {
                border-bottom: none;
            }

            &.mpz-inactive {
                opacity: 0.6;
            }
        }

        td {
            padding: $spacing-md;
            vertical-align: middle;
        }
    }

    // Column widths
    .mpz-col-flag {
        width: 60px;
        text-align: center;
    }

    // Only data cells should have large font for flag emojis
    td.mpz-col-flag {
        font-size: 24px;
    }

    // Header should have same font size as other headers
    th.mpz-col-flag {
        font-size: 12px;
    }

    .mpz-col-name {
        width: auto;
        min-width: 200px;

        strong {
            display: block;
            font-weight: 600;
            color: $text-primary;
        }

        .mpz-native-name {
            color: $text-secondary;
            font-size: 12px;
        }
    }

    .mpz-col-code {
        width: 80px;
        font-family: monospace;
        font-weight: 600;
    }

    .mpz-col-locale {
        width: 100px;
        font-family: monospace;
        color: $text-secondary;
    }

    .mpz-col-direction {
        width: 100px;
    }

    .mpz-col-status {
        width: 80px;
        text-align: center;
    }

    .mpz-col-actions {
        width: 250px;
        text-align: right;
    }
}

/* ==========================================================================
   Sort Button
   ========================================================================== */

.mpz-sort-button {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    padding: 0;
    cursor: pointer;
    transition: color $transition-fast;

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

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

/* ==========================================================================
   Direction Badge
   ========================================================================== */

.mpz-direction {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: $border-radius-sm;
    text-transform: uppercase;
    letter-spacing: 0.5px;

    &.mpz-direction-ltr {
        background: rgba($info-color, 0.1);
        color: $info-color;
    }

    &.mpz-direction-rtl {
        background: rgba($warning-color, 0.1);
        color: darken($warning-color, 10%);
    }
}

/* ==========================================================================
   Badge
   ========================================================================== */

.mpz-badge {
    display: inline-block;
    margin-left: $spacing-sm;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: $border-radius-sm;
    vertical-align: middle;

    &.mpz-badge-default {
        background: rgba($success-color, 0.1);
        color: $success-color;
    }
}

/* ==========================================================================
   Toggle Switch
   ========================================================================== */

.mpz-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: #ccc;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color $transition-fast;

    &::after {
        content: '';
        position: absolute;
        top: 2px;
        left: 2px;
        width: 20px;
        height: 20px;
        background: white;
        border-radius: 50%;
        transition: transform $transition-fast;
    }

    &.mpz-toggle--active {
        background: $success-color;

        &::after {
            transform: translateX(20px);
        }
    }

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

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

/* ==========================================================================
   Actions Group
   ========================================================================== */

.mpz-actions-group {
    display: flex;
    gap: $spacing-sm;
    justify-content: flex-end;
    align-items: center;
}

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

.mpz-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: $spacing-xl;
    text-align: center;

    p {
        margin-top: $spacing-md;
        color: $text-secondary;
    }
}

.mpz-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba($primary-color, 0.2);
    border-top-color: $primary-color;
    border-radius: 50%;
    animation: mpz-spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Empty State
   ========================================================================== */

.mpz-empty-state {
    padding: $spacing-xl;
    text-align: center;

    p {
        margin-bottom: $spacing-md;
        color: $text-secondary;
        font-size: 14px;
    }
}

/* ==========================================================================
   Language Form (Modal)
   ========================================================================== */

.mpz-language-form {
    display: flex;
    flex-direction: column;
    gap: $spacing-md;

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

        label {
            font-weight: 600;
            font-size: 13px;
            color: $text-primary;

            input[type="checkbox"] {
                margin-right: $spacing-xs;
            }
        }

        input,
        select {
            padding: $spacing-sm;
            font-size: 13px;
            border: 1px solid $border-color;
            border-radius: $border-radius-sm;
            transition: border-color $transition-fast;

            &:focus {
                outline: none;
                border-color: $primary-color;
                box-shadow: 0 0 0 3px rgba($primary-color, 0.1);
            }

            &:disabled {
                background: $background-light;
                cursor: not-allowed;
            }
        }

        small {
            color: $text-light;
            font-size: 12px;
        }
    }
}

/* ==========================================================================
   Modal Container
   ========================================================================== */

#mpz-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: $z-modal;
    display: none;
}

.mpz-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: $spacing-lg;
    overflow-y: auto;
}

.mpz-modal {
    background: $background-white;
    border-radius: $border-radius-lg;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: mpz-modal-enter 0.2s ease-out;
}

@keyframes mpz-modal-enter {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.mpz-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: $spacing-lg;
    border-bottom: 1px solid $border-color;
}

.mpz-modal__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.mpz-modal__header-controls {
    display: flex;
    gap: $spacing-sm;
    align-items: center;
}

.mpz-modal__close {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    font-size: 24px;
    color: $text-light;
    cursor: pointer;
    border-radius: $border-radius-sm;
    transition: all $transition-fast;

    &:hover {
        background: rgba(0, 0, 0, 0.05);
        color: $text-primary;
    }

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

.mpz-modal__content {
    padding: $spacing-lg;
    overflow-y: auto;
    flex: 1;
}

.mpz-modal__actions {
    display: flex;
    gap: $spacing-sm;
    justify-content: flex-end;
    padding: $spacing-lg;
    border-top: 1px solid $border-color;
}

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

@media screen and (max-width: 782px) {
    .mpz-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: $spacing-md;

        h1 {
            font-size: 20px;
        }
    }

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

        .mpz-col-flag {
            font-size: 20px;
        }

        .mpz-col-code,
        .mpz-col-locale {
            font-size: 11px;
        }

        .mpz-col-direction {
            display: none;
        }

        .mpz-col-actions {
            width: auto;
        }
    }

    .mpz-actions-group {
        flex-direction: column;
        align-items: stretch;
    }

    .mpz-modal {
        max-width: 100%;
        margin: $spacing-sm;
    }
}

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

@media (prefers-color-scheme: dark) {
    .mpz-languages-table-container,
    .mpz-modal {
        background: $dark-surface;
        border-color: $dark-border;
    }

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

            th {
                color: $dark-text;
            }
        }

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

                &:hover {
                    background: rgba(255, 255, 255, 0.05);
                }
            }

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

    .mpz-modal__header,
    .mpz-modal__actions {
        border-color: $dark-border;
    }

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

            &:disabled {
                background: $dark-surface;
            }
        }
    }
}

body.admin-color-midnight,
body.admin-color-ectoplasm {
    .mpz-languages-table-container,
    .mpz-modal {
        background: $dark-surface;
        border-color: $dark-border;
    }

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

            th {
                color: $dark-text;
            }
        }

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

                &:hover {
                    background: rgba(255, 255, 255, 0.05);
                }
            }

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

    .mpz-modal__header,
    .mpz-modal__actions {
        border-color: $dark-border;
    }

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

            &:disabled {
                background: $dark-surface;
            }
        }
    }
}
