/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f7f5;
    color: #222;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar {
    background: #2d6a4f;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: rgba(255,255,255,0.85);
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover { color: #fff; }
.nav-active { color: #fff !important; border-bottom: 2px solid rgba(255,255,255,0.8); padding-bottom: 2px; }

/* ── Container ────────────────────────────────────────────────────────────── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Flash messages ───────────────────────────────────────────────────────── */
.flash {
    background: #d8f3dc;
    border: 1px solid #52b788;
    color: #1b4332;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1b4332;
    line-height: 1.2;
}

.back-link {
    display: inline-block;
    color: #52b788;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

.back-link:hover { text-decoration: underline; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 0.55rem 1.25rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s, transform 0.1s;
    white-space: nowrap;
}

.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary  { background: #2d6a4f; color: #fff; }
.btn-secondary { background: #e8f5e9; color: #2d6a4f; border: 1px solid #b7dfca; }
.btn-danger   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── Recipe grid ──────────────────────────────────────────────────────────── */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
}

.recipe-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border: 1px solid #e4ede7;
    transition: transform 0.2s, box-shadow 0.2s;
    display: block;
}

.recipe-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.recipe-card-header { margin-bottom: 0.5rem; }

.recipe-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1b4332;
    margin-bottom: 0.35rem;
    line-height: 1.3;
}

.recipe-source {
    font-size: 0.82rem;
    color: #666;
    margin-bottom: 0.5rem;
}

/* ── Badges & tags ────────────────────────────────────────────────────────── */
.meal-type-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
}

.meal-type-both   { background: #d8f3dc; color: #1b4332; }
.meal-type-lunch  { background: #fff3cd; color: #7c5500; }
.meal-type-dinner { background: #e0e7ff; color: #3730a3; }

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }

.tag {
    background: #f0faf4;
    border: 1px solid #b7dfca;
    color: #2d6a4f;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #555;
}

.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h2 { font-size: 1.4rem; margin-bottom: 0.5rem; color: #333; }
.empty-state p  { margin-bottom: 1.5rem; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-card {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border: 1px solid #e4ede7;
    max-width: 700px;
}

.form-card-narrow { max-width: 420px; }

.form-group { margin-bottom: 1.4rem; }

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: #1b4332;
    font-size: 0.95rem;
}

.form-hint {
    font-size: 0.82rem;
    color: #666;
    margin-bottom: 0.4rem;
    margin-top: -0.2rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid #c8ddd1;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fafcfa;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: #222;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #52b788;
    box-shadow: 0 0 0 3px rgba(82,183,136,0.15);
}

.required { color: #e53e3e; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding-top: 0.5rem;
}

/* ── Recipe detail ────────────────────────────────────────────────────────── */
.recipe-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 640px) {
    .recipe-detail-grid { grid-template-columns: 1fr; }
}

.recipe-section {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border: 1px solid #e4ede7;
}

.recipe-section h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1b4332;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #d8f3dc;
}

.ingredient-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ingredient-list li {
    padding: 0.4rem 0.6rem;
    background: #f5faf7;
    border-radius: 6px;
    font-size: 0.93rem;
}

.method-text p {
    margin-bottom: 0.75rem;
    font-size: 0.93rem;
    line-height: 1.65;
}

/* ── Meal plan calendar ───────────────────────────────────────────────────── */
.week-block { margin-bottom: 2.5rem; }

.week-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2d6a4f;
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.6rem;
}

@media (max-width: 900px) {
    .week-grid { grid-template-columns: repeat(4, 1fr); }
}

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

.day-card {
    background: #fff;
    border-radius: 10px;
    padding: 0.85rem 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    border: 1px solid #e4ede7;
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.6rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e4ede7;
}

.day-name  { font-weight: 700; font-size: 0.85rem; color: #1b4332; }
.day-date  { font-size: 0.75rem; color: #888; }

.day-meals { display: flex; flex-direction: column; gap: 0.5rem; }

.meal-slot { display: flex; flex-direction: column; gap: 0.1rem; }

.meal-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #52b788;
}

.meal-name {
    font-size: 0.82rem;
    color: #333;
    line-height: 1.3;
}

.meal-name:hover { color: #2d6a4f; text-decoration: underline; }

/* ── Shopping list ────────────────────────────────────────────────────────── */
.shopping-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.75rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border: 1px solid #e4ede7;
    max-width: 560px;
}

.shopping-list { list-style: none; display: flex; flex-direction: column; }

.shopping-item {
    padding: 0.55rem 0;
    border-bottom: 1px solid #f0f4f1;
}

.shopping-item:last-child { border-bottom: none; }

.shopping-item label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.shopping-check { width: 16px; height: 16px; accent-color: #2d6a4f; flex-shrink: 0; }

.shopping-item input:checked + span {
    text-decoration: line-through;
    color: #aaa;
}

/* ── Print styles ─────────────────────────────────────────────────────────── */
@media print {
    .navbar, .btn, .back-link { display: none; }
    body { background: #fff; }
    .shopping-card { box-shadow: none; border: none; }
}
