@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    --bg-1: #f5f2ec;
    --bg-2: #eef4f2;
    --ink-1: #101418;
    --ink-2: #3a424a;
    --ink-3: #69727c;
    --brand-1: #0f766e;
    --brand-2: #f97316;
    --brand-3: #2563eb;
    --card: #ffffff;
    --border: rgba(16, 20, 24, 0.08);
    --shadow-1: 0 10px 30px rgba(16, 20, 24, 0.08);
    --shadow-2: 0 18px 50px rgba(16, 20, 24, 0.14);
    --radius-1: 14px;
    --radius-2: 22px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    color: var(--ink-1);
    line-height: 1.6;
    background: radial-gradient(1200px 600px at 10% -10%, #ffe9d2 0%, transparent 55%),
                radial-gradient(1000px 600px at 100% 0%, #d7f3f0 0%, transparent 55%),
                linear-gradient(180deg, var(--bg-1), var(--bg-2));
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: radial-gradient(rgba(16, 20, 24, 0.035) 1px, transparent 1px);
    background-size: 18px 18px;
    opacity: 0.6;
    pointer-events: none;
    z-index: -1;
}

/* Navigation */
.main-nav {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 1.5rem;
    display: flex;
    gap: 0.6rem;
    position: sticky;
    top: 0;
    z-index: 20;
    overflow-x: auto;
    scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
    display: none;
}

.nav-link {
    color: var(--ink-2);
    text-decoration: none;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(15, 118, 110, 0.12);
    color: var(--brand-1);
}

.nav-link.active {
    background: var(--brand-1);
    color: #fff;
    box-shadow: 0 8px 22px rgba(15, 118, 110, 0.25);
}

/* Container */
.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 3.5rem;
}

h1 {
    font-family: "Fraunces", "Space Grotesk", serif;
    font-size: clamp(1.85rem, 3.2vw, 2.8rem);
    margin-bottom: 1.6rem;
    color: #fff;
    letter-spacing: 0.2px;
    padding: 1.6rem 1.8rem;
    border-radius: var(--radius-2);
    background-size: cover;
    background-position: center;
    box-shadow: var(--shadow-2);
    text-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

h2, h3 {
    font-family: "Fraunces", "Space Grotesk", serif;
}

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 1rem;
    color: var(--ink-2);
    border-radius: 999px;
    transition: all 0.2s ease;
}

.tab:hover {
    border-color: rgba(15, 118, 110, 0.4);
    color: var(--brand-1);
    background: rgba(15, 118, 110, 0.08);
}

.tab.active {
    background: var(--brand-1);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.25);
    font-weight: 600;
}

/* Tab Content */
.tab-content {
    display: none;
    background: var(--card);
    padding: 1.7rem;
    border-radius: var(--radius-2);
    box-shadow: var(--shadow-1);
    border: 1px solid var(--border);
    animation: fadeUp 0.45s ease;
}

.tab-content.active {
    display: block;
}

/* Formulare */
label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--ink-2);
}

input[type="text"],
input[type="number"],
input[type="url"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 0.75rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    margin-top: 0.35rem;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: rgba(15, 118, 110, 0.6);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
    transform: translateY(-1px);
}

.row {
    display: flex;
    gap: 1rem;
}

.row label {
    flex: 1;
}

/* Buttons */
.btn {
    padding: 0.8rem 1.6rem;
    border: none;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-1), #0ea5a5);
    color: #fff;
    margin-top: 1rem;
    box-shadow: 0 12px 24px rgba(14, 165, 165, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 30px rgba(14, 165, 165, 0.3);
}

.btn-primary:disabled {
    background: #c9cfd6;
    box-shadow: none;
    cursor: not-allowed;
}

/* Vorschau */
.preview {
    background: var(--card);
    padding: 1.6rem;
    border-radius: var(--radius-2);
    box-shadow: var(--shadow-1);
    margin-top: 1.5rem;
    border: 1px solid rgba(249, 115, 22, 0.35);
    position: relative;
}

.preview::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius-2);
    border: 2px dashed rgba(249, 115, 22, 0.35);
    pointer-events: none;
    opacity: 0.6;
}

