/*
 * Plumtier UI kit: tokens, buttons, form controls, cards and badges.
 *
 * Plain CSS on purpose, so the dashboard (React + Tailwind), the store pages the Worker renders,
 * and the plumtier.com site all share the same buttons and forms. This file is the source of
 * truth; `npm run sync-ui` copies it into site/public/.
 *
 * Selected states are a tinted background, never a border.
 */

:root {
    --pt-accent: #7a35e0;
    --pt-accent-hover: #6a28cc;
    --pt-accent-soft: color-mix(in oklab, var(--pt-accent) 10%, white);
    --pt-accent-text: color-mix(in oklab, var(--pt-accent) 85%, black);
    --pt-on-accent: #ffffff;

    --pt-bg: #f7f6fb;
    --pt-surface: #ffffff;
    --pt-surface-2: #f4f3f8;
    --pt-text: #18151f;
    --pt-text-2: #5d5869;
    --pt-text-3: #8d889a;
    --pt-line: rgba(24, 21, 31, 0.1);
    --pt-line-strong: rgba(24, 21, 31, 0.18);

    --pt-success: #15803d;
    --pt-success-soft: #e7f6ec;
    --pt-warning: #b45309;
    --pt-warning-soft: #fdf3e2;
    --pt-danger: #dc2626;
    --pt-danger-hover: #c21f1f;
    --pt-danger-soft: #fdecec;
    --pt-info: #2563eb;
    --pt-info-soft: #e8effd;

    --pt-radius-sm: 6px;
    --pt-radius: 8px;
    --pt-radius-lg: 12px;
    --pt-radius-xl: 16px;

    --pt-shadow-xs: 0 1px 2px rgba(24, 21, 31, 0.06);
    --pt-shadow-sm: 0 1px 2px rgba(24, 21, 31, 0.06), 0 1px 3px rgba(24, 21, 31, 0.08);
    --pt-shadow-md: 0 4px 12px -2px rgba(24, 21, 31, 0.08), 0 2px 4px -2px rgba(24, 21, 31, 0.06);
    --pt-shadow-lg: 0 24px 48px -16px rgba(24, 21, 31, 0.18), 0 8px 16px -8px rgba(24, 21, 31, 0.08);

    --pt-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --pt-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --pt-ease: cubic-bezier(0.2, 0, 0, 1);

    color-scheme: light;
}

:root[data-theme="dark"] {
    --pt-accent: #9b6cf0;
    --pt-accent-hover: #ab82f4;
    --pt-accent-soft: color-mix(in oklab, var(--pt-accent) 18%, #17141d);
    --pt-accent-text: color-mix(in oklab, var(--pt-accent) 70%, white);

    --pt-bg: #0f0d13;
    --pt-surface: #17141d;
    --pt-surface-2: #1f1b27;
    --pt-text: #f3f1f7;
    --pt-text-2: #aaa4b6;
    --pt-text-3: #7a7486;
    --pt-line: rgba(243, 241, 247, 0.09);
    --pt-line-strong: rgba(243, 241, 247, 0.16);

    --pt-success: #4ade80;
    --pt-success-soft: rgba(74, 222, 128, 0.12);
    --pt-warning: #fbbf24;
    --pt-warning-soft: rgba(251, 191, 36, 0.12);
    --pt-danger: #f87171;
    --pt-danger-hover: #fca5a5;
    --pt-danger-soft: rgba(248, 113, 113, 0.12);
    --pt-info: #60a5fa;
    --pt-info-soft: rgba(96, 165, 250, 0.12);

    --pt-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --pt-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
    --pt-shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
    --pt-shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, 0.6);

    color-scheme: dark;
}

/* ---------- Buttons ---------- */

.btn {
    --btn-bg: var(--pt-surface);
    --btn-fg: var(--pt-text);
    --btn-ring: var(--pt-line-strong);
    --btn-hover: var(--pt-surface-2);

    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    padding: 0 1rem;
    border: 0;
    border-radius: var(--pt-radius);
    background: var(--btn-bg);
    color: var(--btn-fg);
    box-shadow: inset 0 0 0 1px var(--btn-ring), var(--pt-shadow-xs);
    font: 500 0.875rem/1 var(--pt-font);
    letter-spacing: -0.005em;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    transition: background-color 150ms var(--pt-ease), box-shadow 150ms var(--pt-ease), transform 100ms var(--pt-ease), color 150ms var(--pt-ease);
}

.btn:hover {
    background: var(--btn-hover);
}

.btn:active {
    transform: translateY(0.5px) scale(0.99);
}

