@use '../globals' as *;

/**
 * Settings Page Styles
 *
 * Styles for the plugin settings page with tabbed interface.
 *
 * @package MultilingualPressZone
 * @since 1.0.0
 */

.multilingual-press-zone-settings {
    max-width: 1200px;
    margin: 0 auto;
    padding: $spacing-lg;

    // Header
    &__header {
        margin-bottom: $spacing-xl;

        h1 {
            margin-bottom: $spacing-sm;
            color: $text-primary;
        }

        .description {
            color: $text-secondary;
            font-size: 14px;
            margin: 0;
        }
    }

    // Content container
    &__content {
        background: $background-white;
        border: 1px solid $border-color;
        border-radius: $border-radius-md;
        padding: $spacing-lg;
        margin-top: $spacing-lg;
    }
}

// Settings sections
.settings-section {
    h2 {
        margin-bottom: $spacing-lg;
        padding-bottom: $spacing-md;
        border-bottom: 2px solid $border-color;
        color: $text-primary;
        font-size: 18px;
        font-weight: 600;
    }

    h3 {
        margin-top: $spacing-lg;
        margin-bottom: $spacing-md;
        color: $text-primary;
        font-size: 16px;
        font-weight: 600;
    }

    .description {
        color: $text-secondary;
        font-size: 13px;
        margin-top: $spacing-xs;
        line-height: 1.5;
    }

    // Spacing between form groups
    > * + * {
        margin-top: $spacing-lg;
    }
}

// API Key wrapper with show/hide button
.api-key-wrapper {
    display: flex;
    gap: $spacing-sm;
    align-items: center;

    input {
        flex: 1;
    }

    button {
        flex-shrink: 0;
    }
}

// API actions (test button + status)
.api-actions {
    display: flex;
    gap: $spacing-md;
    align-items: center;
    margin-top: $spacing-lg;
}

// Connection status indicator
.connection-status {
    display: flex;
    align-items: center;
    gap: $spacing-sm;
    font-size: 14px;

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

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

    .status-unknown {
        color: $text-secondary;
    }
}

// Cache statistics
.cache-stats {
    background: $background-light;
    border: 1px solid $border-color;
    border-radius: $border-radius-md;
    padding: $spacing-lg;
    margin: $spacing-lg 0;

    h3 {
        margin-top: 0;
        margin-bottom: $spacing-md;
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: $spacing-md;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: $spacing-sm $spacing-md;
    background: $background-white;
    border: 1px solid $border-color;
    border-radius: $border-radius-sm;

    .stat-label {
        color: $text-secondary;
        font-size: 13px;
        font-weight: 500;
    }

    .stat-value {
        color: $text-primary;
        font-size: 16px;
        font-weight: 600;
    }
}

// Danger zone
.danger-zone {
    margin-top: $spacing-xl;
    padding: $spacing-lg;
    background: lighten($error-color, 45%);
    border: 1px solid lighten($error-color, 30%);
    border-radius: $border-radius-md;

    h3 {
        margin-top: 0;
        color: $error-color;
    }

    .description {
        color: darken($error-color, 10%);
        margin-bottom: $spacing-md;
    }
}

// Modal actions
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: $spacing-sm;
    margin-top: $spacing-lg;
    padding-top: $spacing-md;
    border-top: 1px solid $border-color;
}

// Loading state
.multilingual-press-zone-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: $spacing-xl;
    min-height: 300px;

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

.multilingual-press-zone-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid $border-color;
    border-top-color: $primary-color;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

// Error state
.multilingual-press-zone-error {
    padding: $spacing-xl;
    text-align: center;
    color: $error-color;

    .error-message {
        margin-top: $spacing-md;
        padding: $spacing-md;
        background: lighten($error-color, 45%);
        border: 1px solid lighten($error-color, 30%);
        border-radius: $border-radius-md;
        color: darken($error-color, 10%);
        font-weight: 500;
    }
}

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

@media screen and (max-width: 782px) {
    .multilingual-press-zone-settings {
        padding: $spacing-md;

        &__content {
            padding: $spacing-md;
        }
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .api-key-wrapper {
        flex-direction: column;
        align-items: stretch;

        button {
            width: 100%;
        }
    }

    .api-actions {
        flex-direction: column;
        align-items: stretch;

        button {
            width: 100%;
        }
    }

    .modal-actions {
        flex-direction: column;

        button {
            width: 100%;
        }
    }
}

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

@media (prefers-color-scheme: dark) {
    .multilingual-press-zone-settings {
        &__header {
            h1 {
                color: $dark-text;
            }

            .description {
                color: lighten($text-secondary, 20%);
            }
        }

        &__content {
            background: $dark-surface;
            border-color: $dark-border;
        }
    }

    .settings-section {
        h2, h3 {
            color: $dark-text;
            border-color: $dark-border;
        }

        .description {
            color: lighten($text-secondary, 20%);
        }
    }

    .cache-stats {
        background: $dark-bg;
        border-color: $dark-border;
    }

    .stat-item {
        background: $dark-surface;
        border-color: $dark-border;

        .stat-label {
            color: lighten($text-secondary, 20%);
        }

        .stat-value {
            color: $dark-text;
        }
    }

    .danger-zone {
        background: rgba($error-color, 0.1);
        border-color: rgba($error-color, 0.3);

        .description {
            color: lighten($error-color, 20%);
        }
    }

    .multilingual-press-zone-loading p {
        color: lighten($text-secondary, 20%);
    }

    .multilingual-press-zone-spinner {
        border-color: $dark-border;
        border-top-color: lighten($primary-color, 15%);
    }

    .multilingual-press-zone-error {
        .error-message {
            background: rgba($error-color, 0.1);
            border-color: rgba($error-color, 0.3);
            color: lighten($error-color, 20%);
        }
    }
}

// Explicit dark mode class (WordPress admin color scheme)
body.admin-color-midnight,
body.admin-color-ectoplasm {
    .multilingual-press-zone-settings {
        &__header {
            h1 {
                color: $dark-text;
            }

            .description {
                color: lighten($text-secondary, 20%);
            }
        }

        &__content {
            background: $dark-surface;
            border-color: $dark-border;
        }
    }

    .settings-section {
        h2, h3 {
            color: $dark-text;
            border-color: $dark-border;
        }

        .description {
            color: lighten($text-secondary, 20%);
        }
    }

    .cache-stats {
        background: $dark-bg;
        border-color: $dark-border;
    }

    .stat-item {
        background: $dark-surface;
        border-color: $dark-border;

        .stat-label {
            color: lighten($text-secondary, 20%);
        }

        .stat-value {
            color: $dark-text;
        }
    }
}
