.ws-alt-text-container {
    position: relative;
}

/* Down-arrow icon for the static button state */
.button.ws-generate-alt-text::after,
.wp-core-ui .button.ws-generate-alt-text::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-bottom: 2px solid #1d2327;
    border-right: 2px solid #1d2327;
    transform: rotate(45deg);
    margin-left: -12px;
    transition: opacity 0.2s;
    opacity: 1;
}

/* Hide the down-arrow when loading */
.button.ws-generate-alt-text.loading::after,
.wp-core-ui .button.ws-generate-alt-text.loading::after {
    opacity: 0;
}

/* Generate button layout (colors in .button.ws-generate-alt-text below) */
.ws-generate-alt-text {
    min-width: 175px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

@keyframes rotation {

  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.button.ws-generate-alt-text .spinner,
.button.ws-generate-alt-text .ws-generate-spinner,
.wp-core-ui .button.ws-generate-alt-text .spinner,
.wp-core-ui .button.ws-generate-alt-text .ws-generate-spinner {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s;
    float: none;
    margin: 0 0 0 5px;

    /* Reset WP core .spinner (background image, sizing, visibility) */
    background: none !important;
    background-image: none !important;
    background-size: 0 !important;
    width: 18px;
    height: 18px;

    /* Custom spinner ring */
    border: 2px solid #1d2327;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    box-sizing: border-box;
}

.button.ws-generate-alt-text .spinner::after,
.wp-core-ui .button.ws-generate-alt-text .spinner::after {
  content: '';  
  position: absolute;
  box-sizing: border-box;

  /* Adjusted positioning and size for the new spinner dimensions */
  left: 6px;
  top: 9px;
  border: 4px solid transparent;
  border-right-color: #1d2327;
  transform: rotate(-40deg);
}

.button.ws-generate-alt-text.loading .spinner,
.button.ws-generate-alt-text.loading .ws-generate-spinner,
.wp-core-ui .button.ws-generate-alt-text.loading .spinner,
.wp-core-ui .button.ws-generate-alt-text.loading .ws-generate-spinner {
    visibility: visible;
    opacity: 1;
    animation: rotation 1s linear infinite;
}

.ws-status-message {
    font-size: 13px;
    line-height: 1.4;
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    background: #fff;
}

.ws-status-message.is-hidden {
    display: none;
}

.ws-is-hidden {
    display: none;
}

.ws-status-message.error {
    color: #b32d2e;
    background: #fcf0f1;
}

.ws-status-message.success {
    color: #007017;
    background: #f0f6f0;
}

.ws-status-message.loading {
    color: #2271b1;
    background: #f0f6fc;
}

/* Modern Bulk Processing Styles. The left offset follows the admin menu width. */
.ws-bulk-progress-container {
    position: fixed;
    top: 32px;
    left: 160px;
    right: 0;
    background: #fff;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    z-index: 999;
    display: none;
    border-bottom: 1px solid #f0f0f1;
}

.ws-bulk-progress-bar {
    height: 6px;
    background-color: #f0f0f1;
    border-radius: 3px;
    overflow: hidden;
    margin: 12px 100px 0 100px;
}

.ws-bulk-progress-bar .progress {
    height: 100%;
    background-color: #58C791;
    width: 0;
    transition: width 0.3s ease;
    border-radius: 3px;
}

.ws-bulk-progress-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 100px 0 100px;
}

.ws-bulk-progress-text {
    font-size: 13px;
    color: #1d2327;
    font-weight: 500;
}

.ws-bulk-stop-button {
    background: #fff;
    color: #b32d2e;
    border: 1px solid #b32d2e;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: none;
    line-height: 1.4;
    height: auto;
}

.ws-bulk-stop-button:hover {
    background: #fcf0f1;
    color: #b32d2e;
}

.ws-bulk-stop-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Settings Page Styles */
.ws-settings-page {
    max-width: 1200px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    padding: 20px;
    border-radius: 8px;
    hyphens: auto;
}

.ws-settings-brand {
    display: flex;
    justify-content: center;
    padding: 0.5rem 0 1.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgb(226, 232, 240);
}

.ws-settings-brand-link {
    display: inline-block;
    line-height: 0;
    border-radius: 8px;
    transition: transform 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}

.ws-settings-brand-link:hover,
.ws-settings-brand-link:focus-visible {
    transform: translateY(-2px) scale(1.02);
    filter: drop-shadow(0 6px 16px rgba(24, 203, 150, 0.25));
    opacity: 0.95;
}

.ws-settings-brand-link:focus-visible {
    outline: 2px solid var(--wp-admin-theme-color, #2271b1);
    outline-offset: 2px;
}

.ws-settings-brand-logo {
    display: block;
    max-width: min(320px, 100%);
    height: auto;
}

.ws-settings-container {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ws-settings-card {
    background: #fff;
    border-radius: 8px;
    margin-bottom: 24px;
    overflow: hidden;
    border: 1px solid rgb(226, 232, 240);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ws-settings-card-header {
    padding: 16px 24px;
    border-bottom: 1px solid rgb(226, 232, 240);
}

.ws-settings-card-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: rgb(30, 41, 59);
    line-height: 1.4;
}

.ws-settings-description {
    margin: 4px 0 0;
    color: rgb(71, 85, 105);
    font-size: 13px;
    line-height: 1.5;
}

.ws-settings-card-content {
    padding: 16px 24px;
}

.ws-settings-field {
    margin-bottom: 16px;
}

.ws-settings-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: rgb(30, 41, 59);
    font-size: 13px;
}

.ws-settings-select {
    width: 100%;
    max-width: 250px;
    padding: 4px 8px;
    border: 1px solid rgb(203, 213, 225);
    border-radius: 4px;
    font-size: 13px;
    color: rgb(30, 41, 59);
    background-color: #fff;
    line-height: 1.5;
    height: 28px;
}

.ws-settings-select:focus {
    border-color: rgb(148, 163, 184);
    box-shadow: 0 0 0 1px rgb(148, 163, 184);
}

.ws-settings-select:focus-visible {
    outline: 2px solid var(--wp-admin-theme-color, #2271b1);
    outline-offset: 2px;
}

.ws-settings-field-group {
    margin-bottom: 0;
}

.ws-setting-help {
    color: #666;
    font-size: 12px;
    margin-top: 10px;
    line-height: 1.5;
    padding: 0;
}

/* API key inline action buttons */
.ws-settings-btn,
.ws-save-api-key-button,
.ws-deactivate-api-key {
    background: #58C791;
    border: none;
    color: #1d2327;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 500;
    height: 38px;
    line-height: 1.4;
    border-radius: 4px;
    box-shadow: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.ws-settings-btn:hover,
.ws-save-api-key-button:hover,
.ws-deactivate-api-key:hover {
    background: #49B583;
    color: #1d2327;
    transform: none;
    box-shadow: none;
}

.ws-settings-btn:active,
.ws-save-api-key-button:active,
.ws-deactivate-api-key:active {
    transform: none;
    box-shadow: none;
    background: #49B583;
    color: #1d2327;
}

.ws-settings-btn:disabled,
.ws-save-api-key-button:disabled,
.ws-deactivate-api-key:disabled {
    background: #ccc;
    color: #FFF;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Generate alt text + settings Save Settings submit */
.button.ws-generate-alt-text,
.button.ws-generate-alt-text:hover,
.button.ws-generate-alt-text:focus,
.button.ws-generate-alt-text:active,
.button.ws-generate-alt-text.loading,
.button.ws-generate-alt-text.loading:hover,
.button.ws-generate-alt-text.loading:focus,
.button.ws-generate-alt-text.loading:active,
.wp-core-ui .button.ws-generate-alt-text,
.wp-core-ui .button.ws-generate-alt-text:hover,
.wp-core-ui .button.ws-generate-alt-text:focus,
.wp-core-ui .button.ws-generate-alt-text:active,
.wp-core-ui .button.ws-generate-alt-text.loading,
.wp-core-ui .button.ws-generate-alt-text.loading:hover,
.wp-core-ui .button.ws-generate-alt-text.loading:focus,
.wp-core-ui .button.ws-generate-alt-text.loading:active,
.ws-settings-page .p-submit .button.button-primary {
    background: #58C791 !important;
    background-color: #58C791 !important;
    border: none !important;
    border-color: #58C791 !important;
    color: #1d2327 !important;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 500;
    height: 38px;
    line-height: 1.4;
    border-radius: 4px;
    box-shadow: none !important;
    transition: all 0.3s ease;
    cursor: pointer;
    text-shadow: none;
    vertical-align: middle;
}

.button.ws-generate-alt-text:hover:not(.loading),
.button.ws-generate-alt-text:focus:not(.loading),
.button.ws-generate-alt-text:active:not(.loading),
.wp-core-ui .button.ws-generate-alt-text:hover:not(.loading),
.wp-core-ui .button.ws-generate-alt-text:focus:not(.loading),
.wp-core-ui .button.ws-generate-alt-text:active:not(.loading) {
    background: #49B583 !important;
    background-color: #49B583 !important;
    border-color: #49B583 !important;
    color: #1d2327 !important;
    transform: none;
    box-shadow: none !important;
}

/* stylelint-disable no-descending-specificity -- Source order sets the hover, loading, disabled, and focus states on purpose. A reorder changes the cascade. */
.button.ws-generate-alt-text.loading,
.button.ws-generate-alt-text.loading:hover,
.button.ws-generate-alt-text.loading:focus,
.button.ws-generate-alt-text.loading:active,
.wp-core-ui .button.ws-generate-alt-text.loading,
.wp-core-ui .button.ws-generate-alt-text.loading:hover,
.wp-core-ui .button.ws-generate-alt-text.loading:focus,
.wp-core-ui .button.ws-generate-alt-text.loading:active {
    cursor: wait;
}
/* stylelint-enable no-descending-specificity */

.ws-settings-page .p-submit .button.button-primary {
    margin-top: 16px;
    height: 28px;
}

.ws-settings-page .p-submit .button.button-primary:hover,
.ws-settings-page .p-submit .button.button-primary:focus,
.ws-settings-page .p-submit .button.button-primary:active {
    background: #49B583 !important;
    background-color: #49B583 !important;
    border-color: #49B583 !important;
    color: #1d2327 !important;
    transform: none;
    box-shadow: none !important;
}

/* stylelint-disable no-descending-specificity -- Source order sets the hover, loading, disabled, and focus states on purpose. A reorder changes the cascade. */
.button.ws-generate-alt-text:disabled,
.button.ws-generate-alt-text.loading:disabled,
.wp-core-ui .button.ws-generate-alt-text:disabled,
.wp-core-ui .button.ws-generate-alt-text.loading:disabled,
.ws-settings-page .p-submit .button.button-primary:disabled {
    background: #ccc !important;
    background-color: #ccc !important;
    border-color: #ccc !important;
    color: #FFF !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none !important;
}
/* stylelint-enable no-descending-specificity */

/* Remove existing container styles and replace with new ones */
.ws-image-alt-text-generator-container {
    padding: 2rem;
    min-height: 100vh;
}

/* Style for each section box */
.ws-settings-section {
    background-color: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Update form elements to match new design */
.ws-settings-section form {
    max-width: 800px;
    margin: 0 auto;
}

.ws-settings-section h2 {
    color: #1e293b;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

/* Update input and button styles */
.ws-settings-section input[type="text"],
.ws-settings-section input[type="password"],
.ws-settings-section select {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;

    width: 100%;
    max-width: 400px;
}

/* Add some spacing between form elements */
.ws-form-group {
    margin-bottom: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {

    .ws-image-alt-text-generator-container {
        padding: 1rem;
    }
    
    .ws-settings-section {
        padding: 1rem;
    }

    .ws-settings-brand {
        padding: 0.25rem 0 1.25rem;
    }
}

/* API Key input styling */
.ws-settings-field input[type="password"] {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    width: 100%;
    max-width: 400px;
    font-family: monospace;
}

.ws-settings-field input[type="password"]:focus {
    border-color: #94a3b8;
    box-shadow: 0 0 0 1px #94a3b8;
}

/* stylelint-disable no-descending-specificity -- Source order sets the hover, loading, disabled, and focus states on purpose. A reorder changes the cascade. */
.ws-settings-field input[type="password"]:focus-visible,
.ws-settings-btn:focus-visible,
.ws-save-api-key-button:focus-visible,
.ws-deactivate-api-key:focus-visible,
.button.ws-generate-alt-text:focus-visible,
.ws-settings-page .p-submit .button.button-primary:focus-visible,
.ws-bulk-stop-button:focus-visible {
    outline: 2px solid var(--wp-admin-theme-color, #2271b1);
    outline-offset: 2px;
}
/* stylelint-enable no-descending-specificity */

.ws-alt-toggle-switch input:focus-visible + .ws-alt-toggle-slider {
    box-shadow: 0 0 0 2px var(--wp-admin-theme-color, #2271b1);
}

.ws-credits-info {
    margin-top: 15px;
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-left: 4px solid #4CAF50;
    border-radius: 3px;
}

.ws-credits-info p {
    margin: 0;
    color: #333;
    font-size: 14px;
}

.ws-credits-info strong {
    font-weight: 600;
}

/* Toggle Switch - More specific and isolated styling */
.ws-alt-toggle-container {
    position: relative;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

.ws-alt-toggle-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 19px;
    margin: 0;
}

.ws-alt-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
}

/* stylelint-disable no-descending-specificity -- Source order sets the hover, loading, disabled, and focus states on purpose. A reorder changes the cascade. */
.ws-alt-toggle-slider {
    border: 1px solid #8c8f94;
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 19px;
}
/* stylelint-enable no-descending-specificity */

.ws-alt-toggle-slider::before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.ws-alt-toggle-switch input:checked + .ws-alt-toggle-slider {
    background-color: #58C791;
}

.ws-alt-toggle-switch input:focus + .ws-alt-toggle-slider {
    box-shadow: 0 0 1px #58C791;
}

.ws-alt-toggle-switch input:checked + .ws-alt-toggle-slider::before {
    transform: translateX(19px);
}

.ws-alt-toggle-label {
    display: flex;
    align-items: center;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.ws-alt-toggle-text {
    margin-left: 0;
    font-size: 14px;
    color: #333;
}

/* Toggle wrapper for better alignment */
.ws-toggle-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

/* Adjust help text alignment */
.ws-toggle-wrapper .ws-setting-help {
    color: #666;
    font-size: 12px;
    margin: 4px 0 0 46px; /* Align with the toggle text */
    line-height: 1.5;
    padding: 0;
}

.ws-keywords-info {
    background-color: #f8f8f8;
    padding: 10px 12px;
    border-left: 4px solid #ccc;
    margin-top: 10px;
    line-height: 1.4;
    border-radius: 0 4px 4px 0;
}

.ws-keywords-info.has-keywords {
    border-left-color: #4CAF50;
    background-color: #f1f8e9;
}

.ws-keywords-info.no-keywords {
    border-left-color: #FFC107;
    background-color: #fff8e1;
}

.ws-keywords-info .parent-info {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #666;
}

.ws-keywords-info .parent-info a {
    color: #0073aa;
    font-style: italic;
}

.ws-keywords-info .parent-info a:hover {
    color: #006391;
}

/* API key row */
.ws-api-key-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* stylelint-disable no-descending-specificity -- Source order sets the hover, loading, disabled, and focus states on purpose. A reorder changes the cascade. */
.ws-api-key-input-wrapper input[type="password"] {
    flex: 1;
    margin: 0;
}
/* stylelint-enable no-descending-specificity */

.ws-api-key-input-wrapper .ws-save-api-key-button,
.ws-api-key-input-wrapper .ws-deactivate-api-key {
    min-width: 100px;
    flex-shrink: 0;
}

.ws-api-key-input-wrapper .ws-save-api-key-button.ws-is-hidden,
.ws-api-key-input-wrapper .ws-deactivate-api-key.ws-is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ws-api-key-input-wrapper .ws-save-api-key-button.ws-is-visible,
.ws-api-key-input-wrapper .ws-deactivate-api-key.ws-is-visible {
    opacity: 1;
    visibility: visible;
}

#wsimgaltgen-api-key-help.ws-is-hidden {
    display: none;
}

.ws-powered-by-container {
    margin-top: 24px;
    text-align: right;
}

.ws-powered-by-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    line-height: 1;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.ws-powered-by-link:hover,
.ws-powered-by-link:focus,
.ws-powered-by-link:focus-visible {
    text-decoration: none;
    background-color: #f8f9fa;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.ws-logo {
    width: auto;
    flex-shrink: 0;
    vertical-align: middle;
}

.ws-powered-by-text {
    font-size: 12px;
    color: #555;
    font-weight: 500;
    font-style: italic;
}

.ws-powered-by-link:hover .ws-powered-by-text,
.ws-powered-by-link:focus .ws-powered-by-text {
    color: #333;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

@media (prefers-reduced-motion: reduce) {

    .ws-generate-alt-text,
    .ws-generate-alt-text::after,
    .ws-generate-alt-text .spinner,
    .ws-generate-alt-text .ws-generate-spinner,
    .ws-bulk-progress-bar .progress,
    .ws-powered-by-link {
        animation: none;
        transition: none;
    }

    .ws-settings-brand-link {
        transition: none;
    }

    .ws-generate-alt-text:hover,
    .ws-generate-alt-text:active,
    .ws-powered-by-link:hover,
    .ws-powered-by-link:focus-visible,
    .ws-settings-brand-link:hover,
    .ws-settings-brand-link:focus-visible {
        transform: none;
    }
}

/* Bulk progress panel: follow the collapsed admin menu and the mobile admin bar. */
.folded .ws-bulk-progress-container {
    left: 36px;
}

@media screen and (max-width: 960px) {

    .auto-fold .ws-bulk-progress-container {
        left: 36px;
    }
}

@media screen and (max-width: 782px) {

    .ws-bulk-progress-container,
    .auto-fold .ws-bulk-progress-container {
        top: 46px;
        left: 0;
        padding: 12px;
    }

    .ws-bulk-progress-status,
    .ws-bulk-progress-bar {
        margin-left: 0;
        margin-right: 0;
    }
}
