/* ============================================================
   Hisob: kirish oynasi, checkout, profil, toast, muvaffaqiyat
   ============================================================ */

/* --- Modal --- */

.modal-veil {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(10, 10, 14, .55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: fade var(--fast) var(--ease) both;
}

.modal {
    width: min(430px, 100%);
    padding: 26px;
    border-radius: var(--r-xl);
    background: var(--bg);
    box-shadow: var(--shadow-lg);
    animation: modal-in var(--mid) var(--spring) both;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(22px) scale(.97);
    }
}

.modal-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
}

.modal-logo {
    width: 46px;
    height: 46px;
    flex: none;
}

.modal-sub {
    margin: 4px 0 0;
    font-size: 13.5px;
}

.modal-close {
    margin-left: auto;
}

.input-lg {
    padding: 15px 16px;
    font-size: 16px;
}

.input-code {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: .4em;
    font-variant-numeric: tabular-nums;
}

.form-error {
    display: none;
    margin: 10px 0;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    background: var(--red-wash);
    color: var(--red);
    font-size: 13.5px;
    font-weight: 550;
}

.form-error.show {
    display: block;
    animation: shake .3s var(--ease);
}

@keyframes shake {

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* TEST rejim ko'rsatkichi */
.test-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    border: 1px dashed var(--red);
    background: var(--red-wash);
    color: var(--red);
    font-size: 13.5px;
}

.test-hint b {
    font-size: 16px;
    letter-spacing: .12em;
    font-variant-numeric: tabular-nums;
}

/* --- Toast --- */

.toasts {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 120;
    display: grid;
    gap: 8px;
    width: min(420px, calc(100vw - 32px));
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    border-radius: var(--r);
    background: var(--bg-deep);
    color: #fff;
    font-size: 14.5px;
    font-weight: 550;
    box-shadow: var(--shadow-lg);
    animation: toast-in var(--mid) var(--spring) both;
}

.toast svg {
    flex: none;
    color: #4ade80;
}

.toast-error svg {
    color: var(--red-bright);
}

.toast.out {
    animation: toast-out var(--mid) var(--ease) forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(16px) scale(.96);
    }
}

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

/* --- Checkout --- */

.co-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 36px;
    align-items: start;
    margin-top: 24px;
}

.co-step {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 30px 0 16px;
}

.co-step:first-child {
    margin-top: 0;
}

