/* ==========================================================
   FORMS
========================================================== */

.form-group{

    display:flex;

    flex-direction:column;

    gap:8px;

    margin-bottom:20px;

}

.complete-item-form{

    display:flex;

    flex-direction:column;

    gap:6px;

    min-width:160px;

}

.checkbox-grid{

    display:grid;

    grid-template-columns:repeat(auto-fill, minmax(180px, 1fr));

    gap:10px;

    padding:12px;

    border:1px solid var(--border);

    border-radius:10px;

    background:var(--surface-alt);

}

.checkbox-grid .checkbox{

    display:flex;

    align-items:center;

    gap:8px;

    font-weight:400;

}

.form-row{

    display:grid;

    grid-template-columns:repeat(auto-fit,minmax(260px,1fr));

    gap:20px;

}

.form-row-2{

    display:grid;

    grid-template-columns:1fr 1fr;

    gap:20px;

}

.form-row-3{

    display:grid;

    grid-template-columns:1fr 1fr 1fr;

    gap:20px;

}

/* ==========================================================
   LABELS
========================================================== */

label{

    font-size:13px;

    font-weight:600;

    color:var(--text-strong);

}

/* ==========================================================
   INPUTS
========================================================== */

input[type=text],
input[type=password],
input[type=email],
input[type=number],
input[type=date],
input[type=datetime-local],
input[type=search],
input[type=tel],
input[type=url],
textarea,
select,
.form-control,
.form-select{

    width:100%;

    height:44px;

    padding:0 14px;

    border:1px solid var(--border-strong);

    border-radius:10px;

    background:var(--input-bg);

    color:var(--text-strong);

    font-size:14px;

    transition:.18s;

}

/* Браузърите по подразбиране "изсветляват" забранени/само-за-четене
   полета (сив/бял фон), независимо от зададения background - изгледа на
   заключен документ (напр. потвърдена продажба) иначе излиза с бели полета
   върху тъмната тема. Държим стила напълно еднакъв с редактируемите полета. */
input:disabled,
input[readonly],
textarea:disabled,
textarea[readonly],
select:disabled,
.form-control:disabled,
.form-control[readonly]{

    background:var(--input-bg);

    color:var(--text-strong);

    opacity:1;

    -webkit-text-fill-color:var(--text-strong);

    cursor:not-allowed;

}

textarea{

    min-height:120px;

    padding:14px;

    resize:vertical;

}

/* Браузърите рендерират падащия списък на <select> с ОС-нативен фон,
   независимо от стила на самия select, освен ако <option> няма изрично
   зададени background/color - иначе списъкът излиза с бял фон дори при
   тъмна тема (нечетлив текст). */
select option{

    background:var(--input-bg);

    color:var(--text-strong);

}

/* ==========================================================
   PLACEHOLDER
========================================================== */

input::placeholder,
textarea::placeholder{

    color:var(--text-faint);

}

/* ==========================================================
   HOVER
========================================================== */

input:hover,
textarea:hover,
select:hover{

    border-color:var(--text-faint);

}

/* ==========================================================
   FOCUS
========================================================== */

input:focus,
textarea:focus,
select:focus{

    outline:none;

    border-color:var(--gold);

    box-shadow:0 0 0 4px rgba(201,162,39,.15);

}

/* ==========================================================
   CHECKBOX
========================================================== */

input[type=checkbox]{

    width:18px;

    height:18px;

    cursor:pointer;

}

/* ==========================================================
   RADIO
========================================================== */

input[type=radio]{

    cursor:pointer;

}

/* ==========================================================
   HELP TEXT
========================================================== */

.form-help{

    font-size:12px;

    color:var(--text-faint);

}

/* ==========================================================
   ERROR
========================================================== */

.input-error{

    border-color:#DC2626 !important;

}

.error-text{

    color:#DC2626;

    font-size:12px;

}

/* ==========================================================
   SUCCESS
========================================================== */

.input-success{

    border-color:#16A34A !important;

}

/* ==========================================================
   REQUIRED
========================================================== */

.required{

    color:#DC2626;

}

/* ==========================================================
   SEARCH
========================================================== */

.toolbar-search{

    min-width:0;

}

/* ==========================================================
   FILTERS
========================================================== */

.toolbar{

    display:flex;

    justify-content:space-between;

    align-items:center;

    gap:20px;

    flex-wrap:wrap;

}

.toolbar-left{

    display:flex;

    gap:14px;

    flex-wrap:wrap;

    align-items:center;

}

.toolbar-right{

    display:flex;

    gap:14px;

    flex-wrap:wrap;

    align-items:center;

}

/* ==========================================================
   SWITCHES
========================================================== */

.form-alert-danger{

    display:flex;

    align-items:center;

    gap:10px;

    background:#FEF2F2;

    border:1px solid #FCA5A5;

    color:#991B1B;

    border-radius:10px;

    padding:14px 18px;

    margin-bottom:18px;

    font-size:14px;

    font-weight:600;

}

.form-alert-warning{

    display:flex;

    align-items:center;

    gap:10px;

    background:#FFFBEB;

    border:1px solid #FCD34D;

    color:#92400E;

    border-radius:10px;

    padding:14px 18px;

    margin-bottom:18px;

    font-size:14px;

    font-weight:600;

}

.form-alert-success{

    display:flex;

    align-items:center;

    gap:10px;

    background:#F0FDF4;

    border:1px solid #86EFAC;

    color:#166534;

    border-radius:10px;

    padding:14px 18px;

    margin-bottom:18px;

    font-size:14px;

    font-weight:600;

}

.ingredients-toolbar{

    display:flex;

    gap:6px;

    margin-bottom:6px;

}

