/* ============================================================
   Kingsman — shared components
   buttons, fields, product cards, modal, toast, skeleton,
   stepper, OTP, suggest dropdown, empty states, stars
   ============================================================ */

/* ---------------- buttons (capsule, like the iOS DefaultButton) ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding-inline: 22px;
    border-radius: var(--r-pill);
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    transition: transform 0.2s var(--ease-spring), box-shadow 0.25s ease,
        background 0.25s ease, color 0.25s ease, opacity 0.2s;
    position: relative;
    overflow: hidden;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:not(:disabled):active { transform: scale(0.96); }
.btn .icon svg { width: 18px; height: 18px; }

.btn--primary {
    background: var(--gold-grad);
    color: #221803;
    box-shadow: var(--shadow-gold);
}
.btn--primary:not(:disabled):hover { box-shadow: 0 14px 34px -10px rgba(241, 164, 36, 0.75); transform: translateY(-1px); }
.btn--primary::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.55) 50%, transparent 60%);
    transform: translateX(-120%);
}
.btn--primary:not(:disabled):hover::after { transform: translateX(120%); transition: transform 0.7s ease; }

.btn--dark { background: var(--text); color: var(--bg); }
.btn--dark:not(:disabled):hover { opacity: 0.88; }

.btn--ghost {
    background: transparent;
    border: 1.5px solid var(--hairline-strong);
    color: var(--text);
}
.btn--ghost:not(:disabled):hover { border-color: var(--gold); color: var(--gold); }

.btn--link {
    height: auto;
    padding: 4px 6px;
    color: var(--gold);
    font-weight: 600;
    border-radius: var(--r-sm);
}
.btn--link:disabled { color: var(--text-3); }

.btn--danger { background: transparent; border: 1.5px solid var(--danger); color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { height: 36px; padding-inline: 16px; font-size: 13px; }

.btn--loading { color: transparent !important; pointer-events: none; }
.btn--loading::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2.5px solid rgba(34, 24, 3, 0.25);
    border-top-color: #221803;
    animation: spin 0.7s linear infinite;
}
.btn--ghost.btn--loading::before, .btn--dark.btn--loading::before {
    border-color: var(--hairline-strong);
    border-top-color: var(--text);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- fields (floating-label, like DefaultTextField) ---------------- */

.field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 16px;
    background: var(--surface);
    border: 1.5px solid var(--hairline-strong);
    border-radius: var(--r-md);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    cursor: text;
}
.field:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(241, 164, 36, 0.14);
}
.field--error { border-color: var(--danger); }
.field__label {
    position: absolute;
    top: -8px;
    left: 12px;
    padding-inline: 5px;
    background: var(--surface);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-2);
    border-radius: 4px;
}
.field:focus-within .field__label { color: var(--gold); }
.field__prefix { font-weight: 700; color: var(--text-2); }
.field__input {
    flex: 1;
    min-width: 0;
    height: 100%;
    background: none;
    border: 0;
    outline: none;
    font-size: 15px;
    font-weight: 600;
}
.field__input::placeholder { color: var(--text-3); font-weight: 500; }
.field__hint { font-size: 12px; color: var(--danger); margin: 6px 4px 0; }

textarea.field__input { padding-block: 14px; resize: vertical; }
.field--area { height: auto; min-height: 96px; align-items: stretch; }

select.field__input { appearance: none; cursor: pointer; }

/* ---------------- product card ---------------- */

.grid { display: grid; gap: 18px; }
.grid--products { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1080px) { .grid--products { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .grid--products { grid-template-columns: repeat(2, 1fr); gap: 12px; } }

.pcard {
    display: flex;
    flex-direction: column;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--hairline);
    overflow: hidden;
    transition: transform 0.35s var(--ease-out), box-shadow 0.35s ease, border-color 0.3s;
}
.pcard:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lift);
    border-color: transparent;
}

.pcard__media {
    position: relative;
    aspect-ratio: 5 / 6;
    background: var(--surface-2);
    overflow: hidden;
}
.pcard__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease-out), opacity 0.45s ease;
}
.pcard:hover .pcard__img { transform: scale(1.06); }
.pcard__img--alt { opacity: 0; }
.pcard:hover .pcard__img--alt { opacity: 1; }

.badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    padding: 4px 10px;
    border-radius: var(--r-pill);
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.03em;
}
.badge--sale { background: var(--danger); color: #fff; }
.badge--new { background: var(--gold-grad); color: #221803; }

.pcard__like {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: var(--text-2);
    transition: color 0.2s, transform 0.25s var(--ease-spring);
    box-shadow: var(--shadow-card);
}
.pcard__like .icon svg { width: 19px; height: 19px; }
.pcard__like:hover { color: var(--danger); transform: scale(1.1); }
.pcard__like.is-liked { color: var(--danger); }
.pcard__like.is-liked .icon svg { fill: currentColor; }
.pcard__like--pop { animation: like-pop 0.4s var(--ease-spring); }
@keyframes like-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.35) rotate(-6deg); }
    100% { transform: scale(1); }
}

.pcard__body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pcard__brand {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold-deep);
}
[data-theme="dark"] .pcard__brand { color: var(--gold-soft); }
.pcard__name {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}
.pcard__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.pcard__price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pcard__price-now { font-size: 15px; font-weight: 800; }
.pcard__price-old { font-size: 12px; color: var(--text-3); text-decoration: line-through; }
.pcard__rating { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.pcard__rating .icon svg { width: 13px; height: 13px; color: var(--gold); }
.pcard__dots { display: flex; gap: 5px; margin-top: 6px; }
.pcard__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid var(--hairline-strong);
    box-shadow: inset 0 0 0 1.5px var(--surface);
}

.pcard--skeleton { pointer-events: none; }
.skeleton-line { height: 12px; border-radius: 6px; margin-block: 5px; }

/* ---------------- shimmer ---------------- */

.shimmer {
    position: relative;
    background: var(--shimmer-base);
    overflow: hidden;
}
.shimmer::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 30%, var(--shimmer-glow) 50%, transparent 70%);
    transform: translateX(-100%);
    animation: shimmer-slide 1.6s ease-in-out infinite;
}
@keyframes shimmer-slide { to { transform: translateX(100%); } }

/* ---------------- section header ---------------- */

.section { margin-top: 44px; }
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.section-head__title {
    font-family: var(--font-display);
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 700;
    letter-spacing: 0.01em;
}
.section-head__link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--gold-deep);
    transition: gap 0.25s var(--ease-out);
}
[data-theme="dark"] .section-head__link { color: var(--gold-soft); }
.section-head__link:hover { gap: 8px; }
.section-head__link .icon svg { width: 15px; height: 15px; }

/* ---------------- modal ---------------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: var(--overlay);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: grid;
    place-items: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.28s ease;
    overflow-y: auto;
}
.modal-overlay--in { opacity: 1; }
.modal {
    position: relative;
    width: min(440px, 100%);
    background: var(--surface);
    border-radius: var(--r-xl);
    padding: 32px 28px 28px;
    box-shadow: var(--shadow-pop);
    transform: translateY(24px) scale(0.97);
    transition: transform 0.35s var(--ease-out);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.modal-overlay--in .modal { transform: none; }
.modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--text-2);
    transition: background 0.2s, transform 0.25s var(--ease-spring);
    z-index: 2;
}
.modal__close:hover { background: var(--hairline); transform: rotate(90deg); }
.modal__close .icon svg { width: 18px; height: 18px; }

@media (max-width: 560px) {
    .modal-overlay { padding: 0; align-items: end; }
    .modal {
        width: 100%;
        border-radius: var(--r-xl) var(--r-xl) 0 0;
        max-height: 92vh;
        transform: translateY(100%);
    }
}

/* ---------------- toast ---------------- */

