/* ═══════════════════════════════════════════════════════════════════════════
   NH-Stoffe B2B-Katalog – Stylesheet
   Palette: Warmes Weiß / Terrakotta-Akzent / Sanfte Schatten
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Custom Properties ───────────────────────────────────────────────────── */
:root {
    --accent:          #78B2B2;
    --accent-hover:    #679f9f;
    --accent-light:    #e8f3f3;
    --accent-text:     #3d7f7f;

    --bg:              #f8f8f8;
    --surface:         #ffffff;
    --border:          #e8e5e0;
    --border-subtle:   #f1eeea;

    --text:            #262626;
    --text-muted:      #737373;
    --text-light:      #a1a1a1;

    --success:         #4caf7d;
    --success-bg:      #e8f5ee;

    --shadow-sm:       0 1px 3px rgba(44, 41, 38, .08);
    --shadow-md:       0 4px 16px rgba(44, 41, 38, .10);
    --shadow-lg:       0 8px 32px rgba(44, 41, 38, .14);

    --radius-sm:       6px;
    --radius-md:       12px;
    --radius-lg:       18px;
    --radius-xl:       24px;

    --header-height:   72px;
    --toolbar-height:  auto;
    --sidebar-width:   350px;

    --transition:      0.18s ease;
    --font:            'DM Sans', 'Segoe UI', sans-serif;
}

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

/* Das HTML-Attribut "hidden" muss immer Vorrang haben (State-Toggling per JS). */
[hidden] { display: none !important; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
}

img { display: block; max-width: 100%; }

button { font-family: inherit; cursor: pointer; }

ul { list-style: none; }

a { color: var(--accent); }

/* ── Container ───────────────────────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
    background: linear-gradient(180deg, #ffffff 0%, #fcfbfa 100%);
    border-bottom: 1px solid var(--border);
    padding: 16px 0 14px;
}

.site-header-grid {
    display: grid;
    grid-template-columns: minmax(210px, 280px) minmax(0, 1fr);
    align-items: center;
    gap: 30px;
}

.site-logo-link {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.site-logo {
    width: clamp(170px, 16vw, 240px);
    height: auto;
    display: block;
}

.site-copy {
    min-width: 0;
    max-width: 900px;
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 12px 16px;
}

.site-title {
    font-size: clamp(2rem, 3.1vw, 3rem);
    font-weight: 400;
    color: rgb(57, 62, 65);
    letter-spacing: -.015em;
    line-height: 1.12;
    margin-top: 0;
}

.site-intro {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 860px;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 0;
    box-shadow: var(--shadow-sm);
}

/* Suchfeld */
.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 480px;
    margin-bottom: 10px;
}

.search-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 10px 36px 10px 40px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: .95rem;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    appearance: none;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: var(--surface);
}

.search-input::placeholder { color: var(--text-light); }

/* WebKit: Standard-Suchfeld-"×" ausblenden, eigenes nutzen */
.search-input::-webkit-search-cancel-button { display: none; }

.search-clear {
    position: absolute;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}
.search-clear:hover { color: var(--text); background: var(--bg); }
.search-clear svg { width: 14px; height: 14px; }

/* Tag-Filter */
.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-btn {
    padding: 5px 12px;
    font-size: .84rem;
    font-weight: 500;
    font-family: var(--font);
    background: #fafafa;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

.tag-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.tag-btn.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.tag-btn.is-all {
    border-color: var(--border);
    font-weight: 600;
}

/* ── App-Layout ──────────────────────────────────────────────────────────── */
.app-layout {
    padding: 24px 0 80px;
}

.layout-grid {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-width);
    gap: 24px;
    align-items: start;
}

/* ── Katalog (linke Spalte) ──────────────────────────────────────────────── */
.catalog {
    min-width: 0; /* Verhindert Overflow im Grid */
}

.catalog-meta {
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    min-height: 1.4em;
}

/* ── States: Loading / Error / Empty ─────────────────────────────────────── */
.state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.state--loading { gap: 16px; }