.btn:focus-visible {
    outline: 2px solid var(--pt-accent);
    outline-offset: 2px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

/* The filled accent button: a soft top highlight and a darker edge, like a pressed sticker. */
.btn-primary {
    --btn-bg: var(--pt-accent);
    --btn-fg: var(--pt-on-accent);
    --btn-hover: var(--pt-accent-hover);

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.22),
        inset 0 0 0 1px color-mix(in oklab, var(--pt-accent) 80%, black),
        0 1px 2px color-mix(in oklab, var(--pt-accent) 40%, transparent),
        0 2px 6px -1px color-mix(in oklab, var(--pt-accent) 35%, transparent);
}

.btn-dark {
    --btn-bg: var(--pt-text);
    --btn-fg: var(--pt-bg);
    --btn-hover: color-mix(in oklab, var(--pt-text) 85%, var(--pt-bg));

    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), var(--pt-shadow-sm);
}

.btn-danger {
    --btn-bg: var(--pt-danger);
    --btn-fg: #fff;
    --btn-hover: var(--pt-danger-hover);

    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), var(--pt-shadow-sm);
}

.btn-ghost {
    --btn-bg: transparent;
    --btn-fg: var(--pt-text-2);
    --btn-hover: var(--pt-surface-2);

    box-shadow: none;
}

.btn-ghost:hover {
    color: var(--pt-text);
}

.btn-soft {
    --btn-bg: var(--pt-accent-soft);
    --btn-fg: var(--pt-accent-text);
    --btn-hover: color-mix(in oklab, var(--pt-accent) 16%, var(--pt-surface));

    box-shadow: none;
}

.btn-sm {
    min-height: 2rem;
    padding: 0 0.75rem;
    font-size: 0.8125rem;
    border-radius: var(--pt-radius-sm);
}

.btn-lg {
    min-height: 3rem;
    padding: 0 1.375rem;
    font-size: 1rem;
    border-radius: var(--pt-radius-lg);
}

.btn-xl {
    min-height: 3.5rem;
    padding: 0 1.75rem;
    font-size: 1.0625rem;
    font-weight: 600;
    border-radius: var(--pt-radius-lg);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-icon {
    width: 2.5rem;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 2rem;
}

.btn[data-loading="true"] {
    color: transparent;
    pointer-events: none;
}

.btn[data-loading="true"]::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    border: 2px solid var(--btn-fg);
    border-right-color: transparent;
    animation: pt-spin 0.7s linear infinite;
}

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

/* ---------- Form controls ---------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.label {
    font: 500 0.875rem/1.25rem var(--pt-font);
    color: var(--pt-text);
}

.label .optional {
    color: var(--pt-text-3);
    font-weight: 400;
}

.help {
    font: 400 0.8125rem/1.25rem var(--pt-font);
    color: var(--pt-text-2);
}

.error-text {
    font: 500 0.8125rem/1.25rem var(--pt-font);
    color: var(--pt-danger);
}

.input,
.select,
.textarea {
    display: block;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: var(--pt-radius);
    background: var(--pt-surface);
    color: var(--pt-text);
    box-shadow: inset 0 0 0 1px var(--pt-line-strong), var(--pt-shadow-xs);
    font: 400 0.875rem/1.5 var(--pt-font);
    transition: box-shadow 150ms var(--pt-ease);
    appearance: none;
}

.input::placeholder,
.textarea::placeholder {
    color: var(--pt-text-3);
}

.input:hover,
.select:hover,
.textarea:hover {
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--pt-text) 30%, transparent), var(--pt-shadow-xs);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    box-shadow: inset 0 0 0 1px var(--pt-accent), 0 0 0 3px color-mix(in oklab, var(--pt-accent) 22%, transparent);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
    box-shadow: inset 0 0 0 1px var(--pt-danger), 0 0 0 3px color-mix(in oklab, var(--pt-danger) 15%, transparent);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
    background: var(--pt-surface-2);
    color: var(--pt-text-3);
    cursor: not-allowed;
}

.textarea {
    min-height: 6rem;
    resize: vertical;
}

.select {
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%238d889a'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.625rem center;
    background-size: 1.125rem;
}

/* An input with a fixed prefix or suffix, like "$" or "%". */
.input-group {
    display: flex;
    align-items: stretch;
    border-radius: var(--pt-radius);
    background: var(--pt-surface);
    box-shadow: inset 0 0 0 1px var(--pt-line-strong), var(--pt-shadow-xs);
    transition: box-shadow 150ms var(--pt-ease);
}

.input-group:focus-within {
    box-shadow: inset 0 0 0 1px var(--pt-accent), 0 0 0 3px color-mix(in oklab, var(--pt-accent) 22%, transparent);
}

.input-group .input {
    box-shadow: none;
    background: transparent;
}

.input-group .addon {
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    color: var(--pt-text-2);
    font: 500 0.875rem var(--pt-font);
    background: var(--pt-surface-2);
}

.input-group .addon:first-child {
    border-radius: var(--pt-radius) 0 0 var(--pt-radius);
}

