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

html {
    /* PWA sifatida ochilganda status-bar/notch bilan
       to'qnashmasligi uchun */
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: Arial, sans-serif;
    background: #f5f5f5;
    color: #222;
    overscroll-behavior-y: none;
}


/* ================================
   HEADER
================================ */

.header {
    position: sticky;
    top: 0;
    z-index: 10;

    display: flex;
    flex-wrap: wrap;
    row-gap: 8px;
    justify-content: space-between;
    align-items: center;

    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top));

    background: white;

    border-bottom: 1px solid #ddd;
}

.header h1 {
    font-size: 22px;
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
}

#profileButton {
    border: 1px solid #ddd;

    background: white;
    color: #222;

    padding: 10px 12px;

    border-radius: 10px;

    font-size: 13px;

    cursor: pointer;
    white-space: nowrap;
}

#profileButton:active {
    transform: scale(0.96);
}

#myOrdersButton {
    border: 1px solid #ddd;

    background: white;
    color: #222;

    padding: 10px 12px;

    border-radius: 10px;

    font-size: 13px;

    cursor: pointer;
    white-space: nowrap;
}

#myOrdersButton:active {
    transform: scale(0.96);
}

#cartButton {
    position: relative;

    border: none;

    background: #222;
    color: white;

    padding: 10px 14px;

    border-radius: 10px;

    font-size: 14px;

    cursor: pointer;
    white-space: nowrap;
}

#cartButton:active {
    transform: scale(0.96);
}

.cart-badge {
    position: absolute;
    top: -6px;
    right: -6px;

    min-width: 20px;
    height: 20px;
    padding: 0 5px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #e53935;
    color: white;

    font-size: 11px;
    font-weight: bold;

    border-radius: 999px;
    border: 2px solid white;
}


/* ================================
   ASOSIY QISM
================================ */

main {
    padding: 15px;

    /* pastki "savat" paneli tagida qolib ketmasligi uchun */
    padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

.search-box {
    margin-bottom: 15px;
}

#searchInput {
    width: 100%;

    padding: 13px 15px;

    border: 1px solid #ddd;

    border-radius: 12px;

    font-size: 16px;

    outline: none;

    background: white;
}

#searchInput:focus {
    border-color: #222;
}


/* ================================
   MAHSULOTLAR
================================ */

.products {
    display: grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap: 12px;
}

.product-card {
    background: white;

    border-radius: 14px;

    overflow: hidden;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.08);
}

.product-image {
    width: 100%;

    height: 150px;

    object-fit: cover;

    background: #eee;
}

.product-info {
    padding: 12px;
}

.product-name {
    font-size: 16px;

    font-weight: bold;

    margin-bottom: 6px;
}

.product-price {
    font-size: 15px;

    font-weight: bold;

    margin-bottom: 5px;
}

.product-stock {
    font-size: 13px;

    color: #777;

    margin-bottom: 10px;
}


/* ================================
   MIQDOR
================================ */

.quantity-control {
    display: flex;

    align-items: center;

    justify-content: center;

    gap: 15px;

    margin-top: 10px;
}

.quantity-control button {
    width: 45px;
    height: 45px;

    font-size: 24px;

    font-weight: bold;

    cursor: pointer;

    border: none;

    border-radius: 10px;

    background: #f1f3f5;
}

.quantity-control button:active {
    transform: scale(0.92);
}

.quantity-control span {
    min-width: 35px;

    text-align: center;

    font-size: 22px;

    font-weight: bold;
}


/* ================================
   PASTKI SAVAT PANELI (sticky bar)
================================ */

.sticky-cart-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;

    display: none;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    background: #181818;
    color: white;

    padding: 14px 16px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));

    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);

    transform: translateY(100%);
    transition: transform 0.25s ease;
}

.sticky-cart-bar.visible {
    display: flex;
    transform: translateY(0);
}

.sticky-cart-info {
    font-size: 14px;
    line-height: 1.4;
}

.sticky-cart-info strong {
    font-size: 15px;
}

#stickyCartButton {
    flex-shrink: 0;

    border: none;
    background: white;
    color: #181818;

    padding: 12px 18px;

    border-radius: 10px;

    font-size: 14px;
    font-weight: bold;

    cursor: pointer;
}

#stickyCartButton:active {
    transform: scale(0.96);
}


/* ================================
   SAVAT OYNASI (pastdan chiqadigan sheet)
================================ */

.cart-modal {
    display: none;

    position: fixed;

    inset: 0;

    background:
        rgba(0, 0, 0, 0.5);

    align-items: flex-end;

    justify-content: center;

    z-index: 1000;

    padding: 0;
}

.cart-window {
    width: 100%;

    max-width: 450px;

    max-height: 85vh;

    overflow-y: auto;

    background: white;

    border-radius: 20px 20px 0 0;

    padding: 12px 20px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));

    box-shadow:
        0 -10px 40px rgba(0, 0, 0, 0.25);

    animation: cartWindowOpen 0.22s ease;
}