.state-icon {
    font-size: 2rem;
    line-height: 1;
}

/* Spinner */
.spinner {
    width: 44px;
    height: 44px;
    border: 3.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}

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

/* ── Produktgrid ─────────────────────────────────────────────────────────── */
.product-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

/* Produktkarte */
.product-card {
    background: var(--surface);
    border: 1.5px solid var(--border-subtle);
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
    user-select: none;
    position: relative;
}

.product-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border);
    transform: translateY(-2px);
}

.product-card.is-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light), var(--shadow-md);
}

/* Bild-Bereich */
.card-img-wrap {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--bg);
    overflow: hidden;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease;
}

.product-card:hover .card-img {
    transform: scale(1.04);
}

.card-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 2.5rem;
}

/* Checkbox-Label über dem Bild */
.card-check-label {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.card-check-label:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.card-check-input {
    /* Checkbox visuell versteckt, Klick auf Label */
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Haken-Symbol, wenn ausgewählt */
.card-check-label::after {
    content: '';
    display: block;
    width: 10px;
    height: 6px;
    border-left: 2px solid transparent;
    border-bottom: 2px solid transparent;
    transform: rotate(-45deg) translate(1px, -1px);
    transition: border-color var(--transition);
}

.product-card.is-selected .card-check-label {
    background: var(--accent);
    border-color: var(--accent);
}

.product-card.is-selected .card-check-label::after {
    border-left-color: #fff;
    border-bottom-color: #fff;
}

/* Karten-Body */
.card-body {
    padding: 12px 14px 14px;
}

.card-sku {
    font-size: .75rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.card-title {
    font-size: .94rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
    margin-bottom: 10px;
    /* Zwei Zeilen max, Rest mit … */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Mengenfeld (erscheint, wenn Karte ausgewählt) */
.card-qty {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.card-qty-label {
    font-size: .8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.card-qty-input {
    width: 64px;
    padding: 5px 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color var(--transition);
    text-align: center;
    appearance: textfield;
    -moz-appearance: textfield;
}

.card-qty-input::-webkit-inner-spin-button,
.card-qty-input::-webkit-outer-spin-button { appearance: none; }

.card-qty-input:focus {
    border-color: var(--accent);
    background: var(--surface);
}

/* Verstecken & Anzeigen des Mengenfelds */
.card-qty { display: none; }
.product-card.is-selected .card-qty { display: flex; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
    position: sticky;
    top: calc(var(--toolbar-height, 0px) + 12px);
    background: var(--surface);
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.sidebar-badge {
    background: var(--accent);
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
    min-width: 28px;
    text-align: center;
    line-height: 1.7;
    transition: background var(--transition);
}

.sidebar-badge[data-count="0"] {
    background: var(--border);
    color: var(--text-muted);
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    scroll-behavior: smooth;
}

.sidebar-empty {
    font-size: .875rem;
    color: var(--text-muted);
    text-align: center;
    padding: 24px 0;
    line-height: 1.6;
}

.sidebar-footer {
    padding: 14px 16px 16px;
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Auswahl-Liste (Sidebar + Drawer) ────────────────────────────────────── */
.selection-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.selection-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 10px 10px 12px;
    background: var(--bg);
    border-radius: var(--radius-md);
    font-size: .83rem;
    line-height: 1.4;
}

.selection-item-thumb {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    overflow: hidden;
    background: #efefef;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
}

.selection-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.selection-item-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 1.1rem;
}

.selection-item-info {
    flex: 1;
    min-width: 0;
}

.selection-item-sku {
    font-weight: 700;
    color: var(--accent);
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.selection-item-title {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selection-item-qty {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-top: 4px;
}

.selection-item-qty-label {
    font-size: .75rem;
    color: var(--text-muted);
}

.selection-item-qty-input {
    width: 52px;
    padding: 3px 6px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .83rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    outline: none;
    text-align: center;
    appearance: textfield;
    -moz-appearance: textfield;
    transition: border-color var(--transition);
}

.selection-item-qty-input::-webkit-inner-spin-button,
.selection-item-qty-input::-webkit-outer-spin-button { appearance: none; }

.selection-item-qty-input:focus {
    border-color: var(--accent);
}

.selection-item-remove {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-light);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    transition: color var(--transition), background var(--transition);
    margin-top: 2px;
}

.selection-item-remove:hover {
    color: var(--accent);
    background: var(--accent-light);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: .9rem;
    font-weight: 600;
    font-family: var(--font);
    border: 1.5px solid transparent;
    transition: all var(--transition);
    cursor: pointer;
    line-height: 1.3;
    text-decoration: none;
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn--primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn--primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 2px 8px rgba(200, 125, 107, .35);
}

.btn--secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn--secondary:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
    font-weight: 500;
    font-size: .85rem;
}

.btn--ghost:hover:not(:disabled) {
    color: var(--text);
    background: var(--bg);
}

.btn--full { width: 100%; }

/* ── Erfolgs-Meldung (Kopieren) ──────────────────────────────────────────── */
.copy-success {
    text-align: center;
    font-size: .85rem;
    font-weight: 600;
    color: var(--success);
    background: var(--success-bg);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    animation: fadeIn .2s ease;
}

.selection-preview {
    position: fixed;
    z-index: 999;
    width: 270px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    pointer-events: none;
}

.selection-preview-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
}

.selection-preview-caption {
    font-size: .86rem;
    color: var(--text);
    padding: 10px 12px;
    line-height: 1.35;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Mobile: Sticky Bar ──────────────────────────────────────────────────── */
.mobile-bar {
    display: none; /* Desktop: unsichtbar (JS steuert display für Mobile) */
}

/* ── Mobile: Drawer ──────────────────────────────────────────────────────── */
.mobile-drawer { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive – Tablet ≤ 960px
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 960px) {
    :root { --sidebar-width: 280px; }

    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1260px) {
    :root { --sidebar-width: 320px; }

    .product-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive – Mobile ≤ 720px
   (Sidebar fällt weg, durch Sticky-Bar + Drawer ersetzt)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {

    .site-header-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        align-items: start;
    }

    .site-copy {
        border-radius: 12px;
        padding: 10px 12px;
    }

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

    /* Desktop-Sidebar auf Mobile ausblenden */
    .sidebar { display: none; }

    /* Sticky Bar */
    .mobile-bar {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 200;
        padding: 0 0 env(safe-area-inset-bottom);
    }

    .mobile-bar-btn {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 16px 20px;
        background: var(--accent);
        color: #fff;
        border: none;
        font-size: .95rem;
        font-weight: 600;
        font-family: var(--font);
        cursor: pointer;
    }

    .mobile-bar-cta {
        margin-left: auto;
        font-size: .85rem;
        opacity: .85;
    }

    /* Drawer */
    .mobile-drawer {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 300;
    }

    .mobile-drawer-overlay {
        position: absolute;
        inset: 0;
        background: rgba(44, 41, 38, .5);
        backdrop-filter: blur(2px);
    }

    .mobile-drawer-panel {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--surface);
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 75vh;
        display: flex;
        flex-direction: column;
        animation: slideUp .25s ease;
        padding-bottom: env(safe-area-inset-bottom);
    }

    @keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }

    .mobile-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px 12px;
        border-bottom: 1px solid var(--border-subtle);
    }

    .mobile-drawer-header h2 {
        font-size: 1rem;
        font-weight: 700;
    }

    .mobile-drawer-close {
        background: var(--bg);
        border: none;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        font-size: 1.3rem;
        line-height: 1;
        color: var(--text-muted);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .mobile-drawer-panel .selection-list {
        flex: 1;
        overflow-y: auto;
        padding: 12px 16px;
    }

    .mobile-drawer-footer {
        padding: 12px 16px 14px;
        border-top: 1px solid var(--border-subtle);
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .app-layout { padding-bottom: 80px; }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive – Kleines Mobil ≤ 400px
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}