#toast-root {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 180;
    pointer-events: none;
}
@media (max-width: 760px) { #toast-root { bottom: 88px; } }
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--r-pill);
    background: var(--text);
    color: var(--bg);
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-pop);
    opacity: 0;
    transform: translateY(16px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.35s var(--ease-spring);
    max-width: min(90vw, 480px);
}
.toast--in { opacity: 1; transform: none; }
.toast .icon svg { width: 17px; height: 17px; }
.toast--success .icon { color: #7edfa8; }
.toast--error .icon { color: #ff8b8e; }

/* ---------------- stepper ---------------- */

.stepper {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: var(--surface-2);
    border: 1px solid var(--hairline);
    border-radius: var(--r-pill);
    padding: 3px;
}
.stepper__btn {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--text);
    transition: background 0.2s, transform 0.15s;
}
.stepper__btn:not(:disabled):hover { background: var(--gold-grad); color: #221803; }
.stepper__btn:not(:disabled):active { transform: scale(0.9); }
.stepper__btn:disabled { opacity: 0.35; cursor: not-allowed; }
.stepper__btn .icon svg { width: 15px; height: 15px; }
.stepper__value { min-width: 30px; text-align: center; font-weight: 800; font-size: 14.5px; }

/* ---------------- auth / OTP ---------------- */

.auth { display: flex; flex-direction: column; gap: 14px; text-align: center; }
.auth__mark { display: grid; place-items: center; margin-bottom: 2px; }
.auth__mark img { animation: splash-pulse 2.4s ease-in-out infinite; }
.auth__title { font-family: var(--font-display); font-size: 24px; font-weight: 700; }
.auth__sub { font-size: 13.5px; color: var(--text-2); margin-top: -8px; }
.auth__phone { margin-top: 10px; text-align: left; }
.auth__error { color: var(--danger); font-size: 13px; font-weight: 600; min-height: 18px; margin-top: -6px; }
.auth__back { margin-top: -6px; color: var(--text-2); }

.otp { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.otp--busy { opacity: 0.5; pointer-events: none; }
.otp--error { animation: otp-shake 0.45s ease; }
@keyframes otp-shake {
    20%, 60% { transform: translateX(-7px); }
    40%, 80% { transform: translateX(7px); }
}
.otp__box {
    width: 46px;
    height: 54px;
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    background: var(--surface-2);
    border: 1.5px solid var(--hairline-strong);
    border-radius: var(--r-md);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    caret-color: var(--gold);
}
.otp__box:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(241, 164, 36, 0.15);
    transform: translateY(-2px);
}
@media (max-width: 400px) { .otp__box { width: 40px; height: 48px; } }

/* ---------------- search suggest ---------------- */

.searchbar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 42px;
    padding: 0 16px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    border: 1.5px solid var(--hairline);
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.searchbar:focus-within {
    border-color: var(--gold);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(241, 164, 36, 0.12);
}
.searchbar .icon { color: var(--text-3); }
.searchbar .icon svg { width: 18px; height: 18px; }
.searchbar input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
}

.suggest {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-pop);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.22s, transform 0.28s var(--ease-out), visibility 0.22s;
    z-index: 96;
    max-height: 420px;
    overflow-y: auto;
}
.suggest--open { opacity: 1; visibility: visible; transform: none; }
.suggest__row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--r-md);
    transition: background 0.18s;
}
.suggest__row:hover { background: var(--hairline); }
.suggest__img { width: 42px; height: 50px; object-fit: cover; border-radius: var(--r-sm); background: var(--surface-2); }
.suggest__info { flex: 1; min-width: 0; }
.suggest__name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest__code { font-size: 11.5px; color: var(--text-3); }
.suggest__price { font-size: 13px; font-weight: 800; white-space: nowrap; }

/* ---------------- empty / error states ---------------- */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    padding: 72px 20px;
}
.empty__icon {
    width: 84px;
    height: 84px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--hairline);
    color: var(--gold);
    box-shadow: var(--shadow-card);
    animation: empty-float 3.4s ease-in-out infinite;
}
.empty__icon svg { width: 34px; height: 34px; }
.empty__icon--error { color: var(--danger); }
@keyframes empty-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
.empty__title { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.empty__sub { color: var(--text-2); font-size: 14px; max-width: 380px; }
.empty .btn { margin-top: 8px; }

/* ---------------- stars ---------------- */

.stars { display: inline-flex; align-items: center; gap: 1.5px; }
.stars .icon svg { width: 15px; height: 15px; }
.stars__on { color: var(--gold); }
.stars__off { color: var(--hairline-strong); }
.stars__count { font-size: 12.5px; color: var(--text-2); margin-left: 5px; }

/* ---------------- spinner / page bits ---------------- */

.spinner {
    width: 34px;
    height: 34px;
    margin: 48px auto;
    border-radius: 50%;
    border: 3px solid var(--hairline);
    border-top-color: var(--gold);
    animation: spin 0.8s linear infinite;
}

.page-title {
    font-family: var(--font-display);
    font-size: clamp(26px, 4vw, 36px);
    font-weight: 700;
    margin-block: 28px 20px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding-inline: 14px;
    border-radius: var(--r-pill);
    background: var(--surface);
    border: 1.5px solid var(--hairline-strong);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.22s ease;
    user-select: none;
}
.chip:hover { border-color: var(--gold); }
.chip.is-active {
    background: var(--gold-grad);
    border-color: transparent;
    color: #221803;
    box-shadow: var(--shadow-gold);
}
.chip .icon svg { width: 14px; height: 14px; }

.divider { height: 1px; background: var(--hairline); border: 0; margin-block: 18px; }
