/* ============================================================
   Recipe Planner – Main Stylesheet
   ============================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ---- Reset & Base ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Brand – warm coral-orange (appetising, food-forward) */
    --brand:       #f97316;
    --brand-dark:  #ea580c;
    --brand-light: #ffedd5;

    /* Header – warm near-black (anchors the page, elegant) */
    --header-bg:   #1c1917;

    /* Surfaces */
    --surface:     #fafaf8;   /* warm off-white, makes food photos pop */
    --card:        #ffffff;
    --border:      #e8e5df;   /* warm border */

    /* Text */
    --text:        #1c1917;
    --text-muted:  #78716c;

    /* Misc */
    --radius:     12px;
    --radius-sm:  8px;
    --shadow-sm:  0 1px 4px rgba(0,0,0,.06);
    --shadow:     0 4px 18px rgba(249,115,22,.14);
    --shadow-md:  0 8px 36px rgba(249,115,22,.20);

    /* Meal-slot colours (used by JS data-slot CSS below) */
    --slot-breakfast-bg: #fef9c3; --slot-breakfast-fg: #a16207;
    --slot-lunch-bg:     #dcfce7; --slot-lunch-fg:     #15803d;
    --slot-dinner-bg:    #ede9fe; --slot-dinner-fg:    #6d28d9;
    --slot-snack-bg:     #ffe4e6; --slot-snack-fg:     #be185d;
}

html { font-size: 16px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--surface);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ---- Typography ---- */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1.1rem;  font-weight: 600; }
h4 { font-size: .9rem;   font-weight: 600; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
    background:
        linear-gradient(160deg, #1c1917 0%, #292524 45%, #44403c 100%);
}

.login-box {
    background: white;
    padding: 48px 40px;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0,0,0,.22);
    width: 100%;
    max-width: 420px;
}

.login-box .brand-icon {
    font-size: 2.8rem;
    display: block;
    text-align: center;
    margin-bottom: 8px;
}

.login-box h1 {
    color: var(--brand-dark);
    text-align: center;
    margin-bottom: 4px;
}

.login-box h2 {
    color: var(--text-muted);
    text-align: center;
    font-weight: 400;
    font-size: 1rem;
    margin-bottom: 32px;
}

.error-message {
    background: #fff0f0;
    color: #c0392b;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    border-left: 4px solid #e74c3c;
    font-size: .9rem;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { margin-bottom: 22px; }

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
    font-size: .9rem;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px; /* prevents iOS zoom */
    font-family: inherit;
    color: var(--text);
    background: white;
    transition: border-color .2s, box-shadow .2s;
    appearance: auto;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(249,115,22,.18);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: .78rem;
}

