/* ==========================================================================
   WooCommerce Price Updater — shadcn/ui inspired design system
   Plain CSS port of shadcn's token system (no build step required).
   ========================================================================== */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Design tokens (shadcn "default" theme, HSL channels)
   -------------------------------------------------------------------------- */
:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 72% 51%;
    --destructive-foreground: 0 0% 98%;
    --success: 142 71% 45%;
    --success-foreground: 0 0% 98%;
    --warning: 38 92% 50%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 240 5.9% 10%;
    --radius: 0.65rem;

    /* Brand surface — always dark so the white/rainbow logo stays legible */
    --brand: 240 10% 5%;
    --brand-foreground: 0 0% 98%;

    color-scheme: light;
}

:root.dark,
:root[data-theme="dark"] {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 10% 5.5%;
    --card-foreground: 0 0% 98%;
    --popover: 240 10% 5.5%;
    --popover-foreground: 0 0% 98%;
    --primary: 0 0% 98%;
    --primary-foreground: 240 5.9% 10%;
    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 45%;
    --destructive-foreground: 0 0% 98%;
    --success: 142 65% 47%;
    --warning: 38 92% 55%;
    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 18%;
    --ring: 240 4.9% 83.9%;

    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --background: 240 10% 3.9%;
        --foreground: 0 0% 98%;
        --card: 240 10% 5.5%;
        --card-foreground: 0 0% 98%;
        --popover: 240 10% 5.5%;
        --popover-foreground: 0 0% 98%;
        --primary: 0 0% 98%;
        --primary-foreground: 240 5.9% 10%;
        --secondary: 240 3.7% 15.9%;
        --secondary-foreground: 0 0% 98%;
        --muted: 240 3.7% 15.9%;
        --muted-foreground: 240 5% 64.9%;
        --accent: 240 3.7% 15.9%;
        --accent-foreground: 0 0% 98%;
        --destructive: 0 62.8% 45%;
        --destructive-foreground: 0 0% 98%;
        --success: 142 65% 47%;
        --warning: 38 92% 55%;
        --border: 240 3.7% 15.9%;
        --input: 240 3.7% 18%;
        --ring: 240 4.9% 83.9%;

        color-scheme: dark;
    }
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
}

a {
    color: inherit;
}

/* --------------------------------------------------------------------------
   Brand top bar (dark in both themes — carries the logo)
   -------------------------------------------------------------------------- */
.appbar {
    background: hsl(var(--brand));
    color: hsl(var(--brand-foreground));
    border-bottom: 1px solid hsl(0 0% 100% / 0.08);
    position: sticky;
    top: 0;
    z-index: 30;
}

.appbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 68px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-logo {
    height: 34px;
    width: auto;
    display: block;
}

.brand-divider {
    width: 1px;
    height: 26px;
    background: hsl(0 0% 100% / 0.15);
}

