/* =========================================================
   INGREDIENTS
   ========================================================= */

.tuco-ing-search-col {
    width: 520px !important;
    flex: 0 0 520px !important;
}

.tuco-ing-search {
    position: relative;
    width: 100%;
}

.tuco-ing-search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    color: var(--text);
    pointer-events: none;
}

.tuco-ing-search-input {
    height: 42px !important;
    width: 100%;
    padding-left: 40px !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    box-shadow: none !important;
}

.tuco-ing-search-input:focus {
    background: var(--surface) !important;
    border-color: var(--border) !important;
}

#ing-purchase-card {
    border-radius: var(--radius-lg);
    border: 1px solid #e8e1d8;
}

#ing-purchase-products .Select-control {
    min-height: 44px;
    border-radius: var(--radius-md) !important;
    border-color: #e2dbd2 !important;
}

#ing-purchase-products .Select-value {
    border-radius: var(--radius-sm) !important;
}

@media (max-width: 900px) {
    .tuco-ing-search-col {
        width: 100% !important;
        flex: 0 0 100% !important;
    }
}

/* Modal ingrédients — palette beige TucoData */
#ing-modal .modal-content,
#ing-modal .modal-header,
#ing-modal .modal-body,
#ing-modal .modal-footer {
    background: #fcf8f2 !important;
}

#ing-modal .modal-content {
    border: 1px solid #e5d9c9 !important;
    border-radius: var(--radius-lg) !important;
}

#ing-modal .form-control,
#ing-modal .form-select,
#ing-modal .Select-control {
    background: #f7f0e6 !important;
    border-color: var(--border) !important;
    box-shadow: none !important;
}

#ing-modal .form-control:focus,
#ing-modal .form-select:focus,
#ing-modal .Select-control.is-focused {
    background: var(--surface) !important;
    border-color: #cdbca5 !important;
}


/* Fond blanc pour la modale ingrédients */
#ing-modal .modal-content,
#ing-modal .modal-header,
#ing-modal .modal-body,
#ing-modal .modal-footer {
    background: var(--surface) !important;
}

/* On garde les champs légèrement beige */
#ing-modal .form-control,
#ing-modal .form-select,
#ing-modal .Select-control {
    background: var(--input-surface) !important;
}


/* Alignement Unité / Coût unitaire */
#ing-f-unit .Select-control,
#ing-f-cost {
    height: 42px !important;
    min-height: 42px !important;
}

/* Coins arrondis des champs beiges */
#ing-f-name,
#ing-f-cost {
    border-radius: var(--radius-md) !important;
}

/* Coins arrondis du dropdown unité aussi */
#ing-f-unit .Select-control {
    border-radius: var(--radius-md) !important;
}


/* Unité + Coût : exactement la même hauteur */
#ing-f-unit .Select-control,
#ing-f-cost {
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    box-sizing: border-box !important;
    border-radius: var(--radius-md) !important;
}

#ing-f-cost {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    line-height: 44px !important;
}

#ing-f-unit .Select-placeholder,
#ing-f-unit .Select-value {
    line-height: 42px !important;
}


/* FIX définitif : coût = exactement même hauteur que unité */
#ing-modal #ing-f-cost.form-control {
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    padding: 0 16px !important;
    line-height: normal !important;
    box-sizing: border-box !important;
    border-radius: var(--radius-md) !important;
}


/* Unit + cost: dimensions réellement identiques */
#ing-modal #ing-f-unit .Select-control,
#ing-modal .tuco-ing-cost-input {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    box-sizing: border-box !important;
    border-radius: var(--radius-md) !important;
}

#ing-modal .tuco-ing-cost-input {
    width: 100% !important;
    padding: 0 16px !important;
    border: 1px solid var(--border) !important;
    background: var(--input-surface) !important;
    font-size: 16px;
    outline: none;
}

#ing-modal #ing-f-unit .Select-value,
#ing-modal #ing-f-unit .Select-placeholder {
    line-height: 38px !important;
}


/* Ingredients: table = largeur réelle des colonnes */
#ing-grid.tabulator {
    width: fit-content !important;
    max-width: 100% !important;
    display: inline-block !important;
    vertical-align: top;
}


/* === INTERMEDIATE RECIPE BUILDER ALIGNMENT === */

/* Dropdown */
#ing-intermediate-component .Select-control {
    height: 48px !important;
    min-height: 48px !important;
}

#ing-intermediate-component .Select-placeholder,
#ing-intermediate-component .Select-value {
    height: 46px !important;
    line-height: 46px !important;
}

#ing-intermediate-component .Select-input {
    height: 46px !important;
}

#ing-intermediate-component .Select-input > input {
    height: 46px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* Quantité */
#ing-intermediate-qty {
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    margin: 0 !important;
}

/* Bouton Ajouter */
#ing-intermediate-add {
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* === END INTERMEDIATE RECIPE BUILDER ALIGNMENT === */


/* === INTERMEDIATE DROPDOWN HEIGHT - REAL CONTROL === */

#ing-intermediate-component,
#ing-intermediate-component .Select,
#ing-intermediate-component .Select-control,
#ing-intermediate-component .Select__control,
#ing-intermediate-component [class*="-control"] {
    min-height: 48px !important;
    height: 48px !important;
}

