/* =============================================================
   Bäckerei Sortiment – Frontend CSS
   Basiert auf dem Pencil-Design (Hoenen Bakery)
   ============================================================= */

/* ---- CSS-Variablen ----------------------------------------- */
.bsort-wrapper {
    --bsort-bg:              transparent;
    --bsort-header-bg:       transparent;
    --bsort-card-bg:         #FFFFFF;
    --bsort-accent:          #F9A100;
    --bsort-accent-dark:     #C07800;
    --bsort-text-primary:    #1E0B0B;
    --bsort-text-secondary:  #6B6B6B;
    --bsort-text-muted:      #9A9A9A;
    --bsort-border:          #E5E2DC;
    --bsort-overlay:         rgba(30, 11, 11, 0.75);
    --bsort-radius-card:     16px;
    --bsort-radius-chip:     20px;
    --bsort-gap:             24px;
    --bsort-padding-h:       0;

    width: 100%;                /* Volle Breite im Brizy Flex-Container */
    margin-left: auto;
    margin-right: auto;
    align-self: stretch;        /* Brizy flex-direction:column + align-items:flex-start überschreiben */
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--bsort-text-primary);
    line-height: 1.5;
    padding-bottom: 48px;
}

/* ---- Hilfklassen ------------------------------------------- */
.bsort-hidden { display: none !important; }

/* =============================================================
   VIEW 1 – Kategorie-Übersicht
   ============================================================= */

.bsort-category-grid {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--bsort-gap);
    padding: 32px 0 0;
}

/* Kategorie-Karte */
.bsort-category-card {
    position: relative;
    height: 240px;
    border-radius: var(--bsort-radius-card);
    background-color: #C8B89A;          /* Fallback ohne Bild */
    background-size: cover;
    background-position: center;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.bsort-category-card:hover,
.bsort-category-card:focus {
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(30, 11, 11, 0.18);
}

.bsort-category-card:focus-visible {
    outline: 3px solid var(--bsort-accent);
    outline-offset: 2px;
}

/* Dunkler Verlauf unten (Text-Overlay) */
.bsort-category-overlay {
    position: absolute;
    inset: auto 0 0 0;
    background: linear-gradient(to top, rgba(30,11,11,0.85) 0%, rgba(30,11,11,0.4) 70%, transparent 100%);
    padding: 32px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bsort-category-name {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: #FFFFFF;
    line-height: 1.2;
    letter-spacing: -0.3px;
}

.bsort-category-count {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.75);
}

/* Leerzustand */
.bsort-empty-state {
    padding: 48px 0;
    text-align: center;
    color: var(--bsort-text-muted);
    font-size: 15px;
}

/* =============================================================
   VIEW 2 – Produkt-Liste mit Filter
   ============================================================= */

/* -- Header -------------------------------------------------- */
.bsort-products-header {
    background-color: var(--bsort-header-bg);
    padding: 40px 0 28px;
    margin-bottom: 0;
}

.bsort-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--bsort-accent);
    cursor: pointer;
    transition: opacity 0.15s;
    font-family: inherit;
}

.bsort-back-btn:hover { opacity: 0.75; }
.bsort-back-arrow { font-size: 16px; }

.bsort-products-title {
    margin: 10px 0 4px;
    font-size: 36px;
    font-weight: 700;
    color: var(--bsort-text-primary);
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.bsort-products-count {
    margin: 0;
    font-size: 16px;
    color: var(--bsort-text-secondary);
}

/* -- Filter-Leiste ------------------------------------------- */
.bsort-filter-bar {
    background-color: var(--bsort-header-bg);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 0 28px;
}

.bsort-filter-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--bsort-text-muted);
    white-space: nowrap;
}

.bsort-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Chip – Basis */
.bsort-chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 16px;
    border-radius: var(--bsort-radius-chip);
    border: 1px solid var(--bsort-border);
    background: #FFFFFF;
    color: var(--bsort-text-primary);
    font-size: 13px;
    font-weight: 400;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.bsort-chip:hover {
    border-color: var(--bsort-accent);
    color: var(--bsort-accent);
}

