/**
 * The app's look for the WordPress components it uses (the "wp-components"
 * script and stylesheet), and for the elements wp-admin styles (forms.css,
 * common.css). Selectors carry the components' own classes plus .wtofe-app
 * and the app's class, so they outrank WordPress's rules, including the
 * CSS-in-JS ones it injects at runtime, on every version from WordPress 6.0
 * (components 19.8) on.
 */

/* ── Text inputs, selects, textareas (TextControl, SelectControl, TextareaControl) */

/*
 * No spacing below the fields (WordPress adds it to the field inside each
 * control; older versions even inside SelectControl's): FieldRow and the
 * page layouts space them.
 */
.wtofe-app .components-base-control .components-base-control__field {
    margin: 0;
}

.wtofe-app .wtofe-control .components-text-control__input,
.wtofe-app .wtofe-control .components-textarea-control__input,
.wtofe-app .wtofe-control .components-input-control__container .components-select-control__input {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 36px;
    margin: 0;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 22px;
    color: var(--wtofe-color-ink);
    background-color: #fff;
    border: 1px solid #d4d0e6;
    border-radius: 6px;
    box-shadow: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.wtofe-app .wtofe-control .components-textarea-control__input {
    min-height: 72px;
    resize: vertical;
}

.wtofe-app .wtofe-control .components-text-control__input:hover,
.wtofe-app .wtofe-control .components-textarea-control__input:hover {
    border-color: #a9a4c8;
}

.wtofe-app .wtofe-control .components-text-control__input:focus,
.wtofe-app .wtofe-control .components-textarea-control__input:focus {
    color: var(--wtofe-color-ink);
    border-color: var(--wtofe-color-primary);
    outline: 2px solid transparent;
    box-shadow: 0 0 0 1px var(--wtofe-color-primary);
}

.wtofe-app .wtofe-control .components-text-control__input:disabled,
.wtofe-app .wtofe-control .components-text-control__input[readonly] {
    color: var(--wtofe-color-muted);
    background-color: #f6f5fb;
    border-color: #e3e0f0;
}

/*
 * SelectControl draws its border on a backdrop behind a borderless <select>.
 * Its styles are CSS-in-JS with a tripled class (.css-x.css-x.css-x),
 * injected after this file, hence the extra container class here.
 */
.wtofe-app .wtofe-control .components-input-control__container .components-select-control__input {
    height: 36px;
    padding-right: 32px;
    background: transparent;
    border-color: transparent;
    cursor: pointer;
}

.wtofe-app .wtofe-control .components-input-control__container .components-input-control__backdrop {
    border: 1px solid #d4d0e6;
    border-radius: 6px;
    box-shadow: none;
}

.wtofe-app .wtofe-control .components-input-control__container:hover .components-input-control__backdrop {
    border-color: #a9a4c8;
}

.wtofe-app .wtofe-control .components-input-control__container:focus-within .components-input-control__backdrop {
    border-color: var(--wtofe-color-primary);
    box-shadow: 0 0 0 1px var(--wtofe-color-primary);
}

.wtofe-app .wtofe-control .components-input-control__suffix,
.wtofe-app .wtofe-control .components-select-control__arrow-wrapper {
    color: var(--wtofe-color-muted);
}

.wtofe-app .wtofe-input--mono .components-text-control__input {
    font-family: var(--wtofe-font-mono);
    letter-spacing: 2px;
}

/* Field sizes, set on the control's wrapper. */
.wtofe-app .wtofe-field-sm {
    width: 7rem;
}

.wtofe-app .wtofe-field-md {
    max-width: 28rem;
}

.wtofe-app .wtofe-field-lg {
    max-width: 42rem;
}

.wtofe-app .wtofe-field-auto {
    width: auto;
}

.wtofe-app .wtofe-field-compact .components-text-control__input {
    min-height: 28px;
    padding: 2px 8px;
    font-size: 13px;
    line-height: 22px;
}

/* ── Checkbox (CheckboxControl) ──────────────────────────────────────────── */

/* The app's text size; WordPress's wrapper sets 13px (CSS-in-JS, hence the weight). */
.wtofe-app .wtofe-checkbox.components-base-control.components-checkbox-control {
    font-size: 14px;
    line-height: 1.5;
}

/* Box beside the label (WordPress 6.0 sets them inline, newer versions in a row). */
.wtofe-app .wtofe-checkbox .components-base-control__field,
.wtofe-app .wtofe-checkbox .components-h-stack {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

/* Level with the label's first line, also when the label wraps. */
.wtofe-app .wtofe-checkbox .components-checkbox-control__input-container {
    position: relative;
    display: block;
    flex: none;
    width: 16px;
    height: 16px;
    /* Half of (line height 1.5em − box), from the font size: WordPress sets its own line height here. */
    margin: calc(0.75em - 8px) 0 0;
}

.wtofe-app .wtofe-checkbox .components-checkbox-control__input[type="checkbox"] {
    width: 16px;
    min-width: 16px;
    height: 16px;
    margin: 0;
    background: #fff;
    border: 1px solid #a9a4c8;
    border-radius: 3px;
    box-shadow: none;
    cursor: pointer;
}

.wtofe-app .wtofe-checkbox .components-checkbox-control__input[type="checkbox"]:checked {
    background: var(--wtofe-color-primary);
    border-color: var(--wtofe-color-primary);
}

.wtofe-app .wtofe-checkbox .components-checkbox-control__input[type="checkbox"]:focus {
    outline: 2px solid transparent;
    box-shadow: none;
}

.wtofe-app .wtofe-checkbox .components-checkbox-control__input[type="checkbox"]:focus-visible {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wtofe-color-primary);
}

.wtofe-app .wtofe-checkbox .components-checkbox-control__checked {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    fill: #fff;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.wtofe-app .wtofe-checkbox .components-checkbox-control__label {
    font-size: inherit;
    line-height: inherit;
    color: var(--wtofe-color-ink);
    cursor: pointer;
}

/* ── Colour swatch input ─────────────────────────────────────────────────── */

.wtofe-app .wtofe-color {
    width: 44px;
    height: 32px;
    margin: 0;
    padding: 2px;
    background: #fff;
    border: 1px solid #d4d0e6;
    border-radius: 6px;
    cursor: pointer;
}

/* ── Switch (FormToggle) ─────────────────────────────────────────────────── */

.wtofe-app .wtofe-switch.components-form-toggle {
    position: relative;
    display: inline-block;
    flex: none;
    width: 36px;
    height: 18px;
    vertical-align: middle;
}

.wtofe-app .wtofe-switch .components-form-toggle__track {
    position: absolute;
    inset: 0;
    width: 36px;
    height: 18px;
    background: #b4afd0;
    border: 0;
    border-radius: 999px;
    box-shadow: none;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.wtofe-app .wtofe-switch.is-checked .components-form-toggle__track {
    background: var(--wtofe-color-primary);
}

.wtofe-app .wtofe-switch .components-form-toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 0;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transform: none;
    transition: transform 0.2s;
}

.wtofe-app .wtofe-switch.is-checked .components-form-toggle__thumb {
    background: #fff;
    transform: translateX(18px);
}

/* The real checkbox, invisible, over the whole switch. */
.wtofe-app .wtofe-switch .components-form-toggle__input {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
}

.wtofe-app .wtofe-switch .components-form-toggle__input:focus + .components-form-toggle__track {
    box-shadow: none;
}

.wtofe-app .wtofe-switch .components-form-toggle__input:focus-visible + .components-form-toggle__track {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wtofe-color-primary);
}