#ing-intermediate-component .Select-control,
#ing-intermediate-component .Select__control,
#ing-intermediate-component [class*="-control"] {
    display: flex !important;
    align-items: center !important;
}

#ing-intermediate-component .Select-placeholder,
#ing-intermediate-component .Select-value,
#ing-intermediate-component .Select__value-container,
#ing-intermediate-component [class*="-ValueContainer"],
#ing-intermediate-component [class*="-valueContainer"] {
    min-height: 46px !important;
    display: flex !important;
    align-items: center !important;
}

/* Les 3 contrôles de la ligne ont exactement la même hauteur */
#ing-intermediate-qty,
#ing-intermediate-add {
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
}


/* === INTERMEDIATE QUANTITY GROUP === */

#ing-intermediate-qty-group {
    height: 48px !important;
    min-height: 48px !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden !important;
}

#ing-intermediate-qty {
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    border-radius: 10px 0 0 10px !important;
    border-right: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}

#ing-intermediate-unit-badge {
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;

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

    min-width: 58px !important;

    border-radius: 0 10px 10px 0 !important;

    background: #f5f0e8 !important;
    color: var(--text-muted) !important;

    font-weight: 600 !important;
}

/* Les trois éléments restent parfaitement alignés */
#ing-intermediate-component,
#ing-intermediate-qty-group,
#ing-intermediate-add {
    height: 48px !important;
    min-height: 48px !important;
}

/* === END INTERMEDIATE QUANTITY GROUP === */



/* === INTERMEDIATE CREATE FORM — FINAL OVERRIDE === */

/* Grille réellement appliquée à la place des largeurs Bootstrap 7/3/2 */
@media (min-width: 768px) {
    html body #ing-modal
    #ing-intermediate-create-box
    .row.tuco-intermediate-create-row {
        display: grid !important;
        grid-template-columns:
            minmax(0, 1fr) 120px 145px !important;
        gap: 14px !important;
        align-items: end !important;

        width: 100% !important;
        margin: 0 !important;
    }

    html body #ing-modal
    #ing-intermediate-create-box
    .row.tuco-intermediate-create-row
    > [class*="col-"] {
        display: block !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: none !important;

        padding: 0 !important;
        margin: 0 !important;
    }

    /* _field ajoute normalement une marge basse :
       on la retire pour aligner le bouton. */
    html body #ing-modal
    .tuco-intermediate-name-col > .mb-3,
    html body #ing-modal
    .tuco-intermediate-parent-unit-col > .mb-3 {
        margin-bottom: 0 !important;
    }
}

/* Nom */
html body #ing-modal #ing-intermediate-name {
    display: block !important;
    width: 100% !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;

    padding: 0 16px !important;
    margin: 0 !important;

    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    background: var(--filter-surface) !important;
    box-shadow: none !important;
}

/* Unité */
html body #ing-modal #ing-intermediate-parent-unit,
html body #ing-modal #ing-intermediate-parent-unit > .Select,
html body #ing-modal #ing-intermediate-parent-unit .Select-control {
    width: 100% !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    margin: 0 !important;
}

html body #ing-modal
#ing-intermediate-parent-unit .Select-control {
    overflow: hidden !important;

    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    background: var(--surface) !important;
    box-shadow: none !important;
}

html body #ing-modal
#ing-intermediate-parent-unit .Select-value,
html body #ing-modal
#ing-intermediate-parent-unit .Select-placeholder,
html body #ing-modal
#ing-intermediate-parent-unit .Select-input {
    height: 42px !important;
    line-height: 42px !important;
}

/* Bouton Créer */
html body #ing-modal #ing-intermediate-create-parent {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    width: 145px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;

    padding: 0 16px !important;
    margin: 0 !important;

    border-radius: var(--radius-md) !important;
    white-space: nowrap !important;
}

/* Suppression complète des flèches du champ quantité */
html body #ing-modal
input#ing-intermediate-qty[type="number"] {
    appearance: textfield !important;
    -moz-appearance: textfield !important;
}

html body #ing-modal
input#ing-intermediate-qty[type="number"]::-webkit-inner-spin-button,
html body #ing-modal
input#ing-intermediate-qty[type="number"]::-webkit-outer-spin-button {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;

    appearance: none !important;
    -webkit-appearance: none !important;
}

/* Même hauteur et mêmes arrondis pour la ligne composant */
html body #ing-modal #ing-intermediate-component .Select-control,
html body #ing-modal #ing-intermediate-qty-group,
html body #ing-modal #ing-intermediate-add {
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    border-radius: var(--radius-md) !important;
}

html body #ing-modal #ing-intermediate-qty-group {
    overflow: hidden !important;
    border: 1px solid var(--border) !important;
}

html body #ing-modal #ing-intermediate-qty {
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;

    border: 0 !important;
    border-radius: 0 !important;
}

html body #ing-modal #ing-intermediate-unit-badge {
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;

    border: 0 !important;
    border-left: 1px solid var(--border) !important;
    border-radius: 0 !important;
}

/* Mobile */
@media (max-width: 767.98px) {
    html body #ing-modal
    #ing-intermediate-create-box
    .row.tuco-intermediate-create-row {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        margin: 0 !important;
    }

    html body #ing-modal
    #ing-intermediate-create-parent {
        width: 100% !important;
    }
}

