/*
 * Tailpress Converter admin page.
 * Registered via FilamentAsset in index.php; loads on every panel page,
 * so every selector is tp- prefixed.
 */

/* ── Source mode toggle (connect vs upload dump) ──────────────────── */
/* Two centered choice buttons: the pair is capped and centered in the
   section so they read as a deliberate either/or control rather than two
   full-bleed header blocks. */
.tp-mode {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    max-width: 600px;
    margin: 0 auto 16px;
}

@media (max-width: 560px) {
    .tp-mode {
        grid-template-columns: 1fr;
    }
}

/* Raised, rounded, centered tile with a resting shadow + hover lift so it
   plainly reads as a pressable button (the old flat transparent card looked
   like static text). Transparent fill keeps it correct on light and dark. */
.tp-mode__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 18px;
    background: transparent;
    border: 1px solid color-mix(in oklch, var(--gray-300) 90%, transparent);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.15s;
}

.tp-mode__btn:hover {
    border-color: var(--primary-400);
    background: color-mix(in oklch, var(--primary-50) 60%, transparent);
    box-shadow: 0 6px 14px -4px rgb(0 0 0 / 0.12);
    transform: translateY(-1px);
}

.tp-mode__btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
}

.tp-mode__btn:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

.tp-mode__btn.is-active {
    border-color: var(--primary-500);
    background: color-mix(in oklch, var(--primary-50) 60%, transparent);
    box-shadow: 0 0 0 1px color-mix(in oklch, var(--primary-500) 35%, transparent), 0 4px 10px -4px rgb(0 0 0 / 0.12);
}

@media (prefers-reduced-motion: reduce) {
    .tp-mode__btn {
        transition: border-color 0.15s, background 0.15s;
    }
    .tp-mode__btn:hover,
    .tp-mode__btn:active {
        transform: none;
    }
}

.tp-mode__icon {
    width: 24px;
    height: 24px;
    color: var(--gray-400);
}

.tp-mode__btn.is-active .tp-mode__icon {
    color: var(--primary-500);
}

.tp-mode__title {
    font-size: 0.875rem;
    font-weight: 700;
}

.tp-mode__hint {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ── Connection form grid ─────────────────────────────────────────── */
.tp-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.tp-grid--dump {
    margin-bottom: 14px;
    max-width: 320px;
}

@media (max-width: 900px) {
    .tp-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.tp-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tp-field__label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-600);
}

.tp-connect-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
}

.tp-conn-ok {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgb(22 163 74);
    font-size: 0.875rem;
    font-weight: 600;
}

.tp-conn-ok__icon {
    width: 18px;
    height: 18px;
}

/* ── Import options ───────────────────────────────────────────────── */
.tp-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

@media (max-width: 700px) {
    .tp-options {
        grid-template-columns: 1fr;
    }
}

.tp-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid color-mix(in oklch, var(--gray-200) 70%, transparent);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.tp-option:hover {
    border-color: var(--primary-400);
    background: color-mix(in oklch, var(--primary-50) 40%, transparent);
}

/* The checkbox must never be flex-squeezed by a long hint text. */
.tp-option > input[type="checkbox"] {
    flex: 0 0 auto;
    margin-top: 2px;
}

.tp-option__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tp-option__title {
    font-size: 0.875rem;
    font-weight: 600;
}

.tp-option__hint {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ── Media ZIP drop zone ──────────────────────────────────────────── */
.tp-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 26px 16px;
    border: 2px dashed var(--gray-300);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}

.tp-zone:hover {
    border-color: var(--primary-500);
    background: color-mix(in oklch, var(--primary-50) 40%, transparent);
}

.tp-zone--has-file {
    border-color: rgb(34 197 94);
    background: rgb(240 253 244 / 0.5);
}

.tp-zone__input {
    display: none;
}

/* Visible "Browse files" affordance inside the drop zone so it plainly
   reads as a clickable upload field, not just a passive outlined box. The
   whole zone is a <label> wrapping the hidden input, so clicking the pill
   (or anywhere in the zone) opens the file picker. */
.tp-zone__browse {
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary-600);
    background: var(--primary-50);
    border: 1px solid var(--primary-200);
    border-radius: 8px;
    transition: background 0.15s, border-color 0.15s;
}

.tp-zone:hover .tp-zone__browse {
    background: var(--primary-100);
    border-color: var(--primary-400);
}

.tp-zone__icon {
    width: 28px;
    height: 28px;
    color: var(--gray-400);
}

.tp-zone__label {
    font-size: 0.875rem;
    font-weight: 600;
}

