/* =========================================================================
   HEGA Portal – Kunden-Sidebar (Icon-Rail, klappt auf)
   Prototyp. Wird in _DevExtremeLayout.cshtml eingebunden.
   - Standard: schmale Icon-Leiste (RAIL_W). Hover/Expand -> volle Breite.
   - Hamburger (☰) "pinnt" die Sidebar offen (Push-Layout) – in localStorage.
   - Mobil (<768px): Off-Canvas-Drawer mit Backdrop.
   ========================================================================= */

:root {
    --hega-rail-w: 60px;   /* eingeklappte Breite (nur Icons) */
    --hega-side-w: 250px;  /* aufgeklappte Breite */
    --hega-top-h: 56px;    /* Höhe der Topbar */
    --hega-red: #dc3545;
}

/* ---- Topbar (schlank, sticky) --------------------------------------- */
.hega-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--hega-top-h);
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0;
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

/* Marke (Burger + Logo) – linke Zone, deckt sich mit der Sidebar-Breite */
.hega-brand { display: flex; align-items: center; gap: 10px; padding-left: 14px; flex-shrink: 0; }
.hega-topbar.hega-app .hega-brand { width: var(--hega-rail-w); min-width: var(--hega-rail-w); transition: width .18s ease; }
body.hega-pinned .hega-topbar.hega-app .hega-brand { width: var(--hega-side-w); min-width: var(--hega-side-w); }
/* Im schmalen Rail-Modus ist neben dem Burger kein Platz fuers Logo */
body:not(.hega-pinned) .hega-topbar.hega-app .hega-logo { display: none; }

/* Inhaltszone der Topbar: spiegelt den Seiten-Container -> rechte Gruppe buendig mit dem Inhalt */
.hega-topbar-content { flex: 1 1 auto; min-width: 0; display: flex; }
.hega-topbar-inner { display: flex; align-items: center; min-height: var(--hega-top-h); }

@media (max-width: 767.98px) {
    .hega-topbar.hega-app .hega-brand { width: auto; min-width: auto; }
    .hega-topbar.hega-app .hega-logo { display: inline !important; }
}

