/* 1. Расширяем базовый контейнер и основной контент ТОЛЬКО на этой странице */
.container,
.main-content {
    max-width: none !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* (если разметка выглядит как recipe-page-container + sidebar + main-content) */
.recipe-page-container {
    align-items: stretch;
}

/* Разрешаем странице занимать всю ширину, перекрывая базовый .container */
.container {
    max-width: none !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.mealplans-page {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

.mealplans-container {
    padding: 20px;
    margin: 0 auto;
    max-width: 1400px; /* контейнер для 10 карточек */
    width: 100%;
    box-sizing: border-box;
}

/* если базовый шаблон ограничивает .content/.container — снимем лимит локально */
.mealplans-page .content,
.mealplans-page .container,
.mealplans-page .panel,
.mealplans-page .card,
.mealplans-page .wrapper,
.mealplans-page .inner,
.mealplans-page [class*="container"] {
    max-width: none !important;
    width: 100% !important;
}

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

/* Сетка карточек: 8 на ≥1600px, адаптивно уменьшаем */
.mealplans-list {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* ≥1600px — 8 колонок */
@media (min-width: 1600px) {
    .mealplans-list { grid-template-columns: repeat(8, minmax(200px, 1fr)); }
}
/* 1280–1599 — 6 */
@media (min-width: 1280px) and (max-width: 1599px) {
    .mealplans-list { grid-template-columns: repeat(6, minmax(200px, 1fr)); }
}
/* 1024–1279 — 5 */
@media (min-width: 1024px) and (max-width: 1279px) {
    .mealplans-list { grid-template-columns: repeat(5, minmax(200px, 1fr)); }
}
/* 768–1023 — 4 */
@media (min-width: 768px) and (max-width: 1023px) {
    .mealplans-list { grid-template-columns: repeat(4, minmax(200px, 1fr)); }
}
/* <768 — 2 */
@media (max-width: 767px) {
    .mealplans-list { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}

.mealplan-card {
    background: #fffefc;
    border: 1px solid #e8e6e0;
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 170px;
}

.mealplan-card_header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: start;
}

.mealplan-card_title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* максимум две строки */
    -webkit-box-orient: vertical;
}

.badge-cal {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid #ddd2b8;
    background: #fff8e6;
    white-space: nowrap;
}

.mealplan-card_meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 12px;
    color: #6b6b6b;
}

.chip-style {
    padding: 2px 8px;
    border-radius: 999px;
    background: #f3f6ff;
    border: 1px solid #dbe5ff;
}

.mealplan-card_desc {
    font-size: 12px;
    color: #545454;
    line-height: 1.3;
    margin-top: 2px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 32px;
}

.mealplan-card_actions {
    margin-top: auto;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    align-items: center !important;
    justify-content: flex-start !important;
}

.btn {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #d9d9d9;
    background: #fff;
    cursor: pointer;
}
.btn-primary {
    border-color: #3b82f6;
    background: #3b82f6;
    color: #fff;
}

/* Кнопка Список ингредиентов */
.btn-small {
    padding: 2px 6px;
    font-size: 11px;
    line-height: 1.2;
    border-radius: 4px;
}

.recipe-btn.view.btn-apply {
    background-color: #2196f3 !important;
    color: white !important;
    padding: 6px 10px !important;
    border-radius: 8px !important;
    border: none !important;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    transition: background 0.2s;
}

.recipe-btn.view.btn-apply:hover {
    background-color: #0b5e9e !important;
}

/* Скелетоны */
.card-skeleton {
    background: #fffefc;
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 12px;
    min-height: 170px;
    animation: pulse 1.2s infinite ease-in-out;
}
.skel-line { height: 12px; background: #f0f0f0; border-radius: 6px; margin: 8px 0; }
@keyframes pulse { 0% {opacity: .9} 50% {opacity: .5} 100% {opacity: .9} }

/* Пагинация */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: center;
    margin-top: 16px;
}
.pagination .page-btn {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 8px;
    border: 1px solid #d9d9d9;
    background: #fff;
    cursor: pointer;
}
.pagination .page-btn.active {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}
.pagination .page-btn[disabled] { opacity: .5; cursor: default; }

/* --- Модалка с деталями рациона --- */
.mealplan-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    z-index: 1000;
}

.mealplan-modal {
    background: #fffefc;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.18);
    max-width: 960px;
    width: 100%;
    max-height: calc(100vh - 80px);
    overflow: auto;
    padding: 18px 20px 20px;
    box-sizing: border-box;
}

.mealplan-modal_header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.mealplan-modal_title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px;
}