.input-group .addon:last-child {
    border-radius: 0 var(--pt-radius) var(--pt-radius) 0;
}

.checkbox {
    appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    margin: 0;
    border-radius: 5px;
    background: var(--pt-surface);
    box-shadow: inset 0 0 0 1px var(--pt-line-strong);
    cursor: pointer;
    transition: background-color 120ms var(--pt-ease);
}

.checkbox:checked {
    background: var(--pt-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3E%3Cpath d='M12.2 4.6a.75.75 0 010 1.06l-5 5a.75.75 0 01-1.06 0l-2.4-2.4a.75.75 0 111.06-1.06l1.87 1.87 4.47-4.47a.75.75 0 011.06 0z'/%3E%3C/svg%3E") center / 0.875rem no-repeat;
    box-shadow: none;
}

.checkbox:focus-visible,
.switch:focus-visible {
    outline: 2px solid var(--pt-accent);
    outline-offset: 2px;
}

.switch {
    appearance: none;
    position: relative;
    width: 2.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    margin: 0;
    border-radius: 999px;
    background: var(--pt-line-strong);
    cursor: pointer;
    transition: background-color 150ms var(--pt-ease);
}

.switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    background: #fff;
    box-shadow: var(--pt-shadow-sm);
    transition: transform 180ms var(--pt-ease);
}

.switch:checked {
    background: var(--pt-accent);
}

.switch:checked::after {
    transform: translateX(1rem);
}

/* Segmented choice: options sit in a soft track; the selected one gets a raised surface. */
.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: calc(var(--pt-radius) + 2px);
    background: var(--pt-surface-2);
}

.segmented > button,
.segmented > label,
.segmented > a {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: 0;
    border-radius: var(--pt-radius-sm);
    background: transparent;
    color: var(--pt-text-2);
    font: 500 0.8125rem/1.25rem var(--pt-font);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 150ms var(--pt-ease), color 150ms var(--pt-ease);
}

.segmented > :hover {
    color: var(--pt-text);
}

.segmented > [aria-pressed="true"],
.segmented > [aria-current="page"],
.segmented > [aria-selected="true"],
.segmented > label:has(input:checked) {
    background: var(--pt-surface);
    color: var(--pt-text);
    box-shadow: var(--pt-shadow-sm);
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Option tiles (pricing tiers, variants): the selected tile gets a tinted fill. */
.option-tile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--pt-radius-lg);
    background: var(--pt-surface-2);
    color: var(--pt-text);
    cursor: pointer;
    transition: background-color 150ms var(--pt-ease);
}

.option-tile:hover {
    background: color-mix(in oklab, var(--pt-accent) 6%, var(--pt-surface-2));
}

.option-tile:has(input:checked),
.option-tile[aria-pressed="true"] {
    background: var(--pt-accent-soft);
    color: var(--pt-accent-text);
}

.option-tile input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.option-tile:has(input:focus-visible) {
    outline: 2px solid var(--pt-accent);
    outline-offset: 2px;
}

/* ---------- Surfaces ---------- */

.card {
    border-radius: var(--pt-radius-lg);
    background: var(--pt-surface);
    box-shadow: 0 0 0 1px var(--pt-line), var(--pt-shadow-sm);
}

.card-pad {
    padding: 1.5rem;
}

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    height: 1.375rem;
    padding: 0 0.5rem;
    border-radius: 999px;
    background: var(--pt-surface-2);
    color: var(--pt-text-2);
    font: 500 0.75rem/1 var(--pt-font);
    white-space: nowrap;
}

.badge-accent {
    background: var(--pt-accent-soft);
    color: var(--pt-accent-text);
}

.badge-success {
    background: var(--pt-success-soft);
    color: var(--pt-success);
}

.badge-warning {
    background: var(--pt-warning-soft);
    color: var(--pt-warning);
}

.badge-danger {
    background: var(--pt-danger-soft);
    color: var(--pt-danger);
}

.badge-info {
    background: var(--pt-info-soft);
    color: var(--pt-info);
}

.badge-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
}

/* ---------- Notices ---------- */

.notice {
    display: flex;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: var(--pt-radius);
    background: var(--pt-info-soft);
    color: var(--pt-text);
    font: 400 0.875rem/1.5 var(--pt-font);
}

.notice-danger {
    background: var(--pt-danger-soft);
}

.notice-success {
    background: var(--pt-success-soft);
}

.notice-warning {
    background: var(--pt-warning-soft);
}

.kbd,
.code {
    font-family: var(--pt-font-mono);
    font-size: 0.8125em;
    padding: 0.125rem 0.375rem;
    border-radius: 5px;
    background: var(--pt-surface-2);
}

@media (prefers-reduced-motion: reduce) {
    .btn,
    .input,
    .switch,
    .switch::after,
    .option-tile {
        transition: none;
    }
}
