/* ==========================================
   HomeCooking - Custom Styles
   Nested CSS für moderne Browser
   ========================================== */

/* App Header */
.app-header {
    text-align: center;
    padding: 1rem;
    margin-bottom: 1.5rem;
    background: var(--background-color);
    border-bottom: 1px solid var(--muted-border-color);
}

/* Bottom Navigation (Mobile-style) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--muted-border-color);
    padding: 0.5rem 0;
    z-index: 100;

    & .nav-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: var(--muted-color);
        padding: 0.25rem 0.5rem;
        transition: color 0.2s;

        &.active {
            color: var(--primary);
        }

        &:hover {
            color: var(--primary);
        }
    }

    & .nav-icon {
        font-size: 1.5rem;
        line-height: 1;
    }

    & .nav-label {
        font-size: 0.65rem;
        margin-top: 0.25rem;
    }
}

/* Add padding to main content to account for fixed bottom nav */
main.container {
    padding-bottom: 5rem;
}

/* Center app content */
#app {
    text-align: center;
}

/* Page Header (title + action button) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;

    & h2 {
        margin: 0;
    }

    @media (max-width: 768px) {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;

        & h2 {
            text-align: center;
        }
    }
}

/* Recipe Card */
.recipe-card {
    margin-bottom: 1rem;
    text-align: left;

    & .header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.5rem;

        & h4 {
            margin: 0;
        }
    }

    & details {
        text-align: left;
    }

    & .ingredients {
        padding-left: 1rem;
        text-align: left;

        & li {
            margin-bottom: 0.25rem;
        }
    }

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

/* Weekplan Grid */
.weekplan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 2.5rem;
    text-align: left;

    & .day-slot {
        border: 1px solid var(--muted-border-color);
        border-radius: var(--border-radius);
        padding: 1rem;
        padding-top: 2.5rem;
        position: relative;
        cursor: grab;
        transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s, border-color 0.2s;

        & .slot-controls {
            position: absolute;
            top: 0.5rem;
            right: 0.5rem;
            display: flex;
            align-items: center;
            gap: 0.25rem;
            opacity: 0.6;
            transition: opacity 0.2s;
        }

        & .move-btn {
            display: none;
            background: transparent;
            border: none;
            color: var(--muted-color);
            cursor: pointer;
            padding: 0.25rem;
            font-size: 0.75rem;
            line-height: 1;
            border-radius: 4px;
            transition: background 0.2s, color 0.2s;

            &:hover:not(:disabled) {
                background: var(--muted-border-color);
                color: var(--primary);
            }

            &:disabled {
                opacity: 0.3;
                cursor: not-allowed;
            }

            @media (max-width: 768px) {
                display: block;
            }
        }

        & .drag-handle {
            color: var(--muted-color);
            font-size: 0.875rem;
            cursor: grab;
            padding: 0.25rem;

            @media (max-width: 768px) {
                display: none;
            }
        }

        &:hover .slot-controls {
            opacity: 1;
        }

        & .day-header {
            font-weight: bold;
            margin-bottom: 0.5rem;
            color: var(--primary);
        }

        & .recipe-name {
            margin: 0.5rem 0;
        }

        & details {
            text-align: left;
        }

        & .change-btn {
            width: 100%;
            margin-top: 0.5rem;
        }

        &.empty {
            opacity: 0.6;
            border-style: dashed;
        }

        &.dragging {
            opacity: 0.4;
            transform: scale(0.95);
            cursor: grabbing;
        }

        &.drag-over-before::before {
            content: '';
            position: absolute;
            top: 0;
            bottom: 0;
            left: -0.6rem;
            width: 4px;
            background: var(--primary);
            border-radius: 2px;
            box-shadow: 0 0 8px rgba(24, 144, 255, 0.6);
        }

        &.drag-over-after::after {
            content: '';
            position: absolute;
            top: 0;
            bottom: 0;
            right: -0.6rem;
            width: 4px;
            background: var(--primary);
            border-radius: 2px;
            box-shadow: 0 0 8px rgba(24, 144, 255, 0.6);
        }
    }
}

/* Shopping List */
.shopping-list {
    text-align: left;

    & .item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.5rem;
        border-bottom: 1px solid var(--muted-border-color);

        & input[type="checkbox"] {
            margin: 0;
        }

        & .ingredient-info {
            flex: 1;
            text-align: left;

            & .amount {
                color: var(--muted-color);
                font-size: 0.9em;
            }
        }

        &.checked {
            opacity: 0.5;
            text-decoration: line-through;
        }
    }
}

/* Recipe Form */
.recipe-form {
    text-align: left;

    & .ingredients-list {
        border: 1px solid var(--muted-border-color);
        border-radius: var(--border-radius);
        padding: 1rem;
        margin-bottom: 1rem;

        & .ingredient-row {
            display: grid;
            grid-template-columns: 2fr 1fr 1fr auto;
            gap: 0.5rem;
            margin-bottom: 0.5rem;
            align-items: center;
        }
    }

    & .add-ingredient-btn {
        margin-bottom: 2rem;
    }

    & .form-actions {
        display: flex;
        gap: 1rem;
        justify-content: flex-end;

        & button:first-child {
            margin-right: auto;
        }
    }
}

/* Discover Header */
.discover-header {
    margin-bottom: 1.5rem;

    & button {
        margin-top: 2rem;
        margin-bottom: 1rem;
    }
}

/* Discover/API Card */
.api-recipe-card {
    text-align: left;

    & .recipe-image {
        width: 100%;
        max-width: 300px;
        border-radius: var(--border-radius);
        margin: 1rem 0;
    }

    & .instructions {
        white-space: pre-line;
        line-height: 1.6;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted-color);

    & svg {
        width: 64px;
        height: 64px;
        margin-bottom: 1rem;
        opacity: 0.3;
    }
}

/* Loading State */
#loading {
    text-align: center;
    padding: 2rem;
}

/* CTA Buttons Group */
.cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;

    a {
        margin-bottom: 0.5rem;
    }
}

/* Import/Export Actions */
.import-export-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--muted-border-color);

    & .import-btn {
        cursor: pointer;
        margin: 0;
    }
}

/* Mobile Navigation */
@media (max-width: 768px) {
    nav ul {
        flex-wrap: wrap;
        justify-content: center;

        & li {
            font-size: 0.9rem;
        }
    }

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

    /* Extra bottom margin for content above fixed nav on small screens */
    .empty-state a[role="button"],
    .empty-state button,
    #app > a[role="button"]:last-child {
        margin-bottom: 2rem;
    }
}