.cart-drag-handle {
    width: 42px;
    height: 5px;

    margin: 2px auto 14px;

    border-radius: 999px;

    background: #e0e0e0;
}

@keyframes cartWindowOpen {

    from {
        opacity: 0;

        transform: translateY(30px);
    }

    to {
        opacity: 1;

        transform: translateY(0);
    }
}


/* ================================
   SAVAT HEADER
================================ */

.cart-header {
    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 10px;
}

.cart-header h2 {
    font-size: 21px;
}

.cart-header button {
    width: 38px;
    height: 38px;

    font-size: 24px;

    border: none;

    background: #f1f3f5;

    border-radius: 50%;

    cursor: pointer;
}

.cart-header button:active {
    transform: scale(0.9);
}


/* ================================
   SAVAT MAHSULOTI
================================ */

.cart-item {
    padding: 15px 0;

    border-bottom:
        1px solid #ddd;
}


/* ================================
   BUYURTMALARIM RO‘YXATI
================================ */

.empty-orders-message {
    padding: 30px 10px;

    text-align: center;

    color: #777;
}

.order-record {
    padding: 14px 0;

    border-bottom: 1px solid #ddd;
}

.order-record:last-child {
    border-bottom: none;
}

.order-record-header {
    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 10px;

    margin-bottom: 8px;
}

.order-record-id {
    font-weight: bold;
    font-size: 15px;
}

.order-record-date {
    font-size: 12px;

    color: #999;

    margin-top: 2px;
}

.order-status-badge {
    flex-shrink: 0;

    padding: 5px 10px;

    border-radius: 999px;

    font-size: 12px;

    font-weight: bold;

    white-space: nowrap;
}

.order-status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.order-status-badge.confirmed {
    background: #dcfce7;
    color: #166534;
}

.order-status-badge.rejected {
    background: #fee2e2;
    color: #991b1b;
}

.order-record-items {
    font-size: 13px;

    color: #555;

    line-height: 1.6;
}

.order-record-total {
    margin-top: 8px;

    font-weight: bold;

    font-size: 15px;
}


/* ================================
   SAVAT JAMI
================================ */

.cart-total {
    font-size: 20px;

    font-weight: bold;

    margin-top: 20px;
}


/* ================================
   BUYURTMA BERISH TUGMASI
================================ */

.order-button {
    width: 100%;

    padding: 14px;

    margin-top: 15px;

    font-size: 17px;

    font-weight: bold;

    border: none;

    border-radius: 10px;

    cursor: pointer;

    background: #222;

    color: white;

    transition: 0.2s;
}

.order-button:hover {
    background: #333;
}

.order-button:active {
    transform: scale(0.98);
}


/* ================================
   SAVAT + / −
================================ */

.cart-quantity-control {
    display: flex;

    align-items: center;

    justify-content: center;

    gap: 12px;

    margin: 10px 0;
}

.cart-quantity-control button {
    width: 38px;
    height: 38px;

    display: flex;

    align-items: center;

    justify-content: center;

    border: none;

    border-radius: 50%;

    background: #f1f3f5;

    color: #222;

    font-size: 24px;

    font-weight: 500;

    line-height: 1;

    cursor: pointer;

    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.12);

    transition:
        background 0.2s ease,
        transform 0.15s ease,
        box-shadow 0.2s ease;
}

.cart-quantity-control button:hover {
    background: #e2e6ea;

    transform: scale(1.08);
}

.cart-quantity-control button:active {
    transform: scale(0.92);
}

.cart-quantity-control span {
    min-width: 70px;

    text-align: center;

    font-size: 17px;

    font-weight: 600;

    color: #222;
}


/* ================================
   BUYURTMA OYNASI
================================ */

.order-modal {
    display: none;

    position: fixed;

    inset: 0;

    z-index: 2000;

    background:
        rgba(0, 0, 0, 0.55);

    align-items: center;

    justify-content: center;

    padding: 15px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
}


/* ================================
   BUYURTMA OYNASI ICHI
================================ */

.order-window {
    width: 100%;

    max-width: 450px;

    max-height: 90vh;

    overflow-y: auto;

    background: white;

    border-radius: 18px;

    padding: 20px;

    box-shadow:
        0 15px 50px rgba(0, 0, 0, 0.3);

    animation:
        orderWindowOpen 0.2s ease;
}

@keyframes orderWindowOpen {

    from {
        opacity: 0;

        transform:
            scale(0.95)
            translateY(10px);
    }

    to {
        opacity: 1;

        transform:
            scale(1)
            translateY(0);
    }
}


/* ================================
   BUYURTMA HEADER
================================ */

.order-header {
    display: flex;

    align-items: center;

    justify-content: space-between;

    margin-bottom: 20px;
}

.order-header h2 {
    font-size: 21px;
}

.order-header button {
    width: 38px;
    height: 38px;

    border: none;

    border-radius: 50%;

    background: #f1f3f5;

    font-size: 23px;

    cursor: pointer;
}

.order-header button:active {
    transform: scale(0.9);
}


/* ================================
   LABEL
================================ */

