/* Адаптация рецепта под себя */

:root {
    --adapt-accent: #0f766e;
    --adapt-accent-2: #059669;
    --adapt-accent-soft: rgba(15, 118, 110, 0.1);
    --adapt-accent-ring: rgba(15, 118, 110, 0.22);
    --adapt-ink: #0f172a;
    --adapt-muted: #64748b;
    --adapt-line: #e8eef5;
    --adapt-surface: #ffffff;
    --adapt-surface-2: #f7fafc;
    --adapt-danger: #e11d48;
    --adapt-danger-soft: rgba(225, 29, 72, 0.08);
    --adapt-radius: 14px;
    --adapt-control-h: 44px;
}

.recipe-adapt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    margin: 0.85rem 0 0.25rem;
    padding: 0.75rem 1.2rem;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #0d9488 0%, #059669 100%);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(5, 150, 105, 0.28);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.recipe-adapt-btn i {
    font-size: 0.95rem;
}

.recipe-adapt-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(5, 150, 105, 0.34);
    filter: brightness(1.03);
}

.recipe-adapt-btn:active:not(:disabled) {
    transform: translateY(0);
}

.recipe-adapt-btn:disabled,
.recipe-adapt-btn.is-locked {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
    filter: grayscale(0.25);
}

.recipe-adapt-btn-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--adapt-muted);
}

.recipe-adapt-private-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: var(--adapt-accent-soft);
    color: var(--adapt-accent);
    font-size: 0.78rem;
    font-weight: 600;
}

html.recipe-adapt-open,
body.recipe-adapt-open {
    overflow: hidden;
}

.recipe-adapt-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10060;
    align-items: stretch;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top, 0px)) max(0.75rem, env(safe-area-inset-right, 0px))
        max(0.75rem, env(safe-area-inset-bottom, 0px)) max(0.75rem, env(safe-area-inset-left, 0px));
    box-sizing: border-box;
}

.recipe-adapt-modal.show {
    display: flex;
    animation: recipe-adapt-fade 0.18s ease;
}

@keyframes recipe-adapt-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.recipe-adapt-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(4px);
}

.recipe-adapt-modal__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(880px, 100%);
    max-height: min(94vh, 900px);
    margin: auto;
    background: var(--adapt-surface);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 22px;
    box-shadow:
        0 8px 16px rgba(15, 23, 42, 0.06),
        0 28px 64px rgba(15, 23, 42, 0.2);
    overflow: hidden;
    animation: recipe-adapt-rise 0.22s ease;
}

@keyframes recipe-adapt-rise {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to { opacity: 1; transform: none; }
}

.recipe-adapt-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.35rem 1rem;
    border-bottom: 1px solid var(--adapt-line);
    background:
        radial-gradient(120% 80% at 0% 0%, rgba(16, 185, 129, 0.12), transparent 55%),
        linear-gradient(180deg, #f8fffc 0%, #fff 100%);
}

.recipe-adapt-modal__title {
    margin: 0;
    font-size: 1.22rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    color: var(--adapt-ink);
}

.recipe-adapt-modal__subtitle {
    margin: 0.4rem 0 0;
    font-size: 0.9rem;
    color: var(--adapt-muted);
    line-height: 1.45;
    max-width: 52ch;
}

.recipe-adapt-modal__close {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: 1px solid var(--adapt-line);
    border-radius: 12px;
    background: #fff;
    color: var(--adapt-muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.recipe-adapt-modal__close:hover {
    background: var(--adapt-surface-2);
    color: var(--adapt-ink);
    border-color: #d5dee8;
}

.recipe-adapt-modal__body {
    flex: 1;
    overflow: auto;
    padding: 1.1rem 1.35rem 1.35rem;
    background:
        linear-gradient(180deg, #fcfdff 0%, #fff 120px);
    -webkit-overflow-scrolling: touch;
}

.recipe-adapt-section {
    margin-bottom: 1.5rem;
}

.recipe-adapt-section h3 {
    margin: 0 0 0.85rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7c8aa0;
}

.recipe-adapt-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.85rem;
}

.recipe-adapt-field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #556277;
}

.recipe-adapt-field input[type="text"],
.recipe-adapt-field input[type="number"],
.recipe-adapt-field textarea,
.recipe-adapt-field select {
    width: 100%;
    box-sizing: border-box;
    min-height: var(--adapt-control-h);
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--adapt-line);
    border-radius: 12px;
    font: inherit;
    color: var(--adapt-ink);
    background: #fff;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.recipe-adapt-field input:focus,
.recipe-adapt-field textarea:focus,
.recipe-adapt-field select:focus {
    outline: none;
    border-color: var(--adapt-accent);
    box-shadow: 0 0 0 4px var(--adapt-accent-ring);
}

.recipe-adapt-field textarea {
    min-height: 84px;
    resize: vertical;
}

.recipe-adapt-meta-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
}