.ingredients-toolbar button{

    width:32px;

    height:32px;

    padding:0;

    border:1px solid var(--border-strong);

    border-radius:8px;

    background:var(--card);

    color:var(--text);

    font-size:14px;

    cursor:pointer;

}

.ingredients-toolbar button:hover{

    background:var(--surface-alt);

}

.ingredients-editor{

    /* height:auto - иначе .form-control (44px) реже по-дългия текст; resize+overflow позволяват оголемяване и скрол */

    height:auto;

    min-height:110px;

    overflow:auto;

    resize:vertical;

    white-space:normal;

    line-height:1.6;

    cursor:text;

}

.ingredients-editor:empty:before{

    content:attr(data-placeholder);

    color:var(--text-faint);

}

.ingredients-preview{

    /* height:auto - иначе .form-control (44px) реже по-дългия текст; resize+overflow позволяват оголемяване и скрол */

    height:auto;

    min-height:110px;

    overflow:auto;

    resize:vertical;

    white-space:normal;

    line-height:1.6;

    background:var(--surface-alt);

}

.lock-note{

    background:#FFFBEB;

    border:1px solid #FDE68A;

    border-radius:8px;

    padding:10px 14px;

    margin-bottom:14px;

    font-size:13px;

    color:#78350F;

}

.role-checkboxes{

    display:flex;

    flex-wrap:wrap;

    gap:10px 24px;

}

.form-switch{

    display:flex;

    align-items:center;

    gap:10px;

}

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

input[type=file]{

    width:100%;

    padding:10px;

    border:1px dashed var(--border-strong);

    border-radius:10px;

    background:var(--input-bg);

    color:var(--text);

}

/* ==========================================================
   RESPONSIVE
========================================================== */

@media(max-width:768px){

    .form-row,
    .form-row-2,
    .form-row-3{

        grid-template-columns:1fr;

    }

    .toolbar{

        flex-direction:column;

        align-items:stretch;

    }

    .toolbar-left,
    .toolbar-right{

        width:100%;

    }

    .toolbar-search{

        min-width:100%;

    }

}

/* ===========================
   Nutrition Grid
=========================== */

.nutrition-grid{
    display:grid;
    grid-template-columns:repeat(3,1fr);
    gap:20px;
    margin-top:15px;
}

.nutrition-item{
    display:flex;
    flex-direction:column;
}

.nutrition-item label{
    margin-bottom:8px;
    font-weight:600;
}

@media (max-width:992px){
    .nutrition-grid{
        grid-template-columns:repeat(2,1fr);
    }
}

@media (max-width:576px){
    .nutrition-grid{
        grid-template-columns:1fr;
    }
}

.allergen-grid{
    display:grid;
    grid-template-columns:repeat(4,minmax(180px,1fr));
    gap:14px 24px;
}

.allergen-item{
    display:flex;
    align-items:center;
    gap:10px;
    padding:8px 10px;
    border:1px solid var(--border);
    border-radius:8px;
    background:var(--card);
    cursor:pointer;
    transition:.2s;
}

.allergen-item:hover{
    background:var(--surface-alt);
    border-color:#d4af37;
}

.allergen-item input{
    margin:0;
    width:18px;
    height:18px;
}

.allergen-item span{
    font-weight:500;
}

@media (max-width:1200px){
    .allergen-grid{
        grid-template-columns:repeat(3,1fr);
    }
}

@media (max-width:768px){
    .allergen-grid{
        grid-template-columns:repeat(2,1fr);
    }
}

@media (max-width:576px){
    .allergen-grid{
        grid-template-columns:1fr;
    }
}

.grid-2{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:24px;
    align-items:start;
}

@media (max-width:992px){
    .grid-2{
        grid-template-columns:1fr;
    }
}

.input-with-button{
    position:relative;
}

.input-with-button .btn-icon{
    position:absolute;
    right:10px;
    top:50%;
    transform:translateY(-50%);
    width:34px;
    height:34px;
    border:none;
    border-radius:8px;
    background:var(--surface-alt);
    cursor:pointer;
}

.lookup-dropdown{
    display:none;
    position:absolute;
    right:0;
    bottom:42px;   /* вместо top */
    min-width:180px;
    background:var(--card);
    border:1px solid var(--border);
    border-radius:8px;
    box-shadow:0 8px 20px rgba(0,0,0,.15);
    z-index:9999;
}

.filters-row{
    display:flex;
    flex-wrap:nowrap;
    align-items:center;
    gap:16px;
    margin-bottom:20px;
}

.filters-row > *{
    flex:1 1 0;
    min-width:0;
}

.filters-row > .toolbar-search{
    flex:1.6 1 0;
}

@media (max-width:1100px){
    .filters-row{
        flex-wrap:wrap;
    }

    .filters-row > *{
        flex:1 1 calc(50% - 8px);
    }

    .filters-row > .toolbar-search{
        flex:1 1 100%;
    }
}

@media (max-width:700px){
    .filters-row > *{
        flex:1 1 100%;
    }
}

.image-preview{

    position:relative;

    width:320px;
    height:320px;

    margin:auto;

    border-radius:16px;

    overflow:hidden;

    cursor:pointer;

    border:2px dashed var(--border-strong);

    background:var(--surface-alt);

}

.image-preview img{

    width:100%;
    height:100%;

    object-fit:cover;

}

.image-overlay{

    position:absolute;

    inset:0;

    display:flex;

    flex-direction:column;

    justify-content:center;

    align-items:center;

    gap:10px;

    color:#fff;

    background:rgba(15,23,42,.55);

    opacity:0;

    transition:.25s;

}

.image-preview:hover .image-overlay{

    opacity:1;

}

.image-preview.drag-over{

    border-color:#C9A227;

    background:#FFF9E6;

}