.order-label {
    display: block;

    margin-top: 14px;

    margin-bottom: 7px;

    font-size: 14px;

    font-weight: bold;

    color: #333;
}


/* ================================
   INPUT
================================ */

.order-input {
    width: 100%;

    padding: 13px 14px;

    border: 1px solid #d5d5d5;

    border-radius: 10px;

    outline: none;

    font-size: 16px;

    background: white;

    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

.order-input:focus {
    border-color: #222;

    box-shadow:
        0 0 0 3px
        rgba(0, 0, 0, 0.06);
}


/* ================================
   FIRMA YO‘Q
================================ */

.no-company-button {
    width: 100%;

    margin-top: 12px;

    padding: 12px;

    border: 1px solid #ddd;

    border-radius: 10px;

    background: #f7f7f7;

    color: #222;

    font-size: 15px;

    font-weight: bold;

    cursor: pointer;

    transition: 0.2s;
}

.no-company-button:hover {
    background: #eee;
}

.no-company-button.active {
    background: #222;

    color: white;

    border-color: #222;
}


/* ================================
   SHAXSIY MA'LUMOT
================================ */

.person-section {
    margin-top: 5px;
}


/* ================================
   MASHINA RAQAMI TURI
================================ */

.plate-type-buttons {
    display: flex;

    gap: 8px;

    margin-top: 6px;
    margin-bottom: 12px;
}

.plate-type-button {
    flex: 1;

    padding: 10px;

    border: 1px solid #ddd;
    border-radius: 10px;

    background: white;
    color: #222;

    font-size: 13px;

    cursor: pointer;
}

.plate-type-button:active {
    transform: scale(0.97);
}

.plate-type-button.selected {
    background: #222;
    color: white;

    border-color: #222;
}


/* ================================
   TANISHUV (IDENTITY) OYNASI
================================ */

.identity-modal {
    z-index: 100000;
}

.identity-subtitle {
    color: #666;

    font-size: 14px;

    line-height: 1.5;

    margin: 4px 0 18px 0;
}

#identityStep1 .confirm-order-button,
#identityWelcomeBack .confirm-order-button,
#identityStep2 .confirm-order-button {
    margin-top: 18px;
}

#identityWelcomeBack .no-company-button {
    margin-top: 10px;
}


/* ================================
   TO‘LOV
================================ */

.payment-section {
    margin-top: 20px;
}

.payment-buttons {
    display: flex;

    flex-direction: column;

    gap: 10px;
}


/* ================================
   TO‘LOV TUGMALARI
================================ */

.payment-button {
    position: relative;

    width: 100%;

    display: flex;

    align-items: center;

    gap: 10px;

    padding: 14px;

    border: 1px solid #ddd;

    border-radius: 11px;

    background: white;

    font-size: 16px;

    cursor: pointer;

    text-align: left;

    transition:
        background 0.2s,
        border-color 0.2s,
        transform 0.15s;
}

.payment-button:hover {
    background: #f7f7f7;
}

.payment-button:active {
    transform: scale(0.98);
}


/* TANLANGAN */

.payment-button.selected {
    background: #222;

    color: white;

    border-color: #222;
}


/* ================================
   PTICHKA
================================ */

.payment-check {
    display: none;

    margin-left: auto;

    width: 25px;
    height: 25px;

    align-items: center;

    justify-content: center;

    border-radius: 50%;

    background: white;

    color: #222;

    font-size: 16px;

    font-weight: bold;
}

.payment-button.selected
.payment-check {
    display: flex;
}


/* ================================
   TASDIQLASH
================================ */

.confirm-order-button {
    width: 100%;

    margin-top: 22px;

    padding: 14px;

    border: none;

    border-radius: 11px;

    background: #1f8f4c;

    color: white;

    font-size: 17px;

    font-weight: bold;

    cursor: pointer;

    transition: 0.2s;
}

.confirm-order-button:hover {
    background: #187a3f;
}

.confirm-order-button:active {
    transform: scale(0.98);
}


/* ================================
   TELEFON INPUT
================================ */

#phoneInput {
    letter-spacing: 0.5px;
}


/* ================================
   TELEFONDA
================================ */

@media (max-width: 600px) {

    .header h1 {
        font-size: 18px;
    }

    #profileButton {
        padding: 8px 9px;
        font-size: 12px;
    }

    #myOrdersButton {
        padding: 8px 10px;
        font-size: 12px;
    }

    #cartButton {
        padding: 8px 11px;
        font-size: 13px;
    }

    .products {
        grid-template-columns:
            repeat(2, 1fr);

        gap: 8px;
    }

    .product-info {
        padding: 9px;
    }

    .product-name {
        font-size: 14px;
    }

    .product-price {
        font-size: 13px;
    }

    .quantity-control {
        gap: 8px;
    }

    .quantity-control button {
        width: 40px;
        height: 40px;
    }

    .cart-window {
        max-height: 85vh;

        padding: 12px 16px 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .order-window {
        max-height: 92vh;

        padding: 17px;
    }

    .order-header h2 {
        font-size: 19px;
    }

}
