/**
 * TheCraftSide Core
 * Caisse publique / tablette
 *
 * Styles complémentaires au layout de base présent
 * dans caisse-tablette.php.
 *
 * À terme, le CSS de base pourra également être déplacé ici.
 */


/* ==========================================================
 * PANIER
 * ======================================================== */

.tcs-caisse-tablette .tcs-cart {
    height: min(
        680px,
        calc(100dvh - 175px)
    );

    min-height: 500px;
    max-height: calc(100dvh - 175px);

    align-self: start;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}

.tcs-caisse-tablette .tcs-cart-items {
    flex: 1 1 auto;

    min-height: 0;

    overflow-y: auto;
    overflow-x: hidden;
}

.tcs-caisse-tablette .tcs-cart-footer {
    flex: 0 0 auto;

    background: #fff;
}

/*
 * Le CSS de base applique display:flex à ce bloc.
 * Cette règle garantit que l'attribut HTML hidden reste
 * prioritaire lorsque le panier contient des articles.
 */
.tcs-caisse-tablette .tcs-cart-empty[hidden] {
    display: none !important;
}


/* ==========================================================
 * GRILLE PRODUITS
 * ======================================================== */

.tcs-caisse-tablette .tcs-products-grid {
    grid-template-columns:
        repeat(
            auto-fill,
            minmax(210px, 1fr)
        );
}


/* ==========================================================
 * CARTE PRODUIT
 * ======================================================== */

#tcs-products-grid .tcs-product-button {
    border: 1px solid #ddd6cf;
    border-radius: 12px;

    background: #fff;

    overflow: hidden;

    transition:
        border-color .15s ease,
        box-shadow .15s ease,
        transform .15s ease;
}

#tcs-products-grid .tcs-product-button:hover {
    border-color: #b87333;

    box-shadow:
        0 6px 16px
        rgba(70, 44, 25, .10);

    transform: translateY(-1px);
}

#tcs-products-grid .tcs-product-button.is-in-cart {
    border: 2px solid #2271b1;
}


/* ==========================================================
 * IMAGE PRODUIT
 * ======================================================== */

#tcs-products-grid .tcs-product-image-zone {
    height: 260px;
    min-height: 260px;

    display: flex;
    align-items: center;
    justify-content: center;

    background:
        linear-gradient(
            180deg,
            #f7f5f2 0%,
            #efebe6 100%
        );

    overflow: hidden;
}

#tcs-products-grid .tcs-product-image {
    display: block;

    width: 100%;
    height: 100%;

    max-width: 100%;

    margin: 0;
    padding: 4px;

    object-fit: contain;
    object-position: center center;

    transform: scale(1.10);

    transition:
        transform .18s ease;
}

#tcs-products-grid
.tcs-product-button:hover
.tcs-product-image {
    transform: scale(1.13);
}


/* ==========================================================
 * INFORMATIONS PRODUIT
 * ======================================================== */

#tcs-products-grid .tcs-product-info {
    padding: 10px 10px 9px;
}

#tcs-products-grid .tcs-product-name {
    min-height: 38px;

    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;

    color: #2c2622;
}

#tcs-products-grid .tcs-product-meta {
    margin-top: 8px;
    padding-top: 8px;

    border-top: 1px solid #eee9e5;
}

#tcs-products-grid .tcs-product-stock {
    padding: 4px 7px;

    border-radius: 6px;

    background: #f3f1ef;

    font-size: 11px;
}

#tcs-products-grid .tcs-product-plus {
    font-size: 23px;
    font-weight: 700;

    color: #2271b1;
}


/* ==========================================================
 * BADGE PANIER PRODUIT
 * ======================================================== */

#tcs-products-grid .tcs-product-cart-count {
    top: 7px;
    right: 7px;

    min-width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 4px 8px;

    font-size: 14px;
}


/* ==========================================================
 * OPERATION LIBRE
 * ======================================================== */

.tcs-caisse-nav-button--free {
    border: 1px solid #b8753a;

    background: #fff7ed;
    color: #70451f;

    cursor: pointer;
}

.tcs-free-operation-modal {
    position: fixed;
    inset: 0;

    z-index: 99999;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(0, 0, 0, .55);
}

