/*
 * base.css
 *
 * Reset, typography and the shared Soft Float primitives used by every view:
 * buttons, tiles, chips, switches, radio cards, fields, search tiles, sheets,
 * dialogs, empty states and toasts.
 *
 * Colour rule: solid accent or ink fill = tappable. Info panels use the accent
 * tint or a grey surface.
 */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font);
    font-size: var(--fs-body);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[v-cloak] {
    display: none !important;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    background: none;
    border: 0;
}

button:disabled {
    cursor: not-allowed;
}

a {
    color: var(--ink);
}

a:hover {
    color: var(--text-2);
}

img {
    display: block;
    max-width: 100%;
}

svg {
    flex: none;
}

h1,
h2,
h3,
h4 {
    font-weight: 800;
    letter-spacing: -0.02em;
}

:focus-visible {
    outline: 3px solid var(--accent-ring);
    outline-offset: 2px;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--track-off);
    border-radius: var(--r-pill);
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.muted {
    color: var(--muted);
}

.caption {
    font-size: var(--fs-caption);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ---------- Buttons ---------- */

/* Heights are minimums: a label that does not fit wraps to a second centred line instead of being clipped */
.btn {
    min-height: 52px;
    padding: 6px 20px;
    border: 0;
    border-radius: var(--r-16);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: var(--fs-button);
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-press) var(--ease);
}

.btn:active:not(:disabled) {
    transform: scale(.98);
}

.btn:disabled {
    opacity: .45;
}

.btn--ink {
    background: var(--ink);
    color: var(--on-fill);
}

@media (hover: hover) and (pointer: fine) {
    .btn--ink:hover:not(:disabled) {
        background: var(--ink-hover);
        color: var(--on-fill);
    }
}

.btn--accent {
    background: var(--accent);
    color: var(--on-fill);
}

@media (hover: hover) and (pointer: fine) {
    .btn--accent:hover:not(:disabled) {
        background: var(--accent-strong);
        color: var(--on-fill);
    }
}

.btn--grey {
    background: var(--control);
    color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
    .btn--grey:hover:not(:disabled) {
        background: var(--hover);
    }
}

.btn--white {
    background: var(--surface);
    color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
    .btn--white:hover:not(:disabled) {
        background: var(--surface-2);
    }
}

.btn--outline {
    background: var(--surface);
    color: var(--accent-strong);
    box-shadow: inset 0 0 0 2px var(--accent-ring);
}

@media (hover: hover) and (pointer: fine) {
    .btn--outline:hover:not(:disabled) {
        box-shadow: inset 0 0 0 2px var(--accent);
    }
}

.btn--error {
    background: var(--error);
    color: var(--on-fill);
}

@media (hover: hover) and (pointer: fine) {
    .btn--error:hover:not(:disabled) {
        background: var(--error-strong);
    }
}

.btn--accent-text {
    color: var(--accent-strong);
}

.btn--error-text {
    color: var(--error-text);
}

.btn--sm {
    min-height: 36px;
    padding: 4px 14px;
    border-radius: var(--r-pill);
    font-size: var(--fs-secondary);
    font-weight: 600;
}

.btn--md {
    min-height: 48px;
    border-radius: var(--r-14);
    font-weight: 700;
}

.btn--lg {
    min-height: 60px;
    border-radius: var(--r-20);
    font-size: var(--fs-lead);
}

.btn--xl {
    min-height: 76px;
    border-radius: var(--r-22);
    font-size: var(--fs-lead);
}

.btn--block {
    width: 100%;
}

.btn--stack {
    height: auto;
    min-height: 64px;
    padding: 10px 18px;
    border-radius: var(--r-20);
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    text-align: left;
    white-space: normal;
}

.btn--stack .btn-sub {
    font-size: var(--fs-secondary);
    font-weight: 500;
}

.btn--accent .btn-sub {
    color: var(--accent-on-muted);
}

.btn--outline .btn-sub {
    color: var(--text-2);
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: var(--r-14);
    background: var(--control);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--dur-fast) var(--ease), transform var(--dur-press) var(--ease);
}

