:root {
    --primary: #007bff;
    --primary-dark: #0056b3;
    --primary-light: #eaf4ff;
    --dark: #2c3e50;
    --accent: #fab005;
    --success: #28a745;
    --danger: #dc3545;
    --background: #f4f7fb;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1f2937;
    --muted: #64748b;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    width: 100%;
    min-height: 100%;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100dvh;
    overflow: hidden;
}

button {
    font: inherit;
    border: 0;
    cursor: pointer;
    touch-action: manipulation;
}

button:disabled {
    opacity: .6;
    cursor: wait;
}

.topbar {
    height: 62px;
    padding: 0 13px;
    background: var(--dark);
    color: white;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 12px rgba(15, 23, 42, .18);
    position: relative;
    z-index: 10;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: rgba(255, 255, 255, .1);
    font-size: 23px;
}

.topbar h1 {
    margin: 0;
    font-size: 19px;
    line-height: 1.1;
}

.caisse-name {
    display: block;
    margin-top: 3px;
    color: rgba(255, 255, 255, .7);
    font-size: 11px;
    font-weight: 600;
}

.btn-refresh {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 9px 13px;
    border: 0;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
    transition: transform .15s ease, opacity .15s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-refresh:hover {
    opacity: .9;
}

.btn-refresh:active {
    transform: scale(.95);
}

.btn-refresh i {
    font-size: 15px;
}

.caisse-layout {
    height: calc(100dvh - 62px);
    padding: 9px;
    overflow: hidden;
}

.catalogue {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.categories {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    flex-shrink: 0;
    padding: 1px 1px 9px;
    scrollbar-width: none;
}

.categories::-webkit-scrollbar {
    display: none;
}

.categories button {
    min-height: 45px;
    padding: 0 17px;
    flex: 0 0 auto;
    border-radius: 12px;
    background: white;
    color: var(--dark);
    border: 1px solid var(--border);
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}

.categories button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 123, 255, .2);
}

.products {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 9px;
    padding: 1px 1px 105px;
    scrollbar-width: thin;
}

.product {
    position: relative;
    overflow: hidden;
    min-height: 132px;
    padding: 14px 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 3px 12px rgba(15, 23, 42, .055);
    transition: transform .1s, border-color .1s, box-shadow .1s;
}

.product:active {
    transform: scale(.965);
    border-color: var(--primary);
    box-shadow: 0 5px 18px rgba(0, 123, 255, .16);
}

.product.adding-to-cart {
    animation: productAddToCart .4s ease;
}

.product.adding-to-cart::after {
    content: "✓ Ajouté";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(40, 167, 69, .92);
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    animation: productAddedOverlay .6s ease forwards;
}

@keyframes productAddToCart {
    0% {
        transform: scale(1);
    }

    45% {
        transform: scale(.94);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes productAddedOverlay {
    0% {
        opacity: 0;
        transform: scale(.7);
    }

    25% {
        opacity: 1;
        transform: scale(1);
    }

    75% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: scale(1.04);
    }
}

.product-icon {
    font-size: 35px;
    line-height: 1;
}

.product-name {
    font-size: 14px;
    text-align: center;
    line-height: 1.2;
}

.product-price {
    color: var(--primary-dark);
    font-size: 14px;
    font-weight: 900;
}

.product-options {
    padding: 3px 7px;
    border-radius: 7px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 9px;
    font-weight: 800;
}

.loading,
.empty-state,
.error-state {
    grid-column: 1 / -1;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: var(--muted);
    text-align: center;
}

.loading span,
.empty-state small,
.error-state small {
    font-size: 13px;
}

.empty-state > span,
.error-state > span {
    font-size: 36px;
}

.empty-state strong,
.error-state strong {
    color: var(--dark);
    font-size: 16px;
}

.error-state small {
    max-width: 90%;
    word-break: break-word;
}

.error-state button {
    margin-top: 5px;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    font-weight: 800;
}

.loader {
    width: 32px;
    height: 32px;
    border: 4px solid #dbeafe;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: rotation .8s linear infinite;
}

@keyframes rotation {
    to {
        transform: rotate(360deg);
    }
}

.panier-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(15, 23, 42, .48);
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s ease;
}

.panier-overlay.open {
    opacity: 1;
    visibility: visible;
}

.panier-panel {
    position: fixed;
    z-index: 100;
    left: 8px;
    right: 8px;
    bottom: 8px;
    height: min(78dvh, 650px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(15, 23, 42, .28);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(calc(100% - 70px));
    transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}

.panier-panel.open {
    transform: translateY(0);
}

.panier-handle {
    width: 100%;
    height: 29px;
    flex: 0 0 29px;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
}

.panier-handle span {
    width: 42px;
    height: 5px;
    border-radius: 20px;
    background: #cbd5e1;
}

.panier-header {
    min-height: 55px;
    padding: 3px 14px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.panier-header-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.panier-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--dark);
}

.panier-header span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.panier-close,
.modal-close {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: #f1f5f9;
    color: var(--dark);
    font-size: 27px;
    line-height: 1;
}

.panier-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 14px;
}

.panier-vide {
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 8px;
    color: var(--muted);
}

.panier-vide span {
    font-size: 40px;
}

.panier-vide strong {
    color: var(--dark);
    font-size: 15px;
}

.panier-vide small {
    font-size: 12px;
}

.cart-item {
    min-height: 68px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 38px;
    align-items: center;
    gap: 9px;
}

.cart-item-main {
    min-width: 0;
}

.cart-item-name {
    color: var(--dark);
    font-size: 14px;
    font-weight: 800;
}