/* ── Buttons (Button, with the app's variants instead of WordPress's) ────── */

.wtofe-app .components-button.wtofe-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: auto;
    min-height: 34px;
    margin: 0;
    padding: 7px 15px;
    overflow: hidden;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 18px;
    white-space: nowrap;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 6px;
    box-shadow: none;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

/* WordPress fills icons in buttons; lucide icons are outlines. */
.wtofe-app .components-button.wtofe-btn svg {
    fill: none;
}

.wtofe-app .components-button.wtofe-btn:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

.wtofe-app .components-button.wtofe-btn:focus-visible {
    outline: 2px solid transparent;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wtofe-color-primary);
}

.wtofe-app .components-button.wtofe-btn:disabled,
.wtofe-app .components-button.wtofe-btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
}

.wtofe-app .components-button.wtofe-btn--sm {
    min-height: 28px;
    padding: 4px 10px;
    font-size: 13px;
}

/* An icon-only button (dialog close). */
.wtofe-app .components-button.wtofe-btn--icon {
    min-height: 0;
    padding: 4px;
    border-radius: 4px;
}

.wtofe-app .components-button.wtofe-btn--primary,
.wtofe-app .components-button.wtofe-btn--primary:focus {
    color: #fff;
    background: var(--wtofe-color-primary);
    border-color: var(--wtofe-color-primary);
}