.icon-btn:active:not(:disabled) {
    transform: scale(.94);
}

@media (hover: hover) and (pointer: fine) {
    .icon-btn:hover:not(:disabled) {
        background: var(--hover);
    }
}

.icon-btn--danger {
    background: var(--error-tint);
    color: var(--error-text);
}

@media (hover: hover) and (pointer: fine) {
    .icon-btn--danger:hover:not(:disabled) {
        background: var(--error-tint-hover);
    }
}

.icon-btn--round {
    border-radius: 50%;
}

.spinner-inline {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2.5px solid currentColor;
    border-right-color: transparent;
    animation: sf-spin .8s linear infinite;
}

/* ---------- Tiles, chips, avatars ---------- */

.tile {
    background: var(--surface);
    border-radius: var(--r-26);
}

.tile--pad {
    padding: 22px;
}

.soft {
    background: var(--surface-2);
    border-radius: var(--r-18);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.soft__label {
    font-size: var(--fs-caption);
    font-weight: 600;
    color: var(--muted);
}

.soft__value {
    font-weight: 800;
    overflow-wrap: anywhere;
}

/* Long amounts (KRW, LBP, COP) step down so they stay on one line in their card */
.amount--long {
    --amount-scale: 0.8;
}

.amount--xlong {
    --amount-scale: 0.65;
}

.panel {
    border-radius: var(--r-24);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel--accent {
    background: var(--accent-tint);
}

.panel--grey {
    background: var(--surface-2);
}

.panel--warning {
    background: var(--warning-surface);
}

.panel__head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel__icon {
    width: 44px;
    height: 44px;
    border-radius: var(--r-14);
    background: var(--surface);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.panel__title {
    font-weight: 800;
    font-size: var(--fs-card);
}

.panel__text {
    font-size: var(--fs-secondary);
    color: var(--text-2);
}

.panel--grey .panel__text {
    color: var(--muted);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: var(--r-pill);
    font-size: var(--fs-caption);
    font-weight: 700;
    white-space: nowrap;
    background: var(--control);
    color: var(--text-2);
}

.chip--accent {
    background: var(--accent-tint);
    color: var(--accent-strong);
}

.chip--outline {
    background: var(--surface);
    color: var(--accent-strong);
    box-shadow: inset 0 0 0 1.5px var(--accent-ring);
}

.chip--success {
    background: var(--success-tint);
    color: var(--success-text);
}

.chip--warning {
    background: var(--warning-tint);
    color: var(--warning-text);
}

.chip--error {
    background: var(--error-tint);
    color: var(--error-text);
}

.chip--white {
    background: var(--surface);
    color: var(--text-2);
}

.chip--lg {
    padding: 7px 14px;
    font-size: var(--fs-secondary);
    font-weight: 800;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--control);
    color: var(--ink);
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    text-transform: uppercase;
}

.avatar--white {
    background: var(--surface);
}

.avatar--accent {
    background: var(--accent-tint);
    color: var(--accent-strong);
}

.flag {
    width: 20px;
    height: 14px;
    border-radius: var(--r-4);
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(20, 22, 27, .08);
    flex: none;
}

/* ---------- Pill filter chips (selection = accent tint) ---------- */

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill {
    height: 44px;
    padding: 0 20px;
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text-2);
    font-weight: 600;
    transition: background-color var(--dur-fast) var(--ease), transform var(--dur-press) var(--ease);
}

.pill:active {
    transform: scale(.96);
}

@media (hover: hover) and (pointer: fine) {
    .pill:hover {
        background: var(--surface-2);
    }
}

@media (max-width: 600px) {
    .pill-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin: 0 -16px;
        padding: 0 16px 2px;
        scrollbar-width: none;
    }

    .pill-row::-webkit-scrollbar {
        display: none;
    }

    .pill {
        flex: none;
    }
}