.tcs-free-operation-modal[hidden] {
    display: none;
}

.tcs-free-operation-dialog {
    width: min(560px, 96vw);
    max-height: 92vh;

    overflow-y: auto;

    padding: 18px;

    border-radius: 14px;

    background: #fff;

    box-shadow:
        0 12px 40px
        rgba(0, 0, 0, .28);
}

.tcs-free-operation-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 15px;

    padding-bottom: 12px;
    margin-bottom: 14px;

    border-bottom: 1px solid var(--border);
}

.tcs-free-operation-header h2 {
    margin: 0;
}

.tcs-free-operation-header p {
    margin: 4px 0 0;

    color: #646970;

    font-size: 12px;
}

.tcs-free-operation-x {
    width: 38px;
    height: 38px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: #fff;

    font-size: 23px;
}

.tcs-free-operation-types {
    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 7px;

    margin-bottom: 15px;
}

.tcs-free-operation-types label {
    display: flex;
    align-items: center;

    gap: 6px;

    padding: 10px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: #f8f8f8;

    cursor: pointer;
}

.tcs-free-operation-types span {
    font-size: 12px;
    font-weight: 700;
}

.tcs-free-operation-field {
    display: block;

    margin-bottom: 12px;
}

.tcs-free-operation-field > span {
    display: block;

    margin-bottom: 5px;

    font-size: 12px;
    font-weight: 700;
}

.tcs-free-operation-field input,
.tcs-free-operation-field textarea {
    width: 100%;

    padding: 9px 10px;

    border: 1px solid var(--border);
    border-radius: 8px;
}

.tcs-free-operation-warning {
    margin-top: 6px;
    padding: 9px 11px;

    border-left: 4px solid #b8753a;

    background: #fff7ed;

    color: #70451f;

    font-size: 12px;
}

.tcs-free-operation-actions {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 8px;

    margin-top: 16px;
}

.tcs-free-operation-actions button {
    min-height: 44px;

    border-radius: 8px;
}

#tcs-free-operation-cancel {
    border: 1px solid var(--border);

    background: #fff;
}


/* ==========================================================
 * COMPTEUR OPERATION LIBRE
 * ======================================================== */

.tcs-free-operation-quantity {
    display: inline-grid;

    grid-template-columns:
        46px 72px 46px;

    align-items: stretch;

    gap: 6px;
}

.tcs-free-operation-quantity button {
    width: 46px;
    height: 46px;

    padding: 0;

    border: 1px solid #c3c4c7;
    border-radius: 9px;

    background: #fff;
    color: #2c2622;

    font-size: 24px;
    font-weight: 700;
    line-height: 1;

    cursor: pointer;
}

.tcs-free-operation-quantity button:hover {
    border-color: #b8753a;

    background: #fff7ed;
    color: #70451f;
}

.tcs-free-operation-quantity button:active {
    transform: scale(.96);
}

#tcs-free-operation-quantity {
    width: 72px !important;
    max-width: 72px;
    height: 46px;

    padding: 0 6px !important;

    border: 1px solid #c3c4c7;
    border-radius: 9px;

    background: #fff;

    text-align: center;

    font-size: 18px;
    font-weight: 700;

    -moz-appearance: textfield;
}

#tcs-free-operation-quantity::-webkit-inner-spin-button,
#tcs-free-operation-quantity::-webkit-outer-spin-button {
    margin: 0;

    -webkit-appearance: none;
}


/* ==========================================================
 * RESPONSIVE
 * ======================================================== */

@media screen and (max-height: 850px) {

    #tcs-products-grid .tcs-product-image-zone {
        height: 220px;
        min-height: 220px;
    }
}


@media screen and (max-height: 800px) {

    .tcs-caisse-tablette .tcs-cart {
        height: calc(100dvh - 160px);
        min-height: 420px;
    }
}


@media screen and (max-width: 900px) {

    #tcs-products-grid .tcs-product-image-zone {
        height: 210px;
        min-height: 210px;
    }

    #tcs-products-grid .tcs-product-image {
        transform: scale(1.07);
    }
}


@media screen and (max-width: 620px) {

    .tcs-free-operation-types {
        grid-template-columns: 1fr;
    }
}