.mealplan-modal_meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
    align-items: center;
}

.mealplan-modal_close {
    border: none;
    background: #fff;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    border: 1px solid #e3e3e3;
    margin-left: 8px;
}

.mealplan-modal_close:hover {
    background: #ffecec;
    color: #c0392b;
}

.mealplan-modal_table-wrap {
    margin-top: 10px;
}

/* используем общий стиль таблицы сайта + чуть доработаем */
.mealplan-modal .table-box {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.mealplan-modal .table-box thead {
    background: #f6f8f6;
}

.mealplan-modal .table-box th,
.mealplan-modal .table-box td {
    padding: 6px 8px;
    border-bottom: 1px solid #ececec;
}

.mealplan-modal .table-box th {
    text-align: left;
    font-weight: 600;
}

.mealplan-modal .table-box td.num {
    text-align: right;
    white-space: nowrap;
}

/* Кнопка "Подробнее" — уменьшить и отключить width:100% из recipes.css */
.mealplan-card_actions .recipe-btn.view.btn-detail {
    font-size: 12px;
    padding: 6px 10px;
    width: auto !important;
    min-width: 0;
    border-radius: 8px;
    flex: 1;
}

/* Кнопка "Сохранить копию" — сделать равной по ширине */
.mealplan-card_actions .btn[data-clone] {
    font-size: 12px;
    padding: 6px 10px;
    white-space: nowrap;
    border-radius: 8px;
    flex: 1;
    text-align: center;
}

/* Hover на кнопке "Сохранить копию" */
.mealplan-card_actions .btn[data-clone]:hover {
    background-color: #f0f7ff;     /* лёгкий голубоватый фон */
    border-color: #8bb8ff;         /* подцветка границы */
    color: #0057d8;                /* чуть более активный текст */
    transition: all 0.15s ease;
}

.mealplan-card_actions .recipe-btn.view,
.mealplan-card_actions .btn {
    width: auto !important;
    margin: 0 !important;
    white-space: nowrap;
}

.plans-scope-tabs {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}

.plans-scope-tab {
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.3;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* делаем похожими на ваши recipe-btn */
.plans-scope-tab:hover {
    background: #eef5ff;
    border-color: #c5d9ff;
}

.plans-scope-tab.active {
    background: #4caf50;          /* основной зелёный как у кнопок */
    color: #fff;
    border-color: #4caf50;
}

/* --- Управление порциями в модалке ингредиентов --- */

.mealplan-portion-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 13px;
}

.mealplan-portion-controls_left {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.mealplan-portion-controls_right {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.mealplan-portion-label {
    margin-right: 4px;
    color: #555;
}

/* Инпут порций  */
.portion-input {
    width: 80px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #d9d9d9;
    font-size: 13px;
    line-height: 1.4;
    box-sizing: border-box;
}

.portion-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2);
}

@media (max-width: 600px) {
    .mealplan-portion-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .mealplan-portion-controls_right {
        margin-left: 0;
        justify-content: flex-start;
    }
}

/* Нижняя строка с кнопкой "Удалить" */
.mealplan-card_delete-row {
    margin-top: 4px;
    display: flex;
    justify-content: flex-end;
}

/* Красная кнопка "Удалить" в стиле сайта */
.btn-danger {
    border-color: #fca5a5;
    background: #fee2e2;
    color: #b91c1c;
}

.btn-danger:hover {
    background: #fecaca;
    border-color: #f97373;
    color: #7f1d1d;
    cursor: pointer;
}

.btn-danger:active {
    background: #fca5a5;
    border-color: #dc2626;
}

/* ========== Модальное окно для применения рациона ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    margin: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.close {
    float: right;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    color: #999;
}
.close:hover {
    color: #333;
}
.modal .form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}
.modal .form-group label {
    font-weight: 500;
    margin-bottom: 6px;
}
.modal .form-input {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
}
.modal .private-checkbox {
    background: #f5f5f5;
    padding: 8px 12px;
    border-radius: 8px;
}
.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}
.modal-buttons .filter-btn {
    background: #4caf50;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 30px;
    cursor: pointer;
}

.modal-buttons .filter-btn:hover {
    background-color: #45a049 !important;
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

.modal-buttons .filter-btn--secondary {
    background: #e0e0e0;
    color: #333;
}

.modal-buttons .filter-btn--secondary:hover {
    background-color: #d5d5d5 !important;
    transform: translateY(-1px);
}