.preview h2 {
    color: var(--brand-2);
    margin-bottom: 1rem;
}

/* Bild-Vorschau */
#bild-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.8rem;
    margin-top: 0.8rem;
}

#bild-preview img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(16, 20, 24, 0.12);
    border: 1px solid var(--border);
}

/* Status */
.status {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    margin-top: 1rem;
    font-weight: 600;
}

.status.success {
    background: rgba(34, 197, 94, 0.12);
    color: #166534;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.status.error {
    background: rgba(239, 68, 68, 0.12);
    color: #7f1d1d;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1rem;
    color: var(--ink-3);
}

.spinner {
    width: 26px;
    height: 26px;
    border: 3px solid rgba(16, 20, 24, 0.12);
    border-top-color: var(--brand-1);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Header backgrounds */
.page-add h1 {
    background-image: linear-gradient(120deg, rgba(15, 118, 110, 0.55), rgba(15, 23, 42, 0.35)), url("assets/headers/header-add.png");
    background-image: linear-gradient(120deg, rgba(15, 118, 110, 0.55), rgba(15, 23, 42, 0.35)),
        image-set(
            url("assets/headers/header-add.webp") type("image/webp"),
            url("assets/headers/header-add.png") type("image/png")
        );
}

.page-recipes h1 {
    background-image: linear-gradient(120deg, rgba(249, 115, 22, 0.55), rgba(30, 41, 59, 0.35)), url("assets/headers/header-recipes.png");
    background-image: linear-gradient(120deg, rgba(249, 115, 22, 0.55), rgba(30, 41, 59, 0.35)),
        image-set(
            url("assets/headers/header-recipes.webp") type("image/webp"),
            url("assets/headers/header-recipes.png") type("image/png")
        );
}

.page-plan h1 {
    background-image: linear-gradient(120deg, rgba(37, 99, 235, 0.55), rgba(15, 23, 42, 0.35)), url("assets/headers/header-plan.png");
    background-image: linear-gradient(120deg, rgba(37, 99, 235, 0.55), rgba(15, 23, 42, 0.35)),
        image-set(
            url("assets/headers/header-plan.webp") type("image/webp"),
            url("assets/headers/header-plan.png") type("image/png")
        );
}

.page-shopping h1 {
    background-image: linear-gradient(120deg, rgba(22, 163, 74, 0.55), rgba(15, 23, 42, 0.35)), url("assets/headers/header-shopping.png");
    background-image: linear-gradient(120deg, rgba(22, 163, 74, 0.55), rgba(15, 23, 42, 0.35)),
        image-set(
            url("assets/headers/header-shopping.webp") type("image/webp"),
            url("assets/headers/header-shopping.png") type("image/png")
        );
}

/* === Wochenplan === */
.week-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.1rem;
    margin-top: 1.5rem;
}

.day-card {
    background: var(--card);
    border-radius: var(--radius-1);
    padding: 1.2rem;
    box-shadow: var(--shadow-1);
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s, border-color 0.2s;
    border: 1px solid var(--border);
    position: relative;
    animation: fadeUp 0.45s ease;
}

.day-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
}

.day-card:active {
    cursor: grabbing;
}

.day-card.dragging {
    opacity: 0.4;
}

.day-card.drag-over {
    border: 2px dashed rgba(15, 118, 110, 0.5);
    background: rgba(15, 118, 110, 0.08);
}

.btn-swap {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    background: rgba(15, 118, 110, 0.1);
    border: 1px solid rgba(15, 118, 110, 0.25);
    border-radius: 8px;
    color: var(--brand-1);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    line-height: 1;
    transition: all 0.2s ease;
}

.btn-swap:hover {
    background: var(--brand-1);
    color: #fff;
    border-color: var(--brand-1);
}

.day-card.weekend {
    border: 1px solid rgba(249, 115, 22, 0.35);
    box-shadow: 0 14px 36px rgba(249, 115, 22, 0.15);
}

.day-thumb {
    width: min(33%, 90px);
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border);
    margin-bottom: 0.7rem;
}

