/* Recipe Cards Styling */

.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto 2rem;
}

/* ========== МОБІЛЬНА АДАПТАЦІЯ recipe-cards (max-width: 768px) ========== */
@media (max-width: 768px) {
    * { box-sizing: border-box !important; }
    body { overflow-x: hidden !important; width: 100% !important; }
    
    /* ЗАГОЛОВОК */
    .recipes-header {
        max-width: 100% !important;
        margin: 0 !important;
        margin-bottom: 1rem !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }
    
    .recipes-header h2 {
        font-size: 1.5rem !important;
        margin: 0 !important;
    }
    
    .header-actions {
        margin-left: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .header-actions > div {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    /* ПОШУК, КНОПКИ */
    #searchInput.page-search,
    #filterInput.page-search {
        width: 100% !important;
        max-width: none !important;
        padding: 0.65rem 1rem !important;
        padding-left: 44px !important;
    }
    
    .catalog-button,
    #searchBtn,
    #filterBtn,
    #catalogBtn,
    #catalogBtnCommunity {
        width: 100% !important;
        justify-content: center !important;
        height: 44px !important;
    }
    
    /* КАТЕГОРІЇ */
    .categories-container,
    .categories,
    .categories-modal-grid {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .categories::-webkit-scrollbar,
    .categories-modal-grid::-webkit-scrollbar {
        height: 4px !important;
    }
    
    .categories::-webkit-scrollbar-thumb,
    .categories-modal-grid::-webkit-scrollbar-thumb {
        background: #FF7A00 !important;
    }
    
    .cat-btn {
        flex: 0 0 auto !important;
        min-width: 100px !important;
        height: 40px !important;
        white-space: nowrap !important;
    }
    
    /* СІТКА РЕЦЕПТІВ */
    .recipes-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    .recipe-card {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        height: auto !important;
        background: linear-gradient(180deg, rgba(0,0,0,0.06), rgba(0,0,0,0.22)) !important;
        border: 1px solid rgba(255,255,255,0.03) !important;
        border-radius: 14px !important;
        overflow: hidden !important;
        box-shadow: 0 8px 26px rgba(2,6,23,0.65) !important;
    }
    
    .recipe-image {
        width: 100% !important;
        height: 200px !important;
        object-fit: cover !important;
        display: block !important;
        aspect-ratio: 16 / 9 !important;
    }
    
    .recipe-content {
        display: flex !important;
        flex-direction: column !important;
        padding: 1rem !important;
        gap: 0.5rem !important;
    }
    
    .recipe-title {
        font-size: 1rem !important;
        font-weight: 600 !important;
        margin: 0 !important;
        color: #fff !important;
    }
    
    .recipe-description {
        font-size: 0.85rem !important;
        color: #9aa6b6 !important;
        margin: 0 !important;
        line-height: 1.4 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }
    
    .recipe-meta {
        display: flex !important;
        gap: 1rem !important;
        font-size: 0.75rem !important;
        color: #9aa6b6 !important;
        margin-top: 0.25rem !important;
    }
    
    /* ПАГІНАЦІЯ */
    .pagination {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        max-width: 1200px !important;
        margin: 2rem auto !important;
        gap: 0.5rem !important;
        flex-wrap: wrap !important;
    }
    
    .pagination > * {
        margin: 0 !important;
    }
    
    .page-btn {
        width: 44px !important;
        height: 44px !important;
        min-height: 44px !important;
        font-size: 0.9rem !important;
        padding: 0 !important;
    }
}

/* Recipes page header and catalog button (moved here so recipes page works with only this file) */
.recipes-header {
    max-width: 1200px;
    margin: 0 auto 1.25rem;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1rem;
    width: 100%;
}
.recipes-header h2 { color: #ffffff; font-size: 2rem; margin: 0 }
.recipes-header .header-actions { margin-left: auto; display: flex; gap: 0.5rem; align-items: center }

/* Page search input used on recipes page */
.page-search {
    padding: 0.65rem 1rem;
    width: 300px;
    max-width: 520px;
    background: var(--bg-2);
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 999px;
    box-shadow: inset 0 -4px 12px rgba(0,0,0,0.25), 0 6px 20px rgba(2,6,23,0.45);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239aa6b6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='6'></circle><line x1='21' y1='21' x2='16.65' y2='16.65'></line></svg>");
    background-repeat: no-repeat;
    background-position: 14px center;
    padding-left: 44px;
    transition: box-shadow 160ms ease, border-color 160ms ease, transform 120ms ease;
    font-size: 0.95rem;
}
.page-search::placeholder { color: #9aa6b6; }
.page-search:focus {
    outline: none;
    border-color: rgba(255,122,0,0.9);
    box-shadow: 0 6px 28px rgba(255,122,0,0.08), inset 0 0 0 3px rgba(255,122,0,0.03);
    transform: translateY(-1px);
}

@media (max-width: 900px) {
    .page-search { width: 220px; max-width: 60%; }
}

/* Ensure recipes page #searchInput with page-search class matches community design (override existing #searchInput rules) */
input#searchInput.page-search {
    padding: 0.65rem 1rem;
    width: 300px;
    max-width: 520px;
    background: var(--bg-2);
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 999px;
    box-shadow: inset 0 -4px 12px rgba(0,0,0,0.25), 0 6px 20px rgba(2,6,23,0.45);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239aa6b6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='6'></circle><line x1='21' y1='21' x2='16.65' y2='16.65'></line></svg>");
    background-repeat: no-repeat;
    background-position: 14px center;
    padding-left: 44px;
    transition: box-shadow 160ms ease, border-color 160ms ease, transform 120ms ease;
    font-size: 0.95rem;
}


.catalog-button {
    background: linear-gradient(90deg, #ff8c1a, #ff7a00);
    border: none;
    color: #fff;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 26px rgba(255,122,0,0.12);
    transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
    height: 40px;
}
.catalog-button:hover { transform: translateY(-3px); box-shadow: 0 20px 44px rgba(255,122,0,0.16); filter: brightness(1.02) }
.catalog-button:focus { outline: 3px solid rgba(255,122,0,0.12); outline-offset: 3px }
.catalog-button .cat-icon { font-size: 1rem; display:inline-block; color:#fff }

/* Categories modal layout and buttons */
.categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}
.cat-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    color: #e6eef8;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 800;
    transition: transform 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}
.cat-btn:hover { background: linear-gradient(90deg, rgba(255,122,0,0.12), rgba(255,122,0,0.06)); border-color: rgba(255,122,0,0.18); color: #fff; transform: translateY(-3px) scale(1.01); box-shadow: 0 8px 20px rgba(255,122,0,0.06) }
.cat-btn[aria-pressed="true"], .cat-btn.active { background: linear-gradient(90deg, #ff7a00, #ff8c1a); color: #111; border-color: transparent; box-shadow: 0 10px 26px rgba(255,122,0,0.14); transform: translateY(-2px) }

@media (max-width: 780px) { .categories { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.6rem } }

.recipe-card {
    background: linear-gradient(180deg, rgba(0,0,0,0.06), rgba(0,0,0,0.22));
    border: 1px solid rgba(255,255,255,0.03);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 26px rgba(2,6,23,0.65);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, background 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.recipe-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 14px 36px rgba(2,6,23,0.78);
    border-color: rgba(255,122,0,0.12);
    background: linear-gradient(180deg, rgba(0,0,0,0.07), rgba(0,0,0,0.26));
}

.recipe-image {
    width: 100%;
    height: 200px;
    background-size: cover;
    background-position: center;
    background-color: #e9ecef;
}

.recipe-info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.recipe-card h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 0.5rem 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.recipe-description {
    font-size: 0.95rem;
    color: #9aa6b6;
    margin: 0.25rem 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
}

.recipe-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.meta-left {
    display: flex;
    gap: 0.35rem;
    flex-wrap: nowrap;
    flex: 1 1 auto;
    min-width: 0;
    overflow: visible;
    align-items: center;
}

.recipe-category {
    display: inline-block;
    background: #ffffff;
    color: #ff7a00;
    padding: 0.08rem 0.32rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 6px 14px rgba(2,6,23,0.12);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    flex: 0 0 auto;
    position: relative;
    left: 0;
    vertical-align: middle;
    line-height: 1.1;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 4px;
}

/* Force cook time and badges to stay on one line where space allows */
.recipe-meta { flex-wrap: nowrap; }
.cook-time { white-space: nowrap; flex: 0 0 auto; margin-right: 0.5rem; min-width: 36px; flex-shrink: 0; position: relative; z-index: 2; }

/* Stronger selector to prevent number and unit breaking on narrow layouts */
.recipes-grid .recipe-card .recipe-meta .meta-left .cook-time { white-space: nowrap; }

.cook-time {
    display: inline-block;
    color: #ffffff;
    font-size: 0.85rem;
}

.meta-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.meta-right { margin-left: 6px; }

.recipe-button {
    background: linear-gradient(90deg, #ff7a00, #ff8c1a);
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 0.22rem 0.8rem;
    height: 28px;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 160ms ease, box-shadow 160ms ease;
    box-shadow: 0 3px 8px rgba(255,122,0,0.10);
}

/* Slightly smaller recipe button specifically on community recipes page */
.recipes-page .recipe-button {
    padding: 0.16rem 0.6rem;
    height: 26px;
    font-size: 0.78rem;
    box-shadow: 0 2px 6px rgba(255,122,0,0.08);
}

.recipe-button:hover {
    background: #ff8c1a;
}

.recipe-like {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #9aa6b6);
    transition: color 0.2s ease, transform 0.2s ease;
}

.recipe-like:hover {
    transform: scale(1.2);
}

.recipe-like.liked {
    color: #ff6b6b;
}

.recipe-like svg {
    width: 24px;
    height: 24px;
}

/* Pagination */
.pagination {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 1200px !important;
    margin: 2rem auto !important;
    gap: 0.6rem !important;
    flex-wrap: wrap !important;
}

.page-btn,
.page-next {
    padding: 0.36rem 0.85rem;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
    color: #e6eef8;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, color 180ms ease;
    font-weight: 700;
    min-width: 40px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(2,6,23,0.36);
}

.page-btn:hover,
.page-next:hover {
    transform: translateY(-3px);
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,122,0,0.12);
    color: #fff;
    box-shadow: 0 12px 28px rgba(2,6,23,0.46);
}

.page-btn.active {
    background: linear-gradient(90deg, var(--accent, #ff7a00), #ff8c1a);
    color: #111;
    border-color: transparent;
    box-shadow: 0 12px 32px rgba(255,122,0,0.12);
    transform: translateY(-2px);
}

/* next/prev emphasis */
.page-next {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
}

@media (max-width: 480px) {
    .pagination { gap: 0.45rem }
    .page-btn, .page-next { min-width: 36px; height: 32px; padding: 0.28rem 0.6rem; font-size: 0.86rem }
}

/* Responsive */
@media (max-width: 768px) {
    .recipes-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.5rem;
    }

    .recipe-image {
        height: 150px;
    }

    .recipe-info {
        padding: 1rem;
    }
}

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

    .recipe-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .meta-right {
        width: 100%;
        justify-content: space-between;
    }
}

/* Ensure consistent card height so meta aligns same as soups */
.recipe-card { min-height: 360px; }

/* Small-screen badge adjustments to keep cook-time and badge on one line */
@media (max-width: 480px) {
    .meta-left { gap: 0.4rem; }
    .cook-time { font-size: 0.85rem; }
    .recipe-category { padding: 0.12rem 0.4rem; font-size: 0.78rem; max-width: none; flex: 0 0 auto; }
    .recipe-button { padding: 0.18rem 0.65rem; height: 28px; font-size: 0.82rem; }
}