/* Tint alone is as light as the grey ground, so the accent ring gives the selected pill its edge */
.pill.is-active,
.pill[aria-pressed="true"] {
    background: var(--accent-tint);
    color: var(--accent-strong);
    font-weight: 700;
    box-shadow: inset 0 0 0 1.5px var(--accent-ring);
}

/* ---------- Switch (wraps a real checkbox) ---------- */

.switch {
    position: relative;
    display: inline-flex;
    flex: none;
    width: 46px;
    height: 28px;
}

.switch input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}

.switch__track {
    width: 100%;
    height: 100%;
    border-radius: var(--r-pill);
    background: var(--track-off);
    padding: 3px;
    display: flex;
    transition: background-color var(--dur-fast) var(--ease);
}

.switch__knob {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(20, 22, 27, .18);
    transition: transform var(--dur-fast) var(--ease);
}

.switch input:checked + .switch__track {
    background: var(--accent);
}

.switch input:checked + .switch__track .switch__knob {
    transform: translateX(18px);
}

.switch input:focus-visible + .switch__track {
    outline: 3px solid var(--accent-ring);
    outline-offset: 2px;
}

/* ---------- Radio cards and segmented control (wrap real radios) ---------- */

.radio-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.radio-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 12px 16px;
    border-radius: var(--r-18);
    background: var(--surface-2);
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-press) var(--ease);
}

.radio-card:active {
    transform: scale(.98);
}

.radio-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.radio-card__dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    background: var(--surface);
    flex: none;
    transition: border var(--dur-fast) var(--ease);
}

.radio-card__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.radio-card__label {
    font-weight: 700;
}

.radio-card__hint {
    font-size: var(--fs-secondary);
    color: var(--muted);
}

@media (hover: hover) and (pointer: fine) {
    .radio-card:hover {
        background: var(--control);
    }
}

.radio-card:has(input:checked) {
    background: var(--accent-tint);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.radio-card:has(input:checked) .radio-card__dot {
    border: 7px solid var(--accent);
}

.radio-card:has(input:checked) .radio-card__label {
    color: var(--accent-strong);
}

.radio-card:has(input:focus-visible) {
    outline: 3px solid var(--accent-ring);
    outline-offset: 2px;
}

.seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border-radius: var(--r-pill);
    background: var(--control);
}

.seg label {
    position: relative;
    height: 40px;
    padding: 0 16px;
    border-radius: var(--r-pill);
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
}

.seg input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.seg label:has(input:checked) {
    background: var(--surface);
    color: var(--accent-strong);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(20, 22, 27, .12);
}

.seg label:has(input:focus-visible) {
    outline: 3px solid var(--accent-ring);
}

/* ---------- Fields ---------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    font-size: var(--fs-secondary);
    font-weight: 700;
    color: var(--text-2);
}

.field input,
.field select,
.field textarea,
.input {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--r-16);
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--hairline);
    color: var(--ink);
    font-size: var(--fs-button);
    font-weight: 500;
    outline: 0;
    transition: box-shadow var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.field select {
    appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%235E626C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus {
    background-color: var(--surface);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.field__hint {
    font-size: var(--fs-caption);
    font-weight: 500;
    color: var(--muted);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.field-grid .span-2 {
    grid-column: span 2;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

/* A destructive or secondary action kept apart on the left (Delete product) */
.form-actions__start {
    margin-right: auto;
}

/* ---------- Search tile ---------- */

.search {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: 0 22px;
    border-radius: var(--r-26);
    background: var(--surface);
    color: var(--muted);
}

.search input {
    flex: 1;
    min-width: 0;
    height: 52px;
    border: 0;
    outline: 0;
    background: transparent;
    font-size: var(--fs-card);
    font-weight: 500;
    color: var(--ink);
}

.search input::placeholder {
    color: var(--muted);
}

.search:focus-within {
    box-shadow: inset 0 0 0 2px var(--accent-ring);
}

/* ---------- Sheet (floating side panel) ---------- */