.day-name {
    font-weight: 700;
    color: var(--ink-2);
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.day-recipe {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.day-meta {
    color: var(--ink-3);
    font-size: 0.85rem;
}

.plan-info {
    margin-top: 1rem;
    color: var(--ink-3);
    font-size: 0.85rem;
}

.empty-msg {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--ink-3);
    padding: 3rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(16, 20, 24, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(6px);
}

.modal-content {
    background: var(--card);
    border-radius: var(--radius-2);
    padding: 2rem;
    max-width: 640px;
    width: 92%;
    max-height: 82vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-2);
}

.modal-close {
    position: absolute;
    top: 0.8rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--ink-3);
}

.modal-close:hover {
    color: var(--ink-1);
}

.modal-content h2 {
    color: var(--ink-1);
    margin-bottom: 0.6rem;
    padding-right: 2rem;
}

.modal-meta {
    color: var(--ink-3);
    margin-bottom: 1rem;
    display: flex;
    gap: 1.5rem;
}

.modal-content h3 {
    color: var(--brand-2);
    margin: 1rem 0 0.5rem;
}

.modal-content ul {
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-content li {
    margin-bottom: 0.3rem;
}

.tag {
    display: inline-block;
    background: rgba(37, 99, 235, 0.12);
    color: #1e3a8a;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    margin-right: 0.3rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.badge-tm {
    background: rgba(34, 197, 94, 0.16);
    color: #166534;
}

.badge-normal {
    background: rgba(37, 99, 235, 0.16);
    color: #1e3a8a;
}

/* Filter-Bar */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.filter-bar input {
    flex: 1;
}

.filter-bar select {
    width: 220px;
    margin-top: 0;
}

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

.recipe-card {
    background: var(--card);
    border-radius: var(--radius-1);
    padding: 1.2rem;
    box-shadow: var(--shadow-1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border);
    animation: fadeUp 0.45s ease;
}

.recipe-thumb {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 0.7rem;
    border: 1px solid var(--border);
}

.image-preview {
    margin: 0.3rem 0 0.8rem;
}

.image-preview.hidden {
    display: none;
}

.image-preview img {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.btn-ghost {
    background: transparent;
    color: var(--ink-2);
    border: 1px solid var(--border);
    padding: 0.55rem 1.1rem;
    margin-bottom: 1rem;
}

.btn-ghost:hover {
    border-color: rgba(239, 68, 68, 0.5);
    color: #b91c1c;
    box-shadow: 0 8px 18px rgba(239, 68, 68, 0.12);
}

.btn-ghost:disabled {
    color: var(--ink-3);
    border-color: var(--border);
    box-shadow: none;
    cursor: not-allowed;
}

.recipe-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
}

.recipe-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--ink-1);
}

.recipe-card-meta {
    color: var(--ink-3);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.recipe-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

/* Anmerkung im Modal */
.modal-anmerkung {
    margin-top: 1rem;
    padding: 0.7rem 0.9rem;
    background: rgba(15, 118, 110, 0.08);
    border-left: 3px solid var(--brand-1);
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--ink-2);
}

.modal-anmerkung a {
    color: var(--brand-3);
    word-break: break-all;
}

.modal-anmerkung a:hover {
    color: #1d4ed8;
}

.recipe-detail {
    display: grid;
    grid-template-columns: minmax(0, 220px) 1fr;
    gap: 1.2rem;
    align-items: start;
}

.recipe-media img {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-1);
}

.recipe-text h3 {
    margin-top: 0.6rem;
}

/* Modal-Aktionen */
.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-actions .btn {
    flex: 1;
}

.btn-edit {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #fff;
}

.btn-edit:hover {
    transform: translateY(-1px);
}

.btn-delete {
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: #fff;
}

.btn-delete:hover {
    transform: translateY(-1px);
}

.btn-cancel {
    background: #94a3b8;
    color: #fff;
    margin-top: 1rem;
}

.btn-cancel:hover {
    background: #64748b;
}

.edit-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.edit-actions .btn {
    flex: 1;
}

/* === Tausch-Modal === */
.swap-info {
    color: var(--ink-3);
    margin-bottom: 1rem;
}

.swap-search {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    margin-bottom: 1rem;
    font-family: inherit;
    background: #fff;
}