.wtofe-app .components-button.wtofe-btn--primary:hover:not(:disabled) {
    color: #fff;
    background: var(--wtofe-color-primary-dark);
    border-color: var(--wtofe-color-primary-dark);
}

.wtofe-app .components-button.wtofe-btn--outline,
.wtofe-app .components-button.wtofe-btn--outline:focus {
    color: var(--wtofe-color-primary);
    background: #fff;
    border-color: var(--wtofe-color-primary);
}

.wtofe-app .components-button.wtofe-btn--outline:hover:not(:disabled) {
    color: var(--wtofe-color-primary-dark);
    background: var(--wtofe-color-primary-light);
    border-color: var(--wtofe-color-primary-dark);
}

.wtofe-app .components-button.wtofe-btn--secondary,
.wtofe-app .components-button.wtofe-btn--secondary:focus {
    color: var(--wtofe-color-ink);
    background: #fff;
    border-color: #d4d0e6;
}

.wtofe-app .components-button.wtofe-btn--secondary:hover:not(:disabled) {
    color: var(--wtofe-color-ink);
    background: var(--wtofe-color-soft);
    border-color: #a9a4c8;
}

.wtofe-app .components-button.wtofe-btn--ghost,
.wtofe-app .components-button.wtofe-btn--ghost:focus {
    color: var(--wtofe-color-muted);
    background: transparent;
}

.wtofe-app .components-button.wtofe-btn--ghost:hover:not(:disabled) {
    color: var(--wtofe-color-ink);
    background: var(--wtofe-color-primary-light);
}

.wtofe-app .components-button.wtofe-btn--danger,
.wtofe-app .components-button.wtofe-btn--danger:focus {
    color: #dc2626;
    background: transparent;
}

.wtofe-app .components-button.wtofe-btn--danger:hover:not(:disabled) {
    color: #dc2626;
    background: #fef2f2;
}

.wtofe-app .components-button.wtofe-btn--danger-outline,
.wtofe-app .components-button.wtofe-btn--danger-outline:focus {
    color: #dc2626;
    background: #fff;
    border-color: #fca5a5;
}

.wtofe-app .components-button.wtofe-btn--danger-outline:hover:not(:disabled) {
    color: #dc2626;
    background: #fef2f2;
    border-color: #dc2626;
}

/* Pending state: a soft ripple behind the label while a request runs. */
.wtofe-app .components-button.wtofe-btn.is-pending::before,
.wtofe-app .components-button.wtofe-btn.is-pending::after {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    content: '';
    pointer-events: none;
    background: color-mix(in srgb, var(--wtofe-color-primary) 30%, transparent);
    border-radius: 50%;
    animation: wtofe-ripple 1.2s ease-out infinite;
}

.wtofe-app .components-button.wtofe-btn.is-pending::after {
    animation-delay: 0.6s;
}

@keyframes wtofe-ripple {
    to {
        opacity: 0;
        transform: scale(18);
    }
}

/* ── Card (Card, CardHeader, CardBody) ───────────────────────────────────── */