.recipe-adapt-image-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.85rem;
}

.recipe-adapt-image-preview {
    width: 88px;
    height: 88px;
    max-width: 88px;
    max-height: 88px;
    border-radius: 16px;
    object-fit: cover;
    background: var(--adapt-surface-2);
    border: 1px solid var(--adapt-line);
    flex-shrink: 0;
}

.recipe-adapt-image-preview.is-empty {
    display: none;
}

.recipe-adapt-image-actions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.recipe-adapt-secondary-btn,
.recipe-adapt-add-btn,
.recipe-adapt-remove-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border-radius: 12px;
    font: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.recipe-adapt-secondary-btn {
    padding: 0.65rem 0.95rem;
    border: 1px solid var(--adapt-line);
    background: #fff;
    color: #334155;
}

.recipe-adapt-secondary-btn:hover {
    border-color: #c9d5e3;
    background: var(--adapt-surface-2);
}

.recipe-adapt-add-btn {
    margin-top: 0.7rem;
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1.5px dashed rgba(15, 118, 110, 0.35);
    background: rgba(15, 118, 110, 0.04);
    color: var(--adapt-accent);
    font-weight: 650;
}

.recipe-adapt-add-btn:hover {
    background: rgba(15, 118, 110, 0.08);
    border-color: rgba(15, 118, 110, 0.5);
}

.recipe-adapt-remove-btn {
    width: var(--adapt-control-h);
    height: var(--adapt-control-h);
    border: 1px solid transparent;
    background: var(--adapt-danger-soft);
    color: var(--adapt-danger);
    flex-shrink: 0;
}

.recipe-adapt-remove-btn:hover {
    background: rgba(225, 29, 72, 0.14);
    border-color: rgba(225, 29, 72, 0.18);
}