.tp-zone__hint {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.tp-error {
    margin-top: 8px;
    color: rgb(220 38 38);
    font-size: 0.8125rem;
}

.tp-uploading {
    margin-top: 8px;
    font-size: 0.8125rem;
    color: var(--gray-500);
}

/* ── Run button row ───────────────────────────────────────────────── */
.tp-run-row {
    display: flex;
    justify-content: flex-start;
}

/* ── Results table ────────────────────────────────────────────────── */
.tp-results {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.tp-results th {
    padding: 8px 12px;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    border-bottom: 1px solid color-mix(in oklch, var(--gray-200) 70%, transparent);
}

.tp-results td {
    padding: 8px 12px;
    border-bottom: 1px solid color-mix(in oklch, var(--gray-200) 40%, transparent);
}

.tp-results__entity {
    font-weight: 600;
}

.tp-results__num {
    font-variant-numeric: tabular-nums;
}

.tp-results__num--ok {
    color: rgb(22 163 74);
    font-weight: 700;
}

.tp-empty {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.tp-warnings {
    margin-top: 16px;
    padding: 12px 14px;
    background: rgb(254 252 232);
    border: 1px solid rgb(253 224 71 / 0.6);
    border-radius: 10px;
}

.tp-warnings__title {
    margin: 0 0 6px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: rgb(161 98 7);
}

.tp-warnings__list {
    margin: 0;
    padding-left: 18px;
    font-size: 0.8125rem;
    color: rgb(113 63 18);
}

/* ── Reset option + confirmation modal ─────────────────────────────── */

.tp-option--danger {
    border-color: rgb(254 202 202);
    background: rgb(254 242 242 / 0.5);
}

.tp-option--danger .tp-option__title {
    color: rgb(185 28 28);
}

.tp-option--danger:hover {
    border-color: rgb(252 165 165);
}

.dark .tp-option--danger {
    border-color: rgb(153 27 27 / 0.5);
    background: rgb(127 29 29 / 0.15);
}

.dark .tp-option--danger .tp-option__title {
    color: rgb(252 165 165);
}

.tp-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgb(15 23 42 / 0.5);
}

.tp-modal {
    width: 100%;
    max-width: 440px;
    padding: 24px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 20px 50px -10px rgb(0 0 0 / 0.35);
    text-align: center;
}

.dark .tp-modal {
    background: rgb(30 41 59);
}

.tp-modal__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: rgb(254 226 226);
    color: rgb(220 38 38);
}

.tp-modal__icon svg {
    width: 26px;
    height: 26px;
}

.dark .tp-modal__icon {
    background: rgb(127 29 29 / 0.4);
    color: rgb(252 165 165);
}

.tp-modal__title {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 700;
}

.tp-modal__text {
    margin: 0 0 10px;
    font-size: 0.8125rem;
    color: rgb(71 85 105);
}

.dark .tp-modal__text {
    color: rgb(148 163 184);
}

.tp-modal__text--muted {
    font-size: 0.75rem;
}

.tp-modal__list {
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgb(185 28 28);
}

.dark .tp-modal__list {
    color: rgb(252 165 165);
}

.tp-modal__actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}

/* ── Staged import progress ─────────────────────────────────────────── */
.tp-progress {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tp-progress__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.tp-progress__label {
    font-weight: 600;
    color: rgb(30 41 59);
}

.dark .tp-progress__label {
    color: rgb(226 232 240);
}

.tp-progress__step {
    font-size: 0.8125rem;
    color: rgb(100 116 139);
    white-space: nowrap;
}

.tp-progress__bar {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 0.6rem;
    border: 0;
    border-radius: 9999px;
    overflow: hidden;
    background-color: rgb(226 232 240);
}

.dark .tp-progress__bar {
    background-color: rgb(51 65 85);
}

.tp-progress__bar::-webkit-progress-bar {
    background-color: rgb(226 232 240);
    border-radius: 9999px;
}

.dark .tp-progress__bar::-webkit-progress-bar {
    background-color: rgb(51 65 85);
}

.tp-progress__bar::-webkit-progress-value {
    background-color: rgb(79 70 229);
    border-radius: 9999px;
    transition: inline-size 0.3s ease;
}

.tp-progress__bar::-moz-progress-bar {
    background-color: rgb(79 70 229);
    border-radius: 9999px;
}

/* Indeterminate (no value yet): gentle pulse so it doesn't look stalled. */
.tp-progress__bar:not([value]) {
    animation: tp-progress-pulse 1.2s ease-in-out infinite;
}

@keyframes tp-progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.tp-progress__count {
    align-self: flex-end;
    font-size: 0.8125rem;
    color: rgb(100 116 139);
    font-variant-numeric: tabular-nums;
}