.required { color: #e74c3c; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}

/* primary */
.btn-primary {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: white;
    box-shadow: 0 3px 12px rgba(249,115,22,.35);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(249,115,22,.45);
    filter: brightness(1.06);
}
.btn-primary:active { transform: translateY(0); }

/* secondary */
.btn-secondary {
    background: white;
    color: var(--text);
    border: 2px solid var(--border);
}
.btn-secondary:hover {
    border-color: var(--brand);
    color: var(--brand-dark);
    background: var(--brand-light);
}

/* danger */
.btn-danger {
    background: #dc3545;
    color: white;
}
.btn-danger:hover { background: #c82333; transform: translateY(-1px); }

/* warning */
.btn-warning { background: #ffc107; color: #333; }
.btn-warning:hover { background: #e0a800; }

/* success */
.btn-success { background: #28a745; color: white; }
.btn-success:hover { background: #218838; }

/* link */
.btn-link {
    background: none;
    color: var(--brand-dark);
    text-decoration: underline;
    padding: 4px 8px;
    box-shadow: none;
}
.btn-link:hover { color: var(--brand); }

/* sizes */
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }

/* login page full-width override */
.login-box .btn-primary { width: 100%; justify-content: center; }

/* ============================================================
   APP SHELL / HEADER / NAV
   ============================================================ */
.app-container { min-height: 100vh; background: var(--surface); }

.app-header {
    background: var(--header-bg);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,.30);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.build-tag {
    background: #22c55e;
    color: white;
    font-size: .65rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 10px;
    letter-spacing: .05em;
    vertical-align: middle;
}

.nav-primary {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    padding: 6px 16px;
    border-radius: 20px;
    color: rgba(255,255,255,.8);
    font-weight: 500;
    font-size: .9rem;
    transition: all .2s;
}

.nav-link:hover {
    background: rgba(255,255,255,.10);
    color: white;
}

.nav-link.active {
    background: var(--brand);
    color: white;
    box-shadow: 0 2px 10px rgba(249,115,22,.45);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.welcome-text {
    color: rgba(255,255,255,.85);
    font-size: .85rem;
}

.welcome-text strong { color: white; }

.user-info .btn-secondary {
    background: rgba(255,255,255,.10);
    color: rgba(255,255,255,.85);
    border-color: rgba(255,255,255,.25);
    font-size: .8rem;
    padding: 5px 14px;
}
.user-info .btn-secondary:hover {
    background: var(--brand);
    color: white;
    border-color: var(--brand);
}

.btn-logout .logout-icon { display: none; }

.app-main {
    padding: 28px 20px 60px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 28px;
}

.page-header h1 {
    color: var(--text);
}

.page-header .header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============================================================
   MESSAGES
   ============================================================ */
.message {
    padding: 13px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-weight: 500;
    font-size: .9rem;
}
.message.success { background: #eafaf2; color: #1a7a46; border-left: 4px solid #27ae60; }
.message.error   { background: #fff0f0; color: #c0392b; border-left: 4px solid #e74c3c; }

/* ============================================================
   LOADING / EMPTY STATES
   ============================================================ */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: .95rem;
}
.loading-state::before { content: '⏳ '; }

.empty-state {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; display: block; }
.empty-state p { margin-bottom: 20px; font-size: 1rem; }
.loading-msg { font-style: italic; }

/* ============================================================
   SEARCH & FILTERS
   ============================================================ */
.search-filters {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.search-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
}

.search-bar input {
    flex: 1;
    padding: 12px 18px 12px 42px;
    border: 2px solid var(--border);
    border-radius: 30px;
    font-size: 15px;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 14px center;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(249,115,22,.15);
    background-color: white;
}

.filter-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.filter-row > label {
    font-weight: 600;
    font-size: .82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    min-width: 70px;
}

/* ============================================================
   CATEGORY CARDS
   ============================================================ */
.category-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 20px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
    font-weight: 600;
    font-size: .85rem;
    min-width: 90px;
    transition: all .2s;
    color: var(--text-muted);
}

.category-card .cat-icon { font-size: 1.6rem; line-height: 1; }

.category-card:hover {
    border-color: var(--brand);
    color: var(--brand-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    background: var(--brand-light);
}

.category-card.active {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    border-color: transparent;
    color: white;
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

/* Category label + All button inline row */
.category-label-line {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.category-label-line > label {
    font-weight: 600;
    font-size: .82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

/* Desktop: All same size and layout as other category cards */
.category-card-all {
    flex-direction: column;
    gap: 6px;
    padding: 14px 20px 12px;
    min-width: 90px;
    font-size: .85rem;
}
.category-card-all .cat-icon { font-size: 1.6rem; line-height: 1; }

/* Labels row: label + chips + clear (matches category row pattern) */
.labels-filter-row {
    align-items: flex-start;
    gap: 10px;
}
.labels-filter-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.filter-row-label {
    font-weight: 600;
    font-size: .82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    flex-shrink: 0;
}
.label-chip-favorites.active {
    background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
    border-color: transparent;
    color: white;
}

/* ============================================================
   LABEL CHIPS
   ============================================================ */
.label-chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; }

.label-chip {
    padding: 5px 14px;
    border: 2px solid var(--border);
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-size: .82rem;
    font-weight: 500;
    transition: all .2s;
    color: var(--text-muted);
}

.label-chip:nth-child(6n+1) { border-color: #818cf8; color: #4338ca; background: #eef2ff; }
.label-chip:nth-child(6n+2) { border-color: #fb7185; color: #be123c; background: #fff1f2; }
.label-chip:nth-child(6n+3) { border-color: #34d399; color: #065f46; background: #ecfdf5; }
.label-chip:nth-child(6n+4) { border-color: #fbbf24; color: #92400e; background: #fffbeb; }
.label-chip:nth-child(6n+5) { border-color: #22d3ee; color: #0e7490; background: #ecfeff; }
.label-chip:nth-child(6n+6) { border-color: #a78bfa; color: #6d28d9; background: #faf5ff; }

.label-chip:hover {
    filter: brightness(.93);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.label-chip.active {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    border-color: transparent;
    color: white;
    filter: none;
}

/* ============================================================
   PLANNER SLOT SECTIONS
   ============================================================ */
.planner-slot-section {
    margin-bottom: 10px;
}

.planner-slot-label {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 3px 10px;
    border-radius: 12px;
    display: inline-block;
    margin-bottom: 6px;
}

.planner-slot-label[data-slot="breakfast"] { background: var(--slot-breakfast-bg); color: var(--slot-breakfast-fg); }
.planner-slot-label[data-slot="lunch"]     { background: var(--slot-lunch-bg);     color: var(--slot-lunch-fg); }
.planner-slot-label[data-slot="dinner"]    { background: var(--slot-dinner-bg);    color: var(--slot-dinner-fg); }
.planner-slot-label[data-slot="snack"]     { background: var(--slot-snack-bg);     color: var(--slot-snack-fg); }

.planner-remove-btn {
    background: none;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: .9rem;
    padding: 4px 6px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all .15s;
    line-height: 1;
}
.planner-remove-btn:hover { background: #fee2e2; color: #dc3545; }

.planner-card-img-placeholder {
    width: 46px;
    height: 46px;
    background: var(--brand-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.planner-day-empty {
    font-size: .85rem;
    color: var(--text-muted);
    padding: 10px 0;
    font-style: italic;
}

.today-badge {
    background: var(--brand);
    color: white;
    font-size: .68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ============================================================
   RECIPE SCHEDULE BADGE (on recipe cards)
   ============================================================ */
.recipe-schedule-badge {
    font-size: .75rem;
    color: var(--brand-dark);
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    background: var(--brand-light);
    margin-top: 6px;
    display: inline-block;
}

/* ============================================================
   RECIPE GRID & CARDS
   ============================================================ */
.recipes-page { padding-bottom: 40px; }

.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.recipe-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform .2s, box-shadow .2s;
}

.recipe-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.recipe-card-link {
    display: block;
    flex: 1;
    text-decoration: none;
    color: inherit;
}

.recipe-card-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.recipe-card-placeholder {
    width: 100%;
    height: 160px;
    background: linear-gradient(135deg, #fff7ed, #ffedd5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.recipe-card-body {
    padding: 14px;
}

.recipe-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
    line-height: 1.3;
}

.recipe-card-category {
    font-size: .78rem;
    color: var(--brand-dark);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 8px;
}

.recipe-card-labels { display: flex; flex-wrap: wrap; gap: 4px; }

.recipe-label-chip {
    display: inline-block;
    padding: 2px 9px;
    background: var(--brand-light);
    color: var(--brand-dark);
    border-radius: 12px;
    font-size: .72rem;
    font-weight: 500;
}

.recipe-card-actions {
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: #fafbff;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.favorite-btn {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: color .2s, border-color .2s;
}

.favorite-btn:hover {
    color: var(--brand-dark);
    border-color: var(--brand);
}

.favorite-btn.active {
    color: #eab308;
    border-color: #eab308;
}

/* ============================================================
   RECIPE DETAIL (MODAL)
   ============================================================ */
#recipeDetailBody h4 {
    margin: 16px 0 8px;
    color: var(--brand-dark);
    font-size: .9rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

#recipeDetailBody ul,
#recipeDetailBody ol {
    padding-left: 22px;
    line-height: 2;
}

#recipeDetailBody ul li,
#recipeDetailBody ol li {
    border-bottom: 1px solid var(--border);
    padding: 4px 0;
    font-size: .95rem;
}

/* ============================================================
   PLANNER PAGE
   ============================================================ */
.planner-page { padding-bottom: 40px; }

.week-range {
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    padding: 5px 16px;
    border-radius: 20px;
    font-size: .9rem;
}

.planner-content { margin-top: 4px; }

.planner-days {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.planner-day {
    background: white;
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: box-shadow .2s;
}

.planner-day:hover { box-shadow: var(--shadow); }

.planner-day.today {
    border: 2px solid var(--brand);
    box-shadow: 0 0 0 4px rgba(249,115,22,.12);
}

.planner-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.planner-day-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.planner-day.today .planner-day-header h3 {
    color: var(--brand-dark);
}

.planner-day-entries { min-height: 56px; margin-bottom: 12px; }

.planner-entry-card {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border);
    align-items: center;
}

.planner-card-clickable {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 10px;
    align-items: center;
    cursor: pointer;
}

.planner-card-clickable:hover .planner-card-body strong {
    color: var(--brand-dark);
}

.planner-card-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.planner-action-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.planner-action-btn:hover {
    background: var(--brand-light);
    color: var(--brand-dark);
}

.planner-card-img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.planner-card-body { flex: 1; min-width: 0; }

.planner-card-body strong {
    display: block;
    font-size: .9rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.planner-card-slot {
    display: inline-block;
    margin-top: 3px;
    font-size: .72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--brand-light);
    color: var(--brand-dark);
}

.planner-card-slot[data-slot="breakfast"] {
    background: var(--slot-breakfast-bg); color: var(--slot-breakfast-fg);
}
.planner-card-slot[data-slot="lunch"] {
    background: var(--slot-lunch-bg); color: var(--slot-lunch-fg);
}
.planner-card-slot[data-slot="dinner"] {
    background: var(--slot-dinner-bg); color: var(--slot-dinner-fg);
}
.planner-card-slot[data-slot="snack"] {
    background: var(--slot-snack-bg); color: var(--slot-snack-fg);
}

.planner-day-ingredients {
    border-top: 1px dashed var(--border);
    padding-top: 10px;
    margin-top: 4px;
    font-size: .82rem;
    color: var(--text-muted);
}

.planner-day-ingredients h4 {
    font-size: .78rem;
    color: var(--brand-dark);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 6px;
}

.planner-day-ingredients ul { padding-left: 18px; line-height: 1.8; }

/* recipe picker inside modal */
.recipe-picker { margin-bottom: 16px; }

.recipe-picker-section { margin-bottom: 20px; }
.recipe-picker-section > label { display: block; font-weight: 600; margin-bottom: 10px; }
.recipe-picker-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.recipe-picker-tab {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    font-size: .9rem;
}
.recipe-picker-tab:hover { border-color: var(--brand); }
.recipe-picker-tab.active {
    background: var(--brand);
    border-color: var(--brand);
    color: white;
}
.recipe-picker-tab-content { margin-top: 10px; }
#recipePickerSearch { margin-bottom: 12px; width: 100%; }
.recipe-picker-label-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.recipe-picker-empty, .recipe-picker-loading { color: var(--text-muted); font-size: .9rem; padding: 8px 0; }

.recipe-picker > label {
    display: block;
    font-weight: 600;
    font-size: .85rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.recipe-picker-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.recipe-picker-btn {
    background: white;
    border: 2px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    font-size: .85rem;
    cursor: pointer;
    transition: all .15s;
}
.recipe-picker-btn:hover { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-light); }
.recipe-picker-btn.active {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    border-color: transparent;
    color: white;
}

/* ============================================================
   RECIPE FORM
   ============================================================ */
.recipe-form-page { padding-bottom: 60px; }

.recipe-form {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    max-width: 640px;
}

.recipe-form .form-section {
    border-bottom: 1px solid var(--border);
    padding-bottom: 24px;
    margin-bottom: 24px;
}

.recipe-form .form-section:last-of-type { border-bottom: none; }

.recipe-form .form-section-title {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--brand-dark);
    margin-bottom: 16px;
}

/* Image upload */
.image-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    background: var(--surface);
}

.image-upload-area:hover,
.image-upload-area:focus-within {
    border-color: var(--brand);
    background: var(--brand-light);
}

.image-upload-prompt .upload-icon { font-size: 2.2rem; display: block; margin-bottom: 8px; }

.image-upload-prompt p {
    color: var(--text-muted);
    font-size: .9rem;
    margin: 0;
}

.image-preview { position: relative; text-align: center; }

.image-preview img {
    max-width: 100%;
    max-height: 220px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.image-preview .btn { margin-top: 10px; }

/* Repeatable rows */
/* Label picker (recipe form) */
.label-picker { margin-top: 4px; }
.label-picker-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    min-height: 32px;
}
.label-picker-empty {
    color: var(--text-muted);
    font-size: .9rem;
}
.label-chip-selected {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--brand-light);
    color: var(--brand-dark);
    border-radius: 20px;
    font-size: .88rem;
    font-weight: 500;
}
.label-chip-remove {
    background: none;
    border: none;
    color: var(--brand-dark);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    opacity: .7;
}
.label-chip-remove:hover { opacity: 1; color: #dc3545; }
.label-picker-available { margin-top: 8px; }
.label-picker-available-label {
    display: block;
    font-size: .82rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.label-picker-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.label-chip-available {
    padding: 5px 14px;
    border: 2px solid var(--border);
    border-radius: 20px;
    background: white;
    color: var(--text-muted);
    font-size: .85rem;
    cursor: pointer;
    transition: all .15s;
}
.label-chip-available:hover {
    border-color: var(--brand);
    color: var(--brand-dark);
    background: var(--brand-light);
}
.label-picker-new {
    display: flex;
    gap: 8px;
    align-items: center;
}
.label-picker-new input {
    flex: 1;
    max-width: 220px;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
}
.label-picker-new input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(249,115,22,.15);
}

.repeatable-list { margin-bottom: 10px; }

.repeatable-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.repeatable-row .ingredient-name,
.repeatable-row .step-text { flex: 1; }

.repeatable-row .ingredient-qty { width: 90px; flex-shrink: 0; }

.repeatable-row input,
.repeatable-row textarea {
    padding: 9px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: inherit;
    width: 100%;
    transition: border-color .2s;
}

.repeatable-row input:focus,
.repeatable-row textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(249,115,22,.15);
}

.btn-remove-row {
    background: none;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 1.3rem;
    padding: 6px;
    line-height: 1;
    border-radius: 50%;
    transition: all .15s;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
}
.btn-remove-row:hover { background: #fee2e2; color: #dc3545; }

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    flex-wrap: wrap;
}

.form-actions .btn { width: auto; }

.form-actions-danger {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #fee2e2;
}

/* ============================================================
   STOCK ALERTS (legacy section)
   ============================================================ */
.alerts-section {
    background: white;
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 14px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.section-header h2 { color: var(--text); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
}

.filter-group label {
    font-size: .85rem;
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
}

.filter-group select {
    padding: 8px 14px;
    border: 2px solid var(--brand);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 500;
    min-width: 130px;
    background: white;
    color: var(--text);
    cursor: pointer;
    transition: all .2s;
}

.filter-group select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(249,115,22,.18);
}

/* Table */
.alerts-table-container { overflow-x: auto; }

.alerts-table { width: 100%; border-collapse: collapse; }

.alerts-table thead { background: var(--surface); }

.alerts-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 2px solid var(--border);
}

.alerts-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}

.alerts-table tbody tr:hover { background: #fafbff; }
.alerts-table tbody tr[data-status="0"] { background: var(--surface); color: var(--text-muted); }
.alerts-table tbody tr[data-status="0"]:hover { background: #f0f1f6; }

.no-alerts { text-align: center; color: var(--text-muted); padding: 48px !important; }
.loading-msg { font-style: italic; }

/* Stock chips */
.stocks-cell { max-width: 320px; }

.stock-chip {
    display: inline-block;
    padding: 3px 10px;
    margin: 2px 4px 2px 0;
    background: var(--brand-light);
    color: var(--brand-dark);
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 500;
}

.stock-chip.removable { padding-right: 28px; position: relative; }

.chip-remove {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
}
.chip-remove:hover { color: #dc3545; }

.stocks-summary { margin-right: 8px; color: var(--text-muted); font-size: .85rem; }
.stocks-cell .manage-stocks-btn { margin-left: 4px; }

.stocks-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 12px 0;
}

.manage-stocks-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }

.manage-stocks-toolbar input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
}
.manage-stocks-toolbar input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(249,115,22,.15); }

/* Status badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 700;
    display: inline-block;
    letter-spacing: .02em;
}
.status-active   { background: #eafaf2; color: #1a7a46; }
.status-inactive { background: #fff0f0; color: #c0392b; }

/* ============================================================
   MODALS
   ============================================================ */
.modal {
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(15,20,40,.45);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,.25);
    animation: modal-in .2s ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(.95) translateY(12px); }
    to   { opacity: 1; transform: scale(1)  translateY(0);    }
}

.modal-content-wide { max-width: 600px; }
#addToPlannerModal .modal-content { max-width: 520px; }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #fff7ed, #ffedd5);
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h2 { color: var(--text); font-size: 1.1rem; }

.close-modal {
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.close-modal:hover { background: #ffe4e4; color: #dc3545; }

.modal-body { padding: 24px; }

/* Recipe detail modal: scale image to fit modal width/height (full image visible) */
.recipe-detail-img-wrap {
    margin: 0 0 1rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: min(50vh, 420px);
}
.recipe-detail-img {
    max-width: 100%;
    max-height: min(50vh, 420px);
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    border-radius: 8px;
    display: block;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .app-header {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas: "nav actions";
        gap: 8px 12px;
        padding: 10px 14px;
    }
    .header-left { display: contents; }
    .app-logo {
        display: none;
    }
    .nav-primary {
        grid-area: nav;
        justify-self: start;
        align-self: center;
    }
    .header-right {
        grid-area: actions;
        justify-self: end;
        align-self: center;
        gap: 6px;
    }
    .nav-link { padding: 5px 10px; font-size: .82rem; }
    .user-info .welcome-text { display: none; }
    .user-info .btn-logout .logout-text { display: none; }
    .user-info .btn-logout .logout-icon { display: inline; font-size: 1.1rem; }
    .user-info .btn-logout { padding: 6px 10px; min-width: auto; }
    .nav-link-alerts {
        font-size: .75rem;
        padding: 5px 8px;
        opacity: .7;
        color: rgba(255,255,255,.8);
    }
    .nav-link-alerts .nav-alerts-text { display: none; }
    .nav-link-alerts .nav-alerts-icon { font-size: 1rem; }
    .nav-link-alerts:hover, .nav-link-alerts.active { opacity: 1; color: white; }

    .app-main {
        padding: 16px 12px 60px;
    }

    .page-header { margin-bottom: 18px; }
    .page-header h1 { font-size: 1.4rem; }

    .recipes-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }

    .recipe-card-img,
    .recipe-card-placeholder { height: 120px; }

    .planner-days {
        grid-template-columns: 1fr;
    }
    .planner-day {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
    .planner-day.today {
        box-shadow: none;
        border: 2px solid var(--brand);
    }
    .planner-day-header h3 {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .planner-entry-card {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
    .planner-page .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .planner-page .header-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .modal {
        padding: 12px;
        align-items: flex-start;
    }
    .modal-content {
        max-width: 100%;
        max-height: calc(100vh - 24px);
        margin: auto;
    }
    .modal-header {
        padding: 14px 16px;
        flex-wrap: wrap;
    }
    .modal-header h2 {
        font-size: 1rem;
    }
    .modal-body {
        padding: 16px;
    }

    .category-filter-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .category-cards {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        overflow-x: unset;
        gap: 6px;
        padding-bottom: 0;
        width: 100%;
    }
    .category-card {
        flex-shrink: unset;
        min-width: 0;
        padding: 10px 8px;
        font-size: .78rem;
    }
    .category-card .cat-icon { font-size: 1.3rem; }

    .category-card-all {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        padding: 8px 10px;
        min-width: 0;
        font-size: .78rem;
    }
    .category-card-all .cat-icon { font-size: 1rem; }

    .section-header { flex-direction: column; align-items: flex-start; }

    .header-left { flex-direction: column; align-items: flex-start; width: 100%; gap: 10px; }

    .filter-group { width: 100%; flex-direction: column; align-items: flex-start; }
    .filter-group select { width: 100%; min-width: 0; }

    /* Mobile table → card view */
    .alerts-table { font-size: .85rem; display: block; }
    .alerts-table thead { display: none; }
    .alerts-table tbody tr {
        display: block;
        margin-bottom: 14px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 12px;
        background: white;
    }
    .alerts-table td {
        display: block;
        padding: 6px 0;
        border-bottom: none;
    }
    .alerts-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        display: block;
        margin-bottom: 3px;
        font-size: .72rem;
        text-transform: uppercase;
        letter-spacing: .04em;
    }
    .alerts-table td.stocks-cell::before    { content: "Stock(s)"; }
    .alerts-table td:nth-child(2)::before   { content: "Alert type"; }
    .alerts-table td:nth-child(3)::before   { content: "Status"; }
    .alerts-table td:nth-child(4)::before   { content: "Actions"; }
    .alerts-table td.no-alerts              { padding: 40px 20px; }
    .alerts-table td.no-alerts::before      { display: none; }
    .stocks-cell                            { max-width: none; }

    .recipe-form { padding: 20px 16px; }

    .search-filters { padding: 14px; }
}