.cart-item-options {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.3;
}

.cart-item-price {
    white-space: nowrap;
    font-size: 14px;
}

.cart-item-remove {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #fff1f2;
    color: var(--danger);
    font-size: 22px;
}

.panier-footer {
    flex-shrink: 0;
    padding: 11px 14px 14px;
    background: white;
    border-top: 1px solid var(--border);
    box-shadow: 0 -5px 16px rgba(15, 23, 42, .055);
}

.total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.total span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.total strong {
    color: var(--dark);
    font-size: 23px;
}

.payment {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.payment button {
    min-height: 50px;
    border-radius: 12px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 14px;
    font-weight: 900;
}

.payment-card {
    background: var(--primary);
}

.payment-card:active {
    background: var(--primary-dark);
}

.payment-cash {
    background: var(--success);
}

.payment-cash:active {
    filter: brightness(.92);
}

.modal {
    position: fixed;
    z-index: 200;
    inset: 0;
    padding: 10px;
    background: rgba(15, 23, 42, .58);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

.modal.open {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    position: relative;
    width: 100%;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 19px;
    border-radius: 20px 20px 0 0;
    background: white;
    box-shadow: 0 15px 50px rgba(15, 23, 42, .25);
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
}

.modal-box h2 {
    margin: 0 48px 8px 0;
    color: var(--dark);
    font-size: 20px;
}

.paiement-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    background: var(--primary-light);
    font-size: 27px;
}

.paiement-box p {
    margin: 0 0 17px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.paiement-choix {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.paiement-option {
    width: 100%;
    min-height: 70px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: white;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.paiement-option:active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.paiement-option-icon {
    width: 43px;
    height: 43px;
    flex: 0 0 43px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: #f1f5f9;
    font-size: 22px;
}

.paiement-option-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.paiement-option-text strong {
    color: var(--dark);
    font-size: 15px;
}

.paiement-option-text small {
    color: var(--muted);
    font-size: 11px;
}

.paiement-arrow {
    color: #94a3b8;
    font-size: 27px;
}

.modal-cancel {
    width: 100%;
    min-height: 47px;
    margin-top: 12px;
    border-radius: 12px;
    background: #e2e8f0;
    color: var(--dark);
    font-weight: 800;
}

.options-box {
    padding-top: 21px;
}

.option-group {
    margin-top: 18px;
}

.option-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.option-group-title strong {
    color: var(--dark);
    font-size: 14px;
}

.option-group-title span {
    padding: 4px 7px;
    border-radius: 7px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 9px;
    font-weight: 800;
}

.option-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.option-choice {
    min-height: 50px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 11px;
    display: flex;
    align-items: center;
    gap: 9px;
}

.option-choice:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
}

.option-choice input {
    width: 19px;
    height: 19px;
    margin: 0;
    accent-color: var(--primary);
    flex: 0 0 auto;
}

.option-choice-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.option-choice-content strong {
    font-size: 13px;
    color: var(--dark);
}

.option-choice-content small {
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
}

.options-actions {
    margin-top: 19px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.options-actions button {
    width: 100%;
    min-height: 48px;
    border-radius: 12px;
    font-weight: 800;
}

.options-actions .primary {
    background: var(--primary);
    color: white;
}

.options-actions .secondary {
    background: #e2e8f0;
    color: var(--dark);
}

.notification {
    position: fixed;
    z-index: 300;
    top: 72px;
    left: 50%;
    transform: translate(-50%, -20px);
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 13px 18px;
    border-radius: 13px;
    background: var(--dark);
    color: white;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 8px 25px rgba(15, 23, 42, .25);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease, visibility .25s ease;
}

.notification.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

@media (max-width: 600px) {
    .notification {
        top: 68px;
        max-width: calc(100% - 20px);
        padding: 12px 15px;
        font-size: 13px;
    }
}


@media (max-width: 600px) {
    .btn-refresh {
        top: 8px;
        right: 8px;
        min-width: 42px;
        width: 42px;
        height: 42px;
        padding: 0;
        border-radius: 11px;
    }

    .btn-refresh span {
        display: none;
    }
}

@media (min-width: 600px) {
    .topbar {
        height: 66px;
        padding: 0 18px;
    }

    .topbar h1 {
        font-size: 22px;
    }

    .caisse-layout {
        height: calc(100dvh - 66px);
        padding: 13px;
    }

    .categories {
        gap: 10px;
        padding-bottom: 12px;
    }

    .categories button {
        min-height: 48px;
        padding: 0 22px;
        font-size: 15px;
    }

    .products {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
        padding-bottom: 110px;
    }

    .product {
        min-height: 145px;
    }

    .product-icon {
        font-size: 40px;
    }

    .product-name {
        font-size: 15px;
    }

    .panier-panel {
        left: 50%;
        right: auto;
        width: min(560px, calc(100% - 20px));
        bottom: 12px;
        transform: translate(-50%, calc(100% - 72px));
    }

    .panier-panel.open {
        transform: translate(-50%, 0);
    }

    .modal {
        align-items: center;
    }

    .modal-box {
        width: min(520px, 100%);
        border-radius: 20px;
    }
}

@media (min-width: 900px) {
    .topbar {
        padding: 0 24px;
    }

    .caisse-layout {
        padding: 17px;
    }

    .products {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 14px;
    }

    .product {
        min-height: 155px;
    }

    .panier-panel {
        width: 520px;
    }
}

@media (min-width: 1200px) {
    .products {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .product {
        min-height: 160px;
    }
}