.co-step-n {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.co-methods,
.co-pays {
    display: grid;
    gap: 10px;
}

.co-methods {
    grid-template-columns: 1fr 1fr;
}

.co-method {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 1.5px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    text-align: left;
    transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}

.co-method:hover {
    border-color: var(--line-strong);
}

.co-method.on {
    border-color: var(--red);
    background: var(--red-wash);
}

.co-method b {
    display: block;
    font-size: 14.5px;
}

.co-method .muted {
    display: block;
    font-size: 12.5px;
    margin-top: 2px;
}

.co-radio {
    margin-left: auto;
    width: 20px;
    height: 20px;
    flex: none;
    border-radius: 50%;
    border: 2px solid var(--line-strong);
    transition: all var(--fast) var(--ease);
}

.co-method.on .co-radio,
.co-branch.on .co-radio {
    border-color: var(--red);
    border-width: 6px;
}

.co-branches {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.co-branch {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    text-align: left;
    transition: border-color var(--fast) var(--ease);
}

.co-branch.on {
    border-color: var(--red);
    background: var(--red-wash);
}

.co-branch b {
    display: block;
    font-size: 14px;
}

.co-branch .muted {
    font-size: 12.5px;
}

/* Xulosa paneli */
.co-summary {
    position: sticky;
    top: calc(var(--header-h) + 16px);
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
}

.co-items {
    display: grid;
    gap: 2px;
    margin: 16px 0;
    max-height: 300px;
    overflow-y: auto;
}

.co-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.co-item-ico {
    width: 42px;
    height: 42px;
}

.co-item-info {
    flex: 1;
    min-width: 0;
}

.co-item-name {
    font-size: 13.5px;
    font-weight: 550;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.co-item-info .muted {
    font-size: 12.5px;
}

.co-item-sum {
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
}

.co-totals {
    padding-top: 14px;
    border-top: 1px solid var(--line);
    margin-bottom: 16px;
}

.co-note {
    margin: 14px 0 0;
    font-size: 12.5px;
    line-height: 1.5;
}

/* Kirish taklifi */
.auth-gate {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    margin-top: 24px;
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    max-width: 620px;
}

.auth-gate > div:nth-child(2) {
    flex: 1;
    min-width: 200px;
}

.auth-gate p {
    margin: 4px 0 0;
    font-size: 13.5px;
}

/* --- Muvaffaqiyat --- */

.success-wrap {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 10px;
    max-width: 640px;
}

.success-ring-wrap {
    position: relative;
    display: grid;
    place-items: center;
    margin-bottom: 8px;
}

.success-check {
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: linear-gradient(160deg, #34c759, #1f9e45);
    color: #fff;
    box-shadow: 0 14px 40px rgba(40, 170, 75, .35);
    animation: pop-in .55s var(--spring) both;
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: scale(.4);
    }
}

.success-ring {
    position: absolute;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    border: 2px solid #34c759;
    animation: ring-out 1.1s var(--ease-out) .2s both;
}

@keyframes ring-out {
    to {
        transform: scale(2.1);
        opacity: 0;
    }
}

.success-number {
    font-size: clamp(1.6rem, 3.4vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--red);
    font-variant-numeric: tabular-nums;
}

.success-card {
    width: 100%;
    margin-top: 14px;
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    text-align: left;
}

.success-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 13.5px;
    color: var(--text-dim);
}

.success-actions {
    margin-top: 18px;
}

/* Payme to'lovi — muvaffaqiyat sahifasidagi asosiy harakat, shuning
   uchun ajratib turadi. */
.pay-box {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    background: var(--surface);
    text-align: center;
}

.pay-box p {
    margin: 0 0 14px;
    line-height: 1.5;
}

.btn-pay {
    display: inline-flex;
    background: #21c1f3;
    border-color: #21c1f3;
    color: #fff;
}

.btn-pay:hover {
    background: #17a8d6;
    border-color: #17a8d6;
}

/* --- Profil --- */

.profile-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
    margin-top: 24px;
}

.profile-card {
    position: sticky;
    top: calc(var(--header-h) + 16px);
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 6px;
    padding: 28px 24px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
}

.profile-card .field {
    width: 100%;
    text-align: left;
    margin: 8px 0 0;
}

.profile-card .btn {
    margin-top: 10px;
}

.profile-avatar {
    display: grid;
    place-items: center;
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: var(--red-wash);
    color: var(--red);
    margin-bottom: 6px;
}

.orders-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.order-card {
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    overflow: hidden;
    transition: box-shadow var(--mid) var(--ease);
}

.order-card.open {
    box-shadow: var(--shadow);
}

.order-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    padding: 18px 20px;
    border: 0;
    background: none;
    text-align: left;
}

.order-head b {
    font-size: 15px;
}

.order-head .muted {
    font-size: 12.5px;
    margin-top: 3px;
}

.order-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.order-right svg {
    color: var(--text-faint);
    transition: transform var(--mid) var(--ease);
}

.order-card.open .order-right svg {
    transform: rotate(180deg);
}

.badge-status {
    background: rgba(52, 199, 89, .14);
    color: #17a34a;
}

.order-body {
    padding: 4px 20px 18px;
    border-top: 1px solid var(--line);
}

.order-body .summary-line {
    font-size: 13.5px;
}

.order-timeline {
    display: flex;
    gap: 0;
    margin: 16px 0;
}

.order-timeline .tl-step {
    flex: 1;
    display: grid;
    justify-items: center;
    gap: 7px;
    position: relative;
}

.order-timeline .tl-step::before {
    content: '';
    position: absolute;
    top: 5px;
    left: -50%;
    right: 50%;
    height: 2px;
    background: var(--line);
}