.recipe-adapt-ing-list,
.recipe-adapt-step-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.recipe-adapt-ing-item,
.recipe-adapt-step-item {
    display: grid;
    gap: 0.65rem;
    padding: 0.85rem;
    border: 1px solid var(--adapt-line);
    border-radius: var(--adapt-radius);
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.recipe-adapt-ing-item:hover,
.recipe-adapt-step-item:hover {
    border-color: #d7e1ec;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

.recipe-adapt-ing-item {
    grid-template-columns: minmax(0, 1fr) 92px 92px var(--adapt-control-h);
    align-items: center;
}

.recipe-adapt-ing-item .ingredient-product {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    position: relative;
}

.recipe-adapt-ing-item .ingredient-amount,
.recipe-adapt-ing-item .ingredient-unit {
    width: 100%;
    height: var(--adapt-control-h);
    box-sizing: border-box;
    margin: 0;
    padding: 0 0.7rem;
    border: 1px solid var(--adapt-line);
    border-radius: 12px;
    background: var(--adapt-surface-2);
    color: var(--adapt-ink);
    font: inherit;
    font-weight: 600;
    text-align: center;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.recipe-adapt-ing-item .ingredient-amount:focus,
.recipe-adapt-ing-item .ingredient-unit:focus {
    outline: none;
    background: #fff;
    border-color: var(--adapt-accent);
    box-shadow: 0 0 0 4px var(--adapt-accent-ring);
}

.recipe-adapt-ing-item .ingredient-unit {
    padding-right: 1.6rem;
    background-image:
        linear-gradient(45deg, transparent 50%, #64748b 50%),
        linear-gradient(135deg, #64748b 50%, transparent 50%);
    background-position:
        calc(100% - 14px) calc(50% - 2px),
        calc(100% - 9px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    background-color: var(--adapt-surface-2);
    cursor: pointer;
}

.recipe-adapt-ing-item .select2-container {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.recipe-adapt-ing-item .select2-selection {
    min-height: var(--adapt-control-h) !important;
    height: var(--adapt-control-h) !important;
    border-radius: 12px !important;
    border: 1px solid var(--adapt-line) !important;
    background: var(--adapt-surface-2) !important;
    box-shadow: none !important;
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.recipe-adapt-ing-item .select2-container--open .select2-selection,
.recipe-adapt-ing-item .select2-container--focus .select2-selection {
    background: #fff !important;
    border-color: var(--adapt-accent) !important;
    box-shadow: 0 0 0 4px var(--adapt-accent-ring) !important;
}

.recipe-adapt-ing-item .select2-selection__rendered {
    line-height: calc(var(--adapt-control-h) - 2px) !important;
    padding-left: 0.9rem !important;
    padding-right: 2.4rem !important;
    color: var(--adapt-ink) !important;
    font-weight: 550;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recipe-adapt-ing-item .select2-selection__arrow {
    height: 100% !important;
    right: 8px !important;
}

.recipe-adapt-ing-item .select2-selection__clear {
    margin-right: 1.4rem !important;
    color: #94a3b8 !important;
    font-weight: 600;
}

/* Dropdown = ширина поля продукта (перебиваем profile.css min-width:100%) */
html body .recipe-adapt-modal .recipe-adapt-ing-item .ingredient-product .select2-dropdown,
html body .recipe-adapt-modal .recipe-adapt-ing-item .select2-container--open .select2-dropdown,
html body .recipe-adapt-modal .select2-dropdown.recipe-adapt-dd {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    left: 0 !important;
    right: auto !important;
    box-sizing: border-box !important;
}

html body .recipe-adapt-modal .recipe-adapt-ing-item .ingredient-product .select2-search--dropdown,
html body .recipe-adapt-modal .recipe-adapt-ing-item .ingredient-product .select2-search--dropdown .select2-search__field,
html body .recipe-adapt-modal .select2-dropdown.recipe-adapt-dd .select2-search__field {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

html body .recipe-adapt-modal .recipe-adapt-ing-item .select2-container {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.recipe-adapt-ing-item .ingredient-product .select2-results__option {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    box-sizing: border-box;
}

.recipe-adapt-modal__body,
.recipe-adapt-modal__dialog {
    overflow-x: hidden;
}

/* Никаких картинок продуктов в селекте адаптации */
.recipe-adapt-modal .select2-selection img,
.recipe-adapt-modal .select2-results img,
.recipe-adapt-modal .select2-product-option-img,
.recipe-adapt-modal .select2-product-selection-img,
.recipe-adapt-ing-item img {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.recipe-adapt-modal .select2-product-option,
.recipe-adapt-modal .select2-product-selection {
    display: inline !important;
}

.recipe-adapt-modal .select2-dropdown {
    border: 1px solid var(--adapt-line) !important;
    border-radius: 14px !important;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14) !important;
    overflow: hidden;
    box-sizing: border-box !important;
}

.recipe-adapt-modal .select2-results__option--highlighted {
    background: var(--adapt-accent) !important;
}

.recipe-adapt-step-item {
    grid-template-columns: 32px minmax(0, 1fr) var(--adapt-control-h);
    align-items: start;
}

.recipe-adapt-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-top: 0.4rem;
    border-radius: 10px;
    background: var(--adapt-accent-soft);
    color: var(--adapt-accent);
    font-size: 0.82rem;
    font-weight: 750;
}

.recipe-adapt-step-item textarea {
    min-height: 72px;
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--adapt-line);
    border-radius: 12px;
    background: var(--adapt-surface-2);
    font: inherit;
    line-height: 1.45;
    color: var(--adapt-ink);
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.recipe-adapt-step-item textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--adapt-accent);
    box-shadow: 0 0 0 4px var(--adapt-accent-ring);
}

.recipe-adapt-modal__footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.7rem;
    padding: 1rem 1.35rem;
    border-top: 1px solid var(--adapt-line);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
}

.recipe-adapt-cancel-btn {
    padding: 0.8rem 1.15rem;
    border: 1px solid var(--adapt-line);
    border-radius: 999px;
    background: #fff;
    color: #475569;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.recipe-adapt-cancel-btn:hover {
    background: var(--adapt-surface-2);
    border-color: #d5dee8;
}

.recipe-adapt-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.8rem 1.25rem;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #0d9488, #059669);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(5, 150, 105, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.recipe-adapt-save-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(5, 150, 105, 0.34);
    filter: brightness(1.03);
}

.recipe-adapt-save-btn:disabled {
    opacity: 0.65;
    cursor: wait;
    box-shadow: none;
}

.recipe-adapt-error {
    margin: 0 0 0.9rem;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #be123c;
    font-size: 0.88rem;
    display: none;
}

.recipe-adapt-error.show {
    display: block;
}

@media (max-width: 720px) {
    .recipe-adapt-meta-row {
        grid-template-columns: 1fr;
    }

    .recipe-adapt-ing-item {
        grid-template-columns: 1fr 1fr var(--adapt-control-h);
        gap: 0.55rem;
    }

    .recipe-adapt-ing-item .ingredient-product {
        grid-column: 1 / -1;
    }

    .recipe-adapt-ing-item .ingredient-amount,
    .recipe-adapt-ing-item .ingredient-unit {
        width: 100%;
    }

    .recipe-adapt-modal__dialog {
        max-height: 100%;
        border-radius: 18px;
    }

    .recipe-adapt-modal__footer {
        flex-direction: column-reverse;
    }

    .recipe-adapt-cancel-btn,
    .recipe-adapt-save-btn {
        width: 100%;
        justify-content: center;
    }
}