.wtofe-app .components-card.wtofe-card {
    background: #fff;
    border: 1px solid var(--wtofe-color-line);
    border-radius: 8px;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

/* The parts' own padding goes; the app's layout inside them pads instead. */
.wtofe-app .components-card__header.wtofe-card__header {
    min-height: 0;
    padding: 0;
    border-bottom: 1px solid var(--wtofe-color-line);
}

.wtofe-app .components-card__body.wtofe-card__body {
    padding: 0;
}

/* ── Notice (Notice; the app draws the box inside it) ────────────────────── */

.wtofe-app .wtofe-notice.components-notice {
    display: block;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
}

.wtofe-app .wtofe-notice .components-notice__content {
    margin: 0;
}

/* ── Modal (Modal; the app draws the header, body and footer) ────────────── */

.wtofe-app.wtofe-modal-overlay {
    background: rgb(0 0 0 / 0.55);
}

.wtofe-app .components-modal__frame.wtofe-modal {
    width: calc(100% - 2rem);
    min-width: 0;
    max-width: 480px;
    height: auto;
    max-height: 85vh;
    margin: auto;
    border-radius: 6px;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

.wtofe-app .components-modal__frame.wtofe-modal--lg {
    max-width: 680px;
}

.wtofe-app .wtofe-modal .components-modal__content {
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* ── Brand bar: the same blue as the highlighted WordPress menu item ─────── */

.wtofe-app .wtofe-brand-bar {
    background: var(--wtofe-color-primary);
}

/* ── Links that wp-admin would recolour on hover/focus ──────────────────── */

.wtofe-app .wtofe-header-link,
.wtofe-app .wtofe-header-link:hover,
.wtofe-app .wtofe-header-link:focus {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    text-decoration: none;
    box-shadow: none;
}

/* Underline rather than recolour: a paler text would lose contrast on the blue bar. */
.wtofe-app .wtofe-header-link:hover,
.wtofe-app .wtofe-header-link:focus-visible {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.wtofe-app .wtofe-header-link:focus-visible {
    outline: 1px solid #fff;
    outline-offset: 3px;
}

.wtofe-app .wtofe-nav-link,
.wtofe-app .wtofe-nav-link:hover,
.wtofe-app .wtofe-nav-link:focus {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 14px 0;
    font-size: 14px;
    font-weight: 400;
    color: var(--wtofe-color-ink);
    white-space: nowrap;
    text-decoration: none;
    box-shadow: none;
}

.wtofe-app .wtofe-nav-link:hover {
    color: var(--wtofe-color-primary-dark);
}

/* TanStack Router's <Link> marks the current tab with aria-current="page". */
.wtofe-app .wtofe-nav-link[aria-current="page"] {
    font-weight: 600;
    color: var(--wtofe-color-primary);
}

.wtofe-app .wtofe-nav-link[aria-current="page"]::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 2px;
    content: '';
    background: var(--wtofe-color-primary);
    border-radius: 2px 2px 0 0;
}

.wtofe-app .wtofe-nav-link:focus-visible {
    outline: 2px solid var(--wtofe-color-primary);
    outline-offset: -2px;
}

/* ── Status pill ─────────────────────────────────────────────────────────── */

.wtofe-app .wtofe-pill,
.wtofe-app .wtofe-pill:hover,
.wtofe-app .wtofe-pill:focus {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 20px;
    white-space: nowrap;
    text-decoration: none;
    border-radius: 999px;
    box-shadow: none;
}

.wtofe-app .wtofe-pill--success,
.wtofe-app .wtofe-pill--success:hover,
.wtofe-app .wtofe-pill--success:focus {
    color: #1e7a1e;
    background: #edf7ed;
}

.wtofe-app .wtofe-pill--warning,
.wtofe-app .wtofe-pill--warning:hover,
.wtofe-app .wtofe-pill--warning:focus {
    color: #9a6a00;
    background: #fdf3e0;
}

.wtofe-app a.wtofe-pill:hover {
    filter: brightness(0.97);
}

.wtofe-app .wtofe-pill__dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
}

/* ── Anchor highlight (fix links from error messages) ───────────────────── */

.wtofe-app .wtofe-highlight {
    outline: 2px solid var(--wtofe-color-primary);
    outline-offset: 3px;
    border-radius: 6px;
    transition: outline-color 1s;
}

/* ── wp-admin notices moved into the app ────────────────────────────────── */

.wtofe-app .wtofe-notices .notice,
.wtofe-app .wtofe-notices div.updated,
.wtofe-app .wtofe-notices div.error {
    margin: 0 0 16px;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