.order-timeline .tl-step:first-child::before {
    display: none;
}

.order-timeline .tl-step.on::before {
    background: var(--red);
}

.order-timeline .tl-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--line);
    position: relative;
    z-index: 1;
}

.order-timeline .tl-step.on .tl-dot {
    background: var(--red);
    box-shadow: 0 0 0 4px var(--red-wash);
}

.order-timeline .tl-label {
    font-size: 12px;
    color: var(--text-dim);
}

.order-timeline .tl-step.on .tl-label {
    color: var(--text);
    font-weight: 600;
}

/* --- Moslashuvchanlik --- */

@media (max-width: 1080px) {
    .co-layout,
    .profile-layout {
        grid-template-columns: 1fr;
    }

    .co-summary,
    .profile-card {
        position: static;
    }

    /* Bir ustunga tushganda maydonlar butun ekran bo'ylab (~950px)
       cho'zilib ketardi. Ustunni o'qishga qulay kenglikda ushlaymiz. */
    .co-form,
    .co-summary {
        max-width: 660px;
    }
}

@media (max-width: 620px) {
    .co-methods {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 20px;
    }
}


/* Bepul yetkazish shkalasi (savat panelida) */
.ship-progress {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
}

.ship-text {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    margin-bottom: 8px;
}

.ship-text b {
    color: var(--red);
}

.ship-progress.done .ship-text {
    color: #17a34a;
    font-weight: 600;
}

.ship-progress.done .ship-text svg {
    color: #17a34a;
}

.ship-bar {
    height: 6px;
    border-radius: var(--r-pill);
    background: var(--line);
    overflow: hidden;
}

.ship-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--red-bright), var(--red));
    transition: width var(--slow) var(--ease-out);
}

.ship-progress.done .ship-fill {
    background: linear-gradient(90deg, #34c759, #1f9e45);
}

/* 404 */
.nf-code {
    font-size: clamp(5rem, 14vw, 9rem);
    font-weight: 800;
    letter-spacing: -.05em;
    line-height: 1;
    background: linear-gradient(160deg, var(--red-bright), var(--red-deep));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Juda kichik ekranda (<=380px) savat qatori uzun summa bilan 2-3px
   yetmay qolardi — ichki bo'shliqlarni moslashtiramiz */
@media (max-width: 380px) {
    .drawer-head,
    .drawer-body,
    .drawer-foot {
        padding-left: 14px;
        padding-right: 14px;
    }

    .cart-ico {
        width: 46px;
        height: 46px;
    }

    .cart-row {
        gap: 10px;
    }

    .cart-sum {
        font-size: 13px;
    }
}

/* Telefonda "Jami" va tasdiqlash tugmasi sahifaning eng pastida qolib
   ketardi — 2-3 ekran chuqurlikda. Asosiy tugma ko'rinmayotganda pastda
   yupqa panel chiqadi (mahsulot sahifasidagi .buy-bar bilan bir uslub). */
.co-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px clamp(16px, 4vw, 40px);
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 30px rgba(16, 16, 24, .1);
    transform: translateY(110%);
    transition: transform var(--mid) var(--ease-out);
}

.co-bar.show {
    transform: none;
}

.co-bar-info {
    display: grid;
    gap: 1px;
    min-width: 0;
}

.co-bar-info span {
    font-size: 12px;
    color: var(--text-dim);
}

.co-bar-info b {
    font-size: 16px;
    font-weight: 750;
    letter-spacing: -.02em;
    color: var(--red);
    white-space: nowrap;
}

/* Katta ekranda xulosa doim yonda ko'rinib turadi — panel kerak emas */
@media (min-width: 1081px) {
    .co-bar {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .co-bar {
        transition: none;
    }
}

/* Nega naqd yo'qligi haqidagi izoh (kurier tanlanganda) */
.co-pay-note {
    margin: 2px 0 0;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    font-size: 13px;
    color: var(--text-dim);
}