.swap-search:focus {
    outline: none;
    border-color: rgba(15, 118, 110, 0.6);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

.swap-list {
    max-height: 400px;
    overflow-y: auto;
}

.swap-item {
    padding: 0.8rem;
    border-bottom: 1px solid rgba(16, 20, 24, 0.06);
    cursor: pointer;
    border-radius: 12px;
    transition: background 0.2s;
}

.swap-item:hover {
    background: rgba(15, 118, 110, 0.08);
}

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

.swap-item-title {
    font-weight: 600;
    color: var(--ink-1);
    margin-bottom: 0.2rem;
}

.swap-item-meta {
    color: var(--ink-3);
    font-size: 0.85rem;
}

/* === Einkaufsliste === */
.shopping-actions {
    margin-bottom: 1.5rem;
}

.plan-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-shopping {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    color: #fff;
}

.btn-shopping:hover {
    transform: translateY(-1px);
}

.shopping-info {
    color: var(--ink-3);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.shopping-category {
    background: var(--card);
    border-radius: var(--radius-1);
    padding: 1.2rem;
    box-shadow: var(--shadow-1);
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    animation: fadeUp 0.45s ease;
}

.shopping-category-title {
    color: var(--brand-2);
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

.shopping-items {
    list-style: none;
    padding: 0;
}

.shopping-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.3rem;
    border-bottom: 1px solid rgba(16, 20, 24, 0.06);
    transition: opacity 0.3s, transform 0.3s;
}

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

.shopping-item.removing {
    opacity: 0;
    transform: translateX(20px);
}

.shopping-item-text {
    flex: 1;
    font-size: 1rem;
}

.btn-remove-item {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    transition: background 0.2s;
    line-height: 1;
}

.btn-remove-item:hover {
    background: rgba(239, 68, 68, 0.12);
}

.btn-print {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #fff;
}

.btn-print:hover {
    transform: translateY(-1px);
}

/* Print */
@media print {
    .main-nav,
    .shopping-actions,
    .btn-remove-item,
    .status,
    .loading {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
        font-size: 12pt;
    }

    .container {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    h1 {
        font-size: 18pt;
        margin-bottom: 0.5rem;
        color: #000;
    }

    .shopping-info {
        color: #666;
        margin-bottom: 0.8rem;
    }

    .shopping-category {
        box-shadow: none;
        padding: 0.5rem 0;
        margin-bottom: 0.5rem;
        break-inside: avoid;
        border: none;
    }

    .shopping-category-title {
        color: #000;
        font-size: 13pt;
        border-bottom: 1px solid #ccc;
        padding-bottom: 0.2rem;
        margin-bottom: 0.4rem;
    }

    .shopping-item {
        padding: 0.2rem 0;
        border-bottom: 1px dotted #ddd;
    }

    .shopping-item::before {
        content: "\2610";
        margin-right: 0.5rem;
        font-size: 14pt;
    }
}

/* Responsive */
@media (max-width: 720px) {
    .container {
        padding: 1.1rem 0.95rem 2.2rem;
    }

    .main-nav {
        gap: 0.5rem;
        padding: 0.6rem 0.75rem;
    }

    .tab {
        flex: 1;
        text-align: center;
        font-size: 0.95rem;
    }

    h1 {
        padding: 1.2rem 1.3rem;
        border-radius: 18px;
    }

    .row {
        flex-direction: column;
        gap: 0;
    }

    .week-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
    }

    .filter-bar select {
        width: 100%;
    }

    .recipe-grid {
        grid-template-columns: 1fr;
    }

    .recipe-detail {
        grid-template-columns: 1fr;
    }

    .tab-content {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .modal-content {
        padding: 1.4rem;
        max-height: 86vh;
    }

    .modal-actions,
    .edit-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    #bild-preview {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 420px) {
    .tabs {
        gap: 0.4rem;
    }

    .tab {
        padding: 0.55rem 0.8rem;
        font-size: 0.9rem;
    }

    h1 {
        font-size: 1.65rem;
        padding: 1rem 1.1rem;
    }

    #bild-preview {
        grid-template-columns: 1fr;
    }

    .day-card {
        padding: 1rem;
    }
}