.hega-burger {
    background: none;
    border: none;
    font-size: 20px;
    color: #444;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    line-height: 1;
}
.hega-burger:hover { background: #f5f5f5; color: var(--hega-red); }

.hega-topbar .hega-logo { height: 28px; }

.hega-top-spacer { flex: 1 1 auto; }

/* Vertraute horizontale Schnellzugriffe in der Topbar */
.hega-topnav { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.hega-topnav-link {
    color: #444; text-decoration: none;
    font-weight: 600; font-size: 14px;
    padding: 8px 12px; border-radius: 8px; white-space: nowrap;
}
.hega-topnav-link:hover { background: #f5f5f5; color: var(--hega-red); text-decoration: none; }
.hega-topnav-link.active { color: var(--hega-red); }
/* Auf Tablet/Mobil ausblenden – dort fuehrt der Hamburger zur Sidebar */
@media (max-width: 991.98px) { .hega-topnav { display: none; } }

/* Suchfeld in der Topbar (Belegsuche)
   Breite: der Platzhalter muss ganz hineinpassen, sonst bricht er mitten im Wort ab
   ("Rechnung, Lieferschein, Ar"). Bei 340px blieben nach Lupe und Suchen-Knopf nur rund
   240px fuer den Text. 460px reichen auf dem Desktop; darunter darf das Feld schrumpfen,
   und der gekuerzte Platzhalter passt auch dann noch. Die vollstaendige Aufzaehlung der
   suchbaren Nummern steht im title-Attribut, nicht im Platzhalter. */
.hega-topsearch { max-width: 460px; flex: 0 1 460px; }
.hega-search-pre { background: #fff; border-right: 0; color: var(--hega-red); }
/* text-overflow als Auffangnetz: wird es doch zu eng, endet der Platzhalter mit
   Auslassungspunkten statt hart abgeschnitten zu werden. */
.hega-topsearch .form-control { border-left: 0; text-overflow: ellipsis; }
.hega-topsearch .form-control::placeholder { color: #9aa0a6; }
@media (max-width: 575.98px) { .hega-topsearch { display: none; } }

/* "Mein Konto" – Identität (Firma + Kd-Nr) dauerhaft sichtbar */
.hega-konto-toggle { display: inline-flex; align-items: center; gap: 9px; line-height: 1.15; padding: 4px 6px; }
.hega-konto-ico { font-size: 24px; color: #6c757d; }
.hega-konto-id { display: flex; flex-direction: column; text-align: left; }
.hega-konto-firma { font-weight: 700; font-size: 13px; color: #333; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hega-konto-kdnr { font-size: 11px; color: #888; }
.hega-konto-menu { min-width: 270px; padding-top: 6px; }
.hega-konto-card { padding: 6px 20px 8px; }
.hega-konto-card-firma { font-weight: 700; color: #333; font-size: 15px; }
.hega-konto-card-kdnr { font-size: 12.5px; color: var(--hega-red); font-weight: 700; margin: 2px 0 8px; }
.hega-konto-card-addr { font-size: 12.5px; color: #212529; line-height: 1.45; margin-bottom: 8px; }
.hega-konto-card-user { font-size: 12px; color: #212529; }
.hega-konto-card-user i { color: #6c757d; }
@media (max-width: 767.98px) { .hega-konto-id { display: none; } }

/* Warenkorb-Icon + Konto-Bereich in der Topbar */
.hega-top-actions { display: flex; align-items: center; gap: 6px; }
.hega-cart-btn {
    position: relative;
    background: none; border: none;
    font-size: 18px; color: #444; cursor: pointer;
    padding: 6px 10px; border-radius: 8px;
}
.hega-cart-btn:hover { background: #f5f5f5; color: var(--hega-red); }
.hega-cart-badge {
    position: absolute; top: 0; right: 0;
    font-size: .65rem; min-width: 18px;
}

/* ---- Sidebar -------------------------------------------------------- */
.hega-sidebar {
    position: fixed;
    top: var(--hega-top-h);
    left: 0;
    bottom: 0;
    width: var(--hega-rail-w);
    background: #fff;
    border-right: 1px solid #e9ecef;
    box-shadow: 2px 0 6px rgba(0,0,0,.04);
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 1020;
    transition: width .18s ease;
    padding: 8px 0 24px;
}
/* Aufklappen: per Hover (Overlay) ODER gepinnt (body.hega-pinned) */
.hega-sidebar:hover,
body.hega-pinned .hega-sidebar { width: var(--hega-side-w); }

.hega-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #343a40;
    padding: 16px 18px 6px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity .15s ease;
}
.hega-sec-title { display: inline-flex; align-items: center; }
.hega-sec-title::before {
    content: '';
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--hega-red);
    margin-right: 9px; flex-shrink: 0;
}

/* Einklappbare Gruppen */
.hega-group-toggle {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    text-align: left;
    text-transform: uppercase;
}
.hega-group-toggle:hover { background: #f8f8f8; }
.hega-group-toggle:hover .hega-sec-title { color: var(--hega-red); }
.hega-chevron {
    font-size: 11px;
    color: #adb5bd;
    opacity: 0;
    transition: transform .15s ease, opacity .15s ease;
}
.hega-sidebar:hover .hega-chevron,
body.hega-pinned .hega-sidebar .hega-chevron { opacity: 1; }
.hega-group.collapsed .hega-group-items { display: none; }
.hega-group.collapsed .hega-chevron { transform: rotate(-90deg); }

/* Klarer, beschrifteter Einklapp-Button am Fuss der Sidebar */
.hega-collapse-btn {
    display: flex; align-items: center; gap: 14px;
    width: 100%; background: none; border: none; cursor: pointer;
    padding: 12px 18px; margin-top: 8px;
    color: #495057; font-size: 13px; font-weight: 600;
    border-top: 1px solid #eee; white-space: nowrap;
}
.hega-collapse-btn:hover { background: #fff5f5; color: var(--hega-red); }
.hega-collapse-ico { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; transition: transform .18s ease; }
.hega-collapse-btn:hover .hega-collapse-ico { color: var(--hega-red); }
/* Im schmalen Rail-Modus zeigt das Icon nach rechts (= aufklappen) */
body:not(.hega-pinned) .hega-collapse-ico { transform: rotate(180deg); }
.hega-sidebar:hover .hega-section,
body.hega-pinned .hega-sidebar .hega-section { opacity: 1; }
/* erste Section ohne großen Abstand oben */
.hega-section:first-child { padding-top: 4px; }

.hega-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 11px 18px;
    color: #333;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    border-left: 3px solid transparent;
}
.hega-link i {
    font-size: 19px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    color: #6c757d;
}
.hega-link .hega-label {
    opacity: 0;
    transition: opacity .15s ease;
}
.hega-sidebar:hover .hega-label,
body.hega-pinned .hega-sidebar .hega-label { opacity: 1; }

.hega-link:hover {
    background: #fff5f5;
    color: var(--hega-red);
    text-decoration: none;
}
.hega-link:hover i { color: var(--hega-red); }

.hega-link.active {
    background: #fff5f5;
    color: var(--hega-red);
    border-left-color: var(--hega-red);
    font-weight: 700;
}
.hega-link.active i { color: var(--hega-red); }

/* Badge im Sidebar-Link (z.B. Warenkorb-Anzahl) */
.hega-link .hega-link-badge {
    margin-left: auto;
    font-size: .65rem;
    opacity: 0;
    transition: opacity .15s ease;
}
.hega-sidebar:hover .hega-link-badge,
body.hega-pinned .hega-sidebar .hega-link-badge { opacity: 1; }

/* Shop-Highlight-Link */
.hega-link.hega-shop-cta { color: var(--hega-red); font-weight: 700; }
.hega-link.hega-shop-cta i { color: var(--hega-red); }

/* ---- Content-Bereich ----------------------------------------------- */
.hega-content {
    margin-left: var(--hega-rail-w);
    transition: margin-left .18s ease;
}
body.hega-pinned .hega-content { margin-left: var(--hega-side-w); }

/* ---- Mobil: Off-Canvas --------------------------------------------- */
.hega-backdrop {
    display: none;
    position: fixed; inset: var(--hega-top-h) 0 0 0;
    background: rgba(0,0,0,.4);
    z-index: 1015;
}

@media (max-width: 767.98px) {
    .hega-sidebar {
        width: var(--hega-side-w);
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .hega-sidebar .hega-label,
    .hega-sidebar .hega-section,
    .hega-sidebar .hega-chevron,
    .hega-sidebar .hega-link-badge { opacity: 1; }
    body.hega-mobile-open .hega-sidebar { transform: translateX(0); }
    body.hega-mobile-open .hega-backdrop { display: block; }
    .hega-content, body.hega-pinned .hega-content { margin-left: 0; }
    .hega-help { opacity: 1; }
}

/* ---- Hilfe-/Support-Block am Fuss der Sidebar (nur aufgeklappt) ---- */
.hega-help { padding: 18px 12px 6px; opacity: 0; transition: opacity .15s ease; }
.hega-sidebar:hover .hega-help,
body.hega-pinned .hega-sidebar .hega-help { opacity: 1; }
.hega-help-card {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe9ea 100%);
    border: 1px solid #f6d6d9;
    border-radius: 12px;
    padding: 14px;
}
.hega-help-title { font-weight: 700; font-size: 14px; color: #b02a37; display: flex; align-items: center; gap: 8px; }
.hega-help-text { font-size: 12.5px; color: #6c5052; margin: 5px 0 11px; white-space: normal; line-height: 1.35; }
.hega-help-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--hega-red); color: #fff; font-weight: 700; font-size: 13.5px;
    padding: 10px 12px; border-radius: 9px; text-decoration: none;
}
.hega-help-btn:hover { background: #c82333; color: #fff; text-decoration: none; }
.hega-help-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 9px; font-size: 12.5px; color: #b02a37; font-weight: 600; text-decoration: none; }
.hega-help-link:hover { text-decoration: underline; color: #b02a37; }

/* ---- Freundlicher Leer-Zustand fuer Listen (_EmptyState.cshtml) ---- */
.hega-empty {
    text-align: center;
    padding: 48px 24px;
    background: #fff;
    border: 1px dashed #e3c6c9;
    border-radius: 12px;
    margin: 8px 0 12px;
}
.hega-empty-ico {
    width: 72px; height: 72px; margin: 0 auto 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff5f5 0%, #ffe3e3 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; color: var(--hega-red);
}
.hega-empty-title { font-size: 19px; font-weight: 700; color: #333; margin: 0 0 6px; }
.hega-empty-text { font-size: 14.5px; color: #6c757d; max-width: 460px; margin: 0 auto 18px; line-height: 1.5; }
.hega-empty-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.hega-empty-cta {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--hega-red); color: #fff; font-weight: 700; font-size: 14px;
    padding: 10px 18px; border-radius: 9px; text-decoration: none;
}
.hega-empty-cta:hover { background: #c82333; color: #fff; text-decoration: none; }
.hega-empty-reset {
    display: inline-flex; align-items: center; gap: 8px;
    background: #fff; color: #555; border: 1px solid #ddd; font-weight: 600; font-size: 14px;
    padding: 10px 16px; border-radius: 9px; text-decoration: none;
}
.hega-empty-reset:hover { border-color: var(--hega-red); color: var(--hega-red); text-decoration: none; }