.sheet {
    background: var(--surface);
    border-radius: var(--r-32);
    padding: 10px 20px 20px;
    box-shadow: var(--shadow-sheet);
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.sheet > * {
    flex-shrink: 0;
}

.sheet__handle {
    align-self: center;
    width: 44px;
    height: 5px;
    border-radius: var(--r-pill);
    background: var(--track-off);
    flex: none;
}

.sheet__placeholder {
    padding: 48px 12px;
    text-align: center;
    color: var(--muted);
    font-weight: 600;
}

/* ---------- Dialogs ---------- */

.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-dialog);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(201, 205, 213, .72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow-y: auto;
    animation: sf-fade var(--dur-fast) var(--ease);
}

.dialog {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: auto;
    background: var(--surface);
    border-radius: var(--r-32);
    padding: 22px 24px 24px;
    box-shadow: var(--shadow-dialog);
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: sf-pop var(--dur-enter) var(--ease);
}

.dialog--wide {
    max-width: 720px;
}

.dialog__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.dialog__head-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dialog__label {
    font-size: var(--fs-secondary);
    font-weight: 600;
    color: var(--muted);
}

.dialog__title {
    font-size: var(--fs-title);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.dialog__amount {
    font-size: calc(var(--fs-amount) * var(--amount-scale, 1));
    white-space: nowrap;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.dialog__text {
    font-size: var(--fs-button);
    color: var(--text-2);
}

/* ---------- Empty state ---------- */

.empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--muted);
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.empty svg {
    color: var(--track-off);
}

/* ---------- Toasts ---------- */

/* Bottom left on wide screens, clear of the basket / detail side sheet */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 20px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: min(520px, calc(100vw - 32px));
    pointer-events: none;
}

.toast-message {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding: 14px 18px;
    border-radius: var(--r-20);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sheet);
    font-weight: 600;
    cursor: pointer;
    animation: sf-toast-in var(--dur-enter) var(--ease);
}

.toast-message::before {
    content: '';
    width: 10px;
    height: 10px;
    margin-top: 5px;
    border-radius: 50%;
    background: var(--ink);
    flex: none;
}

.toast-success::before {
    background: var(--success);
}

.toast-warning::before {
    background: var(--warning);
}

.toast-error::before {
    background: var(--error);
}

.toast-error {
    box-shadow: var(--shadow-sheet), inset 0 0 0 1.5px var(--error-tint);
}

/* ---------- Animations ---------- */

/* Up to 900px the basket is a bottom sheet, so toasts go to the top */
@media (max-width: 900px) {
    .toast-container {
        top: 12px;
        bottom: auto;
        left: 50%;
        transform: translateX(-50%);
        align-items: center;
    }
}

@keyframes sf-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes sf-pulse {
    0% {
        transform: scale(.85);
        opacity: .55;
    }

    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

@keyframes sf-fade {
    from {
        opacity: 0;
    }
}

@keyframes sf-pop {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.98);
    }
}

@keyframes sf-toast-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

@keyframes sf-flash {
    0% {
        background-color: var(--accent-tint);
    }

    100% {
        background-color: transparent;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

.toast-leave-active {
    transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.toast-leave-to {
    opacity: 0;
    transform: translateY(-8px);
}


/* ---------- Shared layout bits ---------- */

.btn-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    grid-auto-flow: column;
    gap: 8px;
}

.span-2 {
    grid-column: span 2;
}

.flag--lg {
    width: 22px;
    height: 15px;
}

.status-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--r-20);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.status-icon--error {
    background: var(--error-tint);
    color: var(--error-text);
}

.status-icon--warning {
    background: var(--warning-tint);
    color: var(--warning-text);
}

.status-icon--success {
    background: var(--success-tint);
    color: var(--success-text);
}

.dialog-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

@media (max-width: 767px) {
    .field input,
    .field select,
    .field textarea,
    .input,
    .search input {
        font-size: var(--fs-lead);
    }
}

@media (max-width: 600px) {
    .field-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .field-grid .span-2,
    .field-grid .field {
        grid-column: auto;
    }
}
