/* ------------------------- */
/*    1. Theming & Variablen */
/* ------------------------- */
:root {
    /* Farbpalette (Light Mode) */
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-text-primary: #212529;
    --color-text-secondary: #6c757d;
    --color-border: #dee2e6;
    --color-primary: #25b16a;
    --color-primary-hover: #1f8f54;
    --color-shadow: rgba(0, 0, 0, 0.05);

    /* Statusfarben */
    --color-status-expired: #dc3545;
    --color-status-expiring-soon: #ffc107;
    --color-status-safe: #198754; 

    /* Layout-Variablen */
    --border-radius-sm: 0.25rem;
    --border-radius-md: 0.5rem;
    --border-radius-lg: 1rem;
    --container-padding: 1.5rem;
}

body.dark-mode {
    /* Farbpalette (Dark Mode) */
    --color-bg: #121212;
    --color-surface: #1e1e1e;
    --color-text-primary: #e9ecef;
    --color-text-secondary: #adb5bd;
    --color-border: #495057;
    --color-primary: #28a745;
    --color-primary-hover: #218838;
    --color-shadow: rgba(0, 0, 0, 0.2);

    /* Statusfarben für besseren Kontrast im Dark Mode */
    --color-status-expired: #f06a77;
    --color-status-expiring-soon: #ffd65c;
    --color-status-safe: #48c774;
}

/* ------------------------- */
/*    2. Basis & Layout      */
/* ------------------------- */
html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    transition: background-color 0.2s ease, color 0.2s ease;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main.container {
    flex-grow: 1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--container-padding);
}

/* ------------------------- */
/*    3. Komponenten-Styling */
/* ------------------------- */

/* Header & Aktionen */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

h1 {
    color: var(--color-text-primary);
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Auto-Sync Schalter */
.autosync-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    user-select: none;
}

.autosync-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--color-primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* View-Tabs & Suche */
.view-switcher {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.view-tab {
    background: none;
    border: none;
    padding: 0.75rem 1rem;
    cursor: pointer;
    color: var(--color-text-secondary);
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.view-tab:hover {
    color: var(--color-text-primary);
}

.view-tab.is-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.search-bar {
    position: relative;
    margin-bottom: 2.5rem;
}

.search-bar input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    font-size: 1rem;
}

.search-bar .fa-search {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
}

/* ------------------------------------- */
/*    4. Modernes Grid-Karten-Layout     */
/* ------------------------------------- */

/* Sektionen & Gruppen */
.category-section {
    margin-bottom: 3rem;
}

.category-section__title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.product-group {
    margin-bottom: 2.5rem;
}

.product-group__title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--color-text-primary);
}

/* Das Grid-Container Element */
.product-grid {
    display: grid;
    gap: 1.5rem; 
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Die neue Produkt-Karte */
.product-card {
    display: flex;
    flex-direction: column; 
    position: relative;
    background: var(--color-surface);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 4px 15px var(--color-shadow);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-top: 4px solid;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

body.dark-mode .product-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
}

/* Statusfarben für den oberen Rand */
.product-card.expired { border-color: var(--color-status-expired); }
.product-card.expiring-soon { border-color: var(--color-status-expiring-soon); }
.product-card.safe { border-color: var(--color-status-safe); }

/* Bild-Bereich */
.product-card__image-link {
    display: block;
    height: 160px; /* Feste Höhe für einheitliches Aussehen */
    background-color: var(--color-bg);
    padding: 1rem;
}

.product-card__image {
    width: 100%;
    height: 100%;
    object-fit: contain; 
}

/* Hauptinhalts-Bereich */
.product-card__content {
    padding: 1rem 1.25rem;
    flex-grow: 1;
}

.product-card__content h3 {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.product-card__content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

/* Footer-Bereich der Karte mit MHD-Info */
.product-card__footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.85rem;
    font-weight: 500;
}

.product-card.expired .product-card__footer { color: var(--color-status-expired); }
.product-card.expiring-soon .product-card__footer { color: var(--color-status-expiring-soon); }
.product-card.safe .product-card__footer { color: var(--color-status-safe); }

/* Aktionen (Löschen, Bearbeiten) */
.product-card__actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

.product-card__action-btn {
    background-color: rgba(0, 0, 0, 0.3);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    font-size: 0.9rem;
}

.product-card__action-btn:hover {
    background-color: rgba(0, 0, 0, 0.5);
    transform: scale(1.1);
}

.product-card__action-btn.delete-btn:hover {
    background-color: var(--color-status-expired);
}

.product-card__category {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-primary);
    background-color: rgba(37, 177, 106, 0.1); 
    padding: 0.2rem 0.5rem;
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body.dark-mode .product-card__category {
    color: var(--color-bg);
    background-color: var(--color-primary);
}


.product-card__content h3 {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.product-card__action-btn.consume-btn:hover {
    background-color: var(--color-primary); /* Nutzt deine primäre Akzentfarbe (grün) */
}

/* Optional: Das Icon für den Löschen-Button anpassen */
.product-card__action-btn.delete-btn .fa-trash-alt {
    font-size: 0.85rem; /* Ggf. die Größe anpassen, da das Mülleimer-Icon anders ist */
}

/* ------------------------- */
/*    5. Responsive Design     */
/* ------------------------- */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
}

/* ---------------------------------- */
/*    6. Empty View & Feedback States   */
/* ---------------------------------- */

.empty-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    background-color: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--border-radius-lg);
}

/* Anpassung des Bildes/Icons */
.empty-view img {
    display: block;       
    margin-left: auto; 
    margin-right: auto;  
    height: 100px; 
    width: auto;
    margin-bottom: 2rem;
    opacity: 0.6;
    filter: invert(0.8);
}

#product-groups-container:has(> .empty-view:not([style*="display: none"])) {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

#product-groups-container .empty-view {
    max-width: 600px;
    width: 100%;
}

body:not(.dark-mode) .empty-view img {
    filter: none;
}


.empty-view p {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    font-weight: 500;
    line-height: 1.6; 
    margin: 0; 
}

.empty-view .btn {
    margin-top: 1.5rem;
}