/* Chip – aktiv (orange) */
.bsort-chip-active {
    background: var(--bsort-accent) !important;
    border-color: var(--bsort-accent) !important;
    color: #FFFFFF !important;
    font-weight: 600;
}

/* Chip – Farb-Varianten (für gefärbte Filter im aktiven Zustand) */
.bsort-chip-color-0.bsort-chip-active { background: #5A9E6F !important; border-color: #5A9E6F !important; }
.bsort-chip-color-1.bsort-chip-active { background: #4A90D9 !important; border-color: #4A90D9 !important; }
.bsort-chip-color-2.bsort-chip-active { background: #7B5EA7 !important; border-color: #7B5EA7 !important; }
.bsort-chip-color-3.bsort-chip-active { background: #8B5E3C !important; border-color: #8B5E3C !important; }
.bsort-chip-color-4.bsort-chip-active { background: #C07800 !important; border-color: #C07800 !important; }
.bsort-chip-color-5.bsort-chip-active { background: #2D7A4F !important; border-color: #2D7A4F !important; }
.bsort-chip-color-6.bsort-chip-active { background: #B94040 !important; border-color: #B94040 !important; }
.bsort-chip-color-7.bsort-chip-active { background: #5887A4 !important; border-color: #5887A4 !important; }

/* -- Produkt-Grid -------------------------------------------- */
.bsort-product-grid {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--bsort-gap);
    padding: 32px 0 0;
    min-height: 200px;
    position: relative;
}

/* Produkt-Karte */
.bsort-product-card {
    background: var(--bsort-card-bg);
    border-radius: var(--bsort-radius-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 10px rgba(30, 11, 11, 0.07);   /* dauerhafter Schatten */
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.bsort-product-card:hover {
    box-shadow: 0 8px 28px rgba(30, 11, 11, 0.15);   /* stärkerer Hover-Schatten */
    transform: translateY(-3px);
}

/* Produktbild */
.bsort-product-img {
    width: 100%;
    height: 200px;
    background-size: cover;
    background-position: center;
    background-color: #E8E4DE;
    flex-shrink: 0;
}

.bsort-product-img.bsort-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bsort-text-muted);
    font-size: 13px;
}

/* Produktinhalt */
.bsort-product-content {
    padding: 16px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.bsort-product-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--bsort-text-primary);
    letter-spacing: -0.2px;
    line-height: 1.25;
}

.bsort-product-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bsort-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.6;
}

/* Tag-Farben (werden inline per JS gesetzt – diese Klassen als Fallback) */
.bsort-tag-0 { background: rgba(90,158,111,0.12);  color: #2D7A4F; }
.bsort-tag-1 { background: rgba(74,144,217,0.12);  color: #2B6CB0; }
.bsort-tag-2 { background: rgba(123,94,167,0.12);  color: #7B5EA7; }
.bsort-tag-3 { background: rgba(139,94,60,0.12);   color: #8B5E3C; }
.bsort-tag-4 { background: rgba(249,161,0,0.14);   color: #C07800; }
.bsort-tag-5 { background: rgba(45,122,79,0.12);   color: #2D7A4F; }
.bsort-tag-6 { background: rgba(185,64,64,0.12);   color: #B94040; }
.bsort-tag-7 { background: rgba(88,135,164,0.12);  color: #5887A4; }

.bsort-product-desc {
    margin: 0;
    font-size: 13px;
    color: var(--bsort-text-secondary);
    line-height: 1.55;
}

/* -- Lade-Indikator ------------------------------------------ */
.bsort-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 60px 0;
    color: var(--bsort-text-muted);
    font-size: 14px;
}

.bsort-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--bsort-border);
    border-top-color: var(--bsort-accent);
    border-radius: 50%;
    animation: bsort-spin 0.7s linear infinite;
}

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

/* -- Keine Ergebnisse ---------------------------------------- */
.bsort-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 0;
    color: var(--bsort-text-muted);
    font-size: 15px;
}

/* =============================================================
   Responsive Design
   ============================================================= */

/* ---- Tablet (≤ 991 px): 2 Spalten ------------------------ */
@media ( max-width: 991px ) {
    .bsort-category-grid,
    .bsort-product-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bsort-products-title { font-size: 30px; }
}

/* ---- Smartphone (≤ 767 px): 1 Spalte ----- */
@media ( max-width: 767px ) {

    /* Beide Grids: 1 Spalte */
    .bsort-category-grid,
    .bsort-product-grid {
        grid-template-columns: 1fr;
        gap: 14px;
        padding-top: 20px;
    }

    /* Kategorie-Karten: volle Breite */
    .bsort-category-card    { height: 200px; }
    .bsort-category-name    { font-size: 22px; }
    .bsort-category-count   { font-size: 12px; }

    /* Header */
    .bsort-products-header  { padding: 24px 0 18px; }
    .bsort-products-title   { font-size: 26px; }
    .bsort-products-count   { font-size: 14px; }

    /* Filter: "Filtern:"-Label ausblenden, Chips horizontal scrollbar */
    .bsort-filter-label { display: none; }
    .bsort-filter-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 20px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .bsort-filter-bar::-webkit-scrollbar { display: none; }
    .bsort-filter-chips                   { flex-wrap: nowrap; }

    .bsort-chip {
        padding: 7px 14px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* Produkt-Karte */
    .bsort-product-img     { height: 200px; }
    .bsort-product-content { padding: 14px 16px 16px; gap: 8px; }
    .bsort-product-title   { font-size: 17px; }
    .bsort-product-desc    { font-size: 13px; }
    .bsort-nutrition-row   { font-size: 13px; }
    .bsort-nutrition-btn   { font-size: 14px; }
}

/* ---- Kleines Smartphone (≤ 480 px): kompaktere Details ------ */
@media ( max-width: 480px ) {
    .bsort-category-card    { height: 180px; }
    .bsort-category-name    { font-size: 20px; }

    .bsort-products-title   { font-size: 22px; }

    .bsort-product-img      { height: 180px; }
    .bsort-product-content  { padding: 12px 14px 14px; gap: 7px; }
    .bsort-product-title    { font-size: 16px; }
    .bsort-product-desc     { font-size: 12px; }

    .bsort-nutrition-row    { font-size: 12px; padding: 6px 12px; }
    .bsort-nutrition-btn    { font-size: 13px; padding: 9px 12px; }
    .bsort-allergen-tag     { font-size: 11px; padding: 2px 8px; }
}

/* =============================================================
   Nährwert-Tabelle
   ============================================================= */

.bsort-product-footer {
    margin-top: auto;   /* Allergene + Button immer am unteren Kartenrand */
    display: flex;
    flex-direction: column;
}

.bsort-nutrition {
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Tabelle (standardmäßig verborgen, per JS eingeblendet) */
.bsort-nutrition-table {
    border: 1px solid var(--bsort-border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 12px;
}

.bsort-nutrition-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--bsort-border);
}

.bsort-nutrition-row:last-child {
    border-bottom: none;
}

.bsort-nutrition-row:nth-child(even) {
    background-color: #FAFAFA;
}

.bsort-nutrition-label {
    color: var(--bsort-text-secondary);
    font-weight: 400;
}

.bsort-nutrition-value {
    color: var(--bsort-text-primary);
    font-weight: 600;
    text-align: right;
}

/* Toggle-Button */
.bsort-nutrition-btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background-color: var(--bsort-accent);
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.15s;
}

.bsort-nutrition-btn:hover {
    background-color: var(--bsort-accent-dark);
}

/* =============================================================
   Allergene
   ============================================================= */

.bsort-allergens {
    padding-top: 10px;
    border-top: 1px solid var(--bsort-border);
}

.bsort-allergens-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bsort-text-muted);
    margin-bottom: 6px;
}

.bsort-allergens-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bsort-allergen-tag {
    display: inline-block;
    padding: 3px 10px;
    background-color: rgba(88, 135, 164, 0.12);
    color: #3A7A9C;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