.brand-title {
    font-size: 14px;
    font-weight: 500;
    color: hsl(0 0% 100% / 0.72);
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.appbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.appbar-user {
    font-size: 13px;
    color: hsl(0 0% 100% / 0.62);
    white-space: nowrap;
}

.appbar-user strong {
    color: hsl(0 0% 100% / 0.95);
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.16s ease, color 0.16s ease,
        border-color 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
    user-select: none;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.btn-primary:hover:not(:disabled) {
    background: hsl(var(--primary) / 0.9);
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover:not(:disabled) {
    background: hsl(var(--secondary) / 0.7);
}

.btn-outline {
    background: transparent;
    border-color: hsl(var(--border));
    color: hsl(var(--foreground));
}

.btn-outline:hover:not(:disabled) {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.btn-destructive {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.btn-destructive:hover:not(:disabled) {
    background: hsl(var(--destructive) / 0.9);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    height: 36px;
    padding: 0 14px;
    font-size: 13px;
}

/* Ghost icon button (used in the dark appbar) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: calc(var(--radius) - 2px);
    background: hsl(0 0% 100% / 0.06);
    border: 1px solid hsl(0 0% 100% / 0.1);
    color: hsl(0 0% 100% / 0.9);
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.btn-icon:hover {
    background: hsl(0 0% 100% / 0.12);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-icon .icon-sun {
    display: none;
}

:root.dark .btn-icon .icon-sun,
:root[data-theme="dark"] .btn-icon .icon-sun {
    display: block;
}

:root.dark .btn-icon .icon-moon,
:root[data-theme="dark"] .btn-icon .icon-moon {
    display: none;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: 0 1px 2px 0 hsl(240 10% 3.9% / 0.04);
}

.card-header {
    padding: 22px 24px 0;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-desc {
    margin-top: 4px;
    font-size: 13px;
    color: hsl(var(--muted-foreground));
}

.card-body {
    padding: 22px 24px;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 16px;
}

.label {
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    color: hsl(var(--foreground));
}

.input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font-size: 14px;
    font-family: inherit;
    color: hsl(var(--foreground));
    background: hsl(var(--background));
    border: 1px solid hsl(var(--input));
    border-radius: calc(var(--radius) - 2px);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input::placeholder {
    color: hsl(var(--muted-foreground));
}

.input:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}

.input-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */
.alert {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-radius: calc(var(--radius) - 2px);
    font-size: 14px;
    border: 1px solid hsl(var(--border));
    background: hsl(var(--card));
    margin-bottom: 16px;
}

.alert-error {
    border-color: hsl(var(--destructive) / 0.5);
    background: hsl(var(--destructive) / 0.08);
    color: hsl(var(--destructive));
}

.alert-success {
    border-color: hsl(var(--success) / 0.5);
    background: hsl(var(--success) / 0.1);
    color: hsl(var(--success));
}

.alert-warning {
    border-color: hsl(var(--warning) / 0.5);
    background: hsl(var(--warning) / 0.1);
    color: hsl(var(--warning));
}

/* --------------------------------------------------------------------------
   Login screen
   -------------------------------------------------------------------------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(
            120% 120% at 50% 0%,
            hsl(var(--muted)) 0%,
            hsl(var(--background)) 60%
        );
}

.auth-card {
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.auth-brand {
    background: hsl(var(--brand));
    padding: 28px 24px;
    text-align: center;
}

.auth-brand img {
    height: 40px;
    width: auto;
}

.auth-brand p {
    margin-top: 12px;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: hsl(0 0% 100% / 0.55);
}

.auth-body {
    padding: 28px 26px 26px;
}

.auth-body h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.auth-body .sub {
    margin: 4px 0 22px;
    font-size: 13px;
    color: hsl(var(--muted-foreground));
}

.auth-hint {
    margin-top: 22px;
    text-align: center;
    font-size: 12px;
    color: hsl(var(--muted-foreground));
}

/* --------------------------------------------------------------------------
   Page + search
   -------------------------------------------------------------------------- */
main {
    padding: 32px 0 64px;
}

.page-head {
    margin-bottom: 22px;
}

.page-head h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-head p {
    margin-top: 4px;
    font-size: 14px;
    color: hsl(var(--muted-foreground));
}

.search-card {
    margin-bottom: 24px;
}

.search-box {
    display: flex;
    gap: 10px;
}

.search-box .input {
    flex: 1;
}

/* Results meta row */
.results-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 2px;
}

.results-meta .count {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
}

/* --------------------------------------------------------------------------
   Product list (shadcn table/card hybrid)
   -------------------------------------------------------------------------- */
.products {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) 116px 236px auto;
    gap: 18px;
    align-items: center;
    padding: 16px 18px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.product:hover {
    border-color: hsl(var(--ring) / 0.35);
    box-shadow: 0 2px 10px -4px hsl(240 10% 3.9% / 0.12);
}

.product-thumb {
    width: 56px;
    height: 56px;
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
    background: hsl(var(--muted));
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

.product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-thumb svg {
    width: 22px;
    height: 22px;
}

.product-meta {
    min-width: 0;
}

.product-meta h3 {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
    color: hsl(var(--muted-foreground));
}

.product-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: hsl(var(--muted-foreground));
    transition: color 0.16s ease;
}

.product-link:hover {
    color: hsl(var(--foreground));
}

.product-link svg {
    width: 12px;
    height: 12px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 999px;
    border: 1px solid hsl(var(--border));
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.badge-mono {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
}

.badge-sale {
    border-color: hsl(var(--success) / 0.4);
    background: hsl(var(--success) / 0.12);
    color: hsl(var(--success));
}

/* Current price column */
.price-current {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.price-current .cap {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: hsl(var(--muted-foreground));
    margin-bottom: 3px;
}

.price-current .mrp {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
    text-decoration: line-through;
}

.price-current .sell {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Editable price fields */
.price-edit {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.price-edit .field {
    margin-bottom: 0;
    gap: 5px;
}

.price-edit .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: hsl(var(--muted-foreground));
}

.price-edit .input {
    height: 38px;
}

.input-affix {
    position: relative;
    display: flex;
    align-items: center;
}

.input-affix .prefix {
    position: absolute;
    left: 11px;
    font-size: 13px;
    color: hsl(var(--muted-foreground));
    pointer-events: none;
}

.input-affix .input {
    padding-left: 24px;
}

/* Update action */
.product-action {
    display: flex;
    justify-content: flex-end;
}

.update-btn.is-success {
    background: hsl(var(--success));
    color: hsl(var(--success-foreground));
}

.update-btn.is-error {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

/* --------------------------------------------------------------------------
   Empty / loading states
   -------------------------------------------------------------------------- */
.state {
    text-align: center;
    padding: 56px 20px;
    color: hsl(var(--muted-foreground));
}

.state svg {
    width: 40px;
    height: 40px;
    margin-bottom: 14px;
    opacity: 0.5;
}

.state h3 {
    font-size: 15px;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: 4px;
}

.state p {
    font-size: 14px;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: -2px;
}

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

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toast-wrap {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 60;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    max-width: 380px;
    padding: 13px 15px;
    font-size: 14px;
    background: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    box-shadow: 0 10px 30px -10px hsl(240 10% 3.9% / 0.35);
    animation: toast-in 0.2s ease;
}

.toast.leaving {
    animation: toast-out 0.2s ease forwards;
}

.toast svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.toast-success svg {
    color: hsl(var(--success));
}

.toast-error svg {
    color: hsl(var(--destructive));
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 860px) {
    .product {
        grid-template-columns: 48px minmax(0, 1fr);
        gap: 14px;
    }

    .product-thumb {
        width: 48px;
        height: 48px;
        grid-row: 1 / 2;
    }

    .product-meta {
        grid-column: 2;
    }

    .price-current {
        grid-column: 1 / -1;
        display: flex;
        align-items: baseline;
        justify-content: flex-start;
        gap: 10px;
        text-align: left;
        padding-top: 4px;
        border-top: 1px dashed hsl(var(--border));
    }

    .price-current .cap {
        margin: 0;
    }

    .price-edit {
        grid-column: 1 / -1;
    }

    .product-action {
        grid-column: 1 / -1;
    }

    .product-action .btn {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .container {
        padding: 0 16px;
    }

    .brand-title,
    .appbar-user {
        display: none;
    }

    .search-box {
        flex-direction: column;
    }

    .toast-wrap {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        min-width: 0;
        max-width: none;
    }
}
