/* ===========================
   Muutujad
=========================== */
:root {
    --sidebar-w: 340px;
    --sidebar-bg: #1a2535;
    --sidebar-active: rgba(255,255,255,.15);
    --sidebar-text: #b8cfe0;
    --sidebar-section: #5a7a92;
    --accent: #f05a00;
    --accent-hover: #d14f00;
    --btn-dark: #1a2535;
}

/* ===========================
   Alus
=========================== */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: #e8ecf0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

/* ===========================
   Paigutus
=========================== */
.store-layout {
    display: flex;
    min-height: 100vh;
}

/* Külgpaneel — Bootstrap offcanvas-lg override */
.store-sidebar,
.store-sidebar.offcanvas-lg,
.store-sidebar.offcanvas {
    --bs-offcanvas-bg: #1a2535;
    --bs-offcanvas-color: #d0dde8;
    width: var(--sidebar-w) !important;
    background-color: #1a2535 !important;
    color: #d0dde8;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.2) transparent;
}

/* Mobiil (<992px): Bootstrap offcanvas (position:fixed, ei võta flex-ruumi) */
@media (max-width: 991.98px) {
    .store-sidebar {
        z-index: 1045;
    }
    /* Kui sidebar on mobiilil peidetud, ära lase tal flex-ruumi võtta */
    .store-layout {
        display: block;
    }
}

/* Lauaarvuti (≥992px): kleepuv külgpaneel flex-paigutuses */
@media (min-width: 992px) {
    .store-layout {
        display: flex;
    }
    .store-sidebar.offcanvas-lg {
        flex-shrink: 0;
        position: sticky !important;
        top: 0;
        height: 100vh;
        transform: none !important;
        visibility: visible !important;
        z-index: 100;
    }
}
.sidebar-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* !important vajab: Bootstrap offcanvas-lg seab lg+ puhul .offcanvas-body { padding:0 } */
    padding: 1.25rem 1.5rem !important;
}

/* Bränd — keskel */
.sidebar-brand {
    padding-bottom: .85rem;
    border-bottom: 1px solid rgba(255,255,255,.12);
    text-align: center;
}
.brand-name { color: #d0dde8; font-size: .82rem; font-weight: 600; }

/* Logo — valge ümaram kast, sobib tumedale taustale */
.sidebar-logo-wrap { display: inline-block; text-decoration: none; }
.sidebar-logo {
    display: block;
    max-height: 48px;
    max-width: 160px;
    object-fit: contain;
    background: #fff;
    border-radius: .4rem;
    padding: 4px 10px;
    margin: 0 auto;
}
.mobile-logo {
    max-height: 30px;
    object-fit: contain;
    background: rgba(255,255,255,.92);
    border-radius: .3rem;
    padding: 2px 6px;
    display: block;
}

/* Navigatsioonilingid */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    border-radius: .4rem;
    color: #d0dde8;
    text-decoration: none;
    font-size: .9rem;
    transition: background .15s, color .15s;
    margin-bottom: .15rem;
}
.sidebar-link:hover { background: rgba(255,255,255,.1); color: #ffffff; }
.sidebar-link.active {
    background: rgba(240, 90, 0, .22);
    color: #ffffff;
    font-weight: 700;
}
.sidebar-link.active::before {
    content: '';
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #f05a00;
    flex-shrink: 0;
}

/* Otsing */
.search-input {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    color: #fff;
    border-radius: .4rem 0 0 .4rem;
}
.search-input::placeholder { color: rgba(255,255,255,.45); }
.search-input:focus { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.3); color: #fff; box-shadow: none; }
.btn-search {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.15);
    border-left: none;
    color: var(--sidebar-text);
    border-radius: 0 .4rem .4rem 0;
}
.btn-search:hover { background: rgba(255,255,255,.2); color: #fff; }

/* Sektsiooni pealkiri */
.sidebar-section { }
.sidebar-section-title {
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .1em;
    color: #6a9ab8;
    padding: .2rem .75rem;
    margin-bottom: .3rem;
    text-transform: uppercase;
}

/* Tootjate kokkupandav sektsioon */
.sidebar-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .1em;
    color: #6a9ab8;
    padding: .2rem .75rem;
    margin-bottom: .3rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: color .15s;
}
.sidebar-section-toggle:hover { color: #9bbfd4; }
.sidebar-section-toggle.active-mfr { color: var(--accent); }
.sidebar-toggle-icon {
    font-size: .75rem;
    transition: transform .2s;
}
.sidebar-section-toggle:not(.collapsed) .sidebar-toggle-icon {
    transform: rotate(180deg);
}
.sidebar-link-sub {
    padding-left: 1.5rem;
    font-size: .85rem;
}

/* ── Kahetasandiline kategooriapuu ────────────────────────────── */
.cat-tree-item {
    display: flex;
    align-items: center;
    margin-bottom: .15rem;
}
/* Peakategooria link võtab järelejäänud ruumi */
.cat-tree-item .sidebar-link {
    flex: 1;
    margin-bottom: 0;
}
/* Peakategooria, kelle lapskategooria on aktiivne */
.sidebar-link.cat-parent-has-active {
    color: #ffffff;
    background: rgba(255,255,255,.07);
}
.sidebar-link.cat-parent-has-active::before {
    content: '';
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: rgba(240, 90, 0, .55);
    flex-shrink: 0;
}
/* Chevron-nupp peakategooria kõrval */
.cat-toggle-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    padding: .4rem .45rem;
    cursor: pointer;
    border-radius: .3rem;
    flex-shrink: 0;
    line-height: 1;
    transition: background .15s, color .15s;
}
.cat-toggle-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.cat-toggle-icon {
    display: block;
    font-size: .72rem;
    transition: transform .2s ease;
}
.cat-toggle-btn[aria-expanded="true"] .cat-toggle-icon {
    transform: rotate(180deg);
}

/* Ostukorvi nupp külgpaneelil */
.sidebar-cart-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.2);
    color: #ffffff;
    padding: .6rem .85rem;
    border-radius: .4rem;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.sidebar-cart-btn:hover { background: rgba(255,255,255,.22); }

/* Keel */
.sidebar-lang { display: flex; align-items: center; gap: .5rem; padding: .3rem .75rem; }
.lang-btn { color: #8ab4cc; text-decoration: none; font-size: .85rem; font-weight: 600; }
.lang-btn:hover { color: #fff; }
.lang-btn.active { color: #fff; font-weight: 800; }
.lang-sep { color: #3d5a70; }

/* Badge */
.cart-count.badge { background: var(--accent) !important; font-size: .65rem; }

/* ===========================
   Peamine sisu
=========================== */
.store-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.store-content { flex: 1; padding: 1.5rem; max-width: 1100px; }

/* ===========================
   Toodikaardid
=========================== */

/* Kaart täidab kogu veeru kõrguse (reas ühtlane) */
#productsRow .col { display: flex; }

.product-card {
    background: #fff;
    border: none;
    border-radius: .6rem;
    overflow: hidden;
    transition: transform .15s, box-shadow .15s;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    width: 100%;
}
.product-card:hover { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0,0,0,.14); }

.product-card-img-wrap { display: block; flex-shrink: 0; }
.product-card-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    display: block;
    background: #f5f7fa;
    padding: .5rem;
}
.product-card-body {
    padding: .85rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.product-card-info { flex: 1; }
.product-card-name {
    font-size: .9rem;
    font-weight: 600;
    color: #2c3e50;
    text-decoration: none;
    line-height: 1.3;
    margin-bottom: .4rem;
    display: block;
}
.product-card-name:hover { color: var(--accent); }
.product-card-manufacturer {
    font-size: .7rem;
    background: #e8f3eb;
    color: #2e7d48;
    border: 1px solid #b2d8bc;
    border-radius: 3px;
    padding: .15rem .4rem;
    display: inline-block;
    margin-bottom: .3rem;
    font-weight: 500;
    text-decoration: none;
}
.product-card-manufacturer:hover { background: #d4ecda; color: #1e5c34; }

.badge-manufacturer:hover { background: #d4ecda; color: #1e5c34; }

.product-price { font-size: 1.25rem; font-weight: 800; color: var(--accent); line-height: 1.2; }
.product-vat { font-size: .65rem; font-weight: 400; display: block; color: #9aafbe; letter-spacing: .01em; }
.product-stock { font-size: .78rem; color: #6c8c9f; margin-top: .15rem; }
.product-stock.out { color: #c0392b; font-weight: 600; }
.badge-manufacturer {
    font-size: .8rem;
    background: #e8f3eb;
    color: #2e7d48;
    border: 1px solid #b2d8bc;
    border-radius: 4px;
    padding: .25rem .6rem;
    display: inline-block;
    font-weight: 500;
    text-decoration: none;
}

.badge-service-tag {
    font-size: .7rem;
    background: #e8f4f8;
    color: #2980b9;
    border-radius: 3px;
    padding: .15rem .4rem;
    display: inline-block;
    margin-bottom: .3rem;
}

.btn-add-cart {
    background: var(--btn-dark);
    color: #fff;
    border: none;
    border-radius: .35rem;
    padding: .5rem .75rem;
    font-size: .85rem;
    font-weight: 600;
    width: 100%;
    margin-top: .75rem;
    cursor: pointer;
    transition: background .15s;
    letter-spacing: .01em;
    flex-shrink: 0;
}
.btn-add-cart:hover { background: #2c3e52; }
.btn-add-cart:disabled { background: #bcc5ce; cursor: default; }
.btn-info-url {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: .35rem;
    border: 1px solid #cdd4da;
    color: #6c757d;
    text-decoration: none;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.btn-info-url:hover { background: #f0f3f5; color: #343a40; }

/* ===========================
   List vaade
=========================== */
#productsWrapper[data-view="list"] #productsRow {
    display: flex !important;
    flex-direction: column;
    gap: .5rem;
}
#productsWrapper[data-view="list"] #productsRow .col {
    width: 100% !important;
    max-width: 100% !important;
    flex: none;
}
#productsWrapper[data-view="list"] .product-card {
    flex-direction: row;
    align-items: stretch;
    border-radius: .5rem;
}
#productsWrapper[data-view="list"] .product-card:hover { transform: none; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
#productsWrapper[data-view="list"] .product-card-img-wrap {
    width: 100px;
    flex-shrink: 0;
}
#productsWrapper[data-view="list"] .product-card-img {
    width: 100px;
    height: 100px;
    aspect-ratio: unset;
    object-fit: contain;
    padding: .375rem;
}
#productsWrapper[data-view="list"] .product-card-body {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1rem;
}
#productsWrapper[data-view="list"] .product-card-info { flex: 1; }
#productsWrapper[data-view="list"] .btn-add-cart {
    width: auto;
    white-space: nowrap;
    margin-top: 0;
    padding: .45rem 1rem;
}

/* ===========================
   Toote detailleht
=========================== */
.product-main-img {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: .6rem;
    background: #fff;
    padding: 1rem;
    border: 1px solid #e2e8ef;
}
.product-price-lg { font-size: 2rem; font-weight: 700; color: var(--accent); }
.qty-input { width: 60px; text-align: center; }
.btn-add-to-cart-lg {
    background: var(--btn-dark);
    color: #fff;
    border: none;
    border-radius: .4rem;
    padding: .65rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background .15s;
}
.btn-add-to-cart-lg:hover { background: #506070; }

/* ===========================
   Ostukorvi offcanvas
=========================== */
.cart-offcanvas { width: 340px; }
.cart-offcanvas-header {
    background: var(--sidebar-bg);
    color: #fff;
}
.cart-offcanvas-header .offcanvas-title { color: #fff; font-size: 1rem; }

.cart-widget-item {
    display: flex;
    gap: .75rem;
    align-items: center;
    padding: .75rem 1rem;
    border-bottom: 1px solid #eef0f3;
}
.cart-widget-img {
    width: 52px; height: 52px;
    object-fit: cover;
    border-radius: .35rem;
    flex-shrink: 0;
    background: #f5f7fa;
}
.cart-widget-name { font-size: .85rem; font-weight: 600; color: #2c3e50; }
.cart-widget-qty { font-size: .78rem; color: #6c8c9f; }
.cart-widget-price { font-size: .9rem; font-weight: 700; color: var(--accent); margin-left: auto; flex-shrink: 0; }
.cart-widget-footer {
    padding: 1rem;
    border-top: 2px solid #eef0f3;
}
.cart-widget-total { font-size: 1rem; font-weight: 700; color: var(--accent); }
.btn-checkout {
    display: block;
    width: 100%;
    background: var(--btn-dark);
    color: #fff;
    text-align: center;
    padding: .65rem;
    border-radius: .4rem;
    text-decoration: none;
    font-weight: 600;
    margin-top: .75rem;
    transition: background .15s;
}
.btn-checkout:hover { background: #506070; color: #fff; }

/* ===========================
   Ostukorvi leht
=========================== */
.cart-item-img {
    width: 60px; height: 60px;
    object-fit: cover;
    border-radius: .35rem;
    background: #f5f7fa;
}

/* ===========================
   Kassa
=========================== */
.order-summary { position: sticky; top: 1.5rem; }

/* ===========================
   Tühi olek
=========================== */
.empty-state { padding: 3rem 0; text-align: center; color: #6c8c9f; }
.empty-state i { font-size: 3rem; display: block; margin-bottom: 1rem; color: #aec3d0; }

/* Ostutingimuste sisu */
.terms-content { line-height: 1.7; color: #2c3e50; }
.terms-content h2, .terms-content h3 { margin-top: 1.5rem; margin-bottom: .5rem; }
.terms-content ul, .terms-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.terms-content p { margin-bottom: .75rem; }

/* ===========================
   Mobiili ülariba
=========================== */
.mobile-header {
    background: #1a2535;
    color: #fff;
    height: 54px;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.mobile-brand { color: #fff; text-decoration: none; font-weight: 700; }
.btn-icon { background: none; border: none; color: #fff; padding: .35rem .5rem; cursor: pointer; position: relative; }

/* ===========================
   Breadcrumb
=========================== */
.breadcrumb { background: none; padding: 0; margin-bottom: 1.25rem; }
.breadcrumb-item a { color: #6c8c9f; text-decoration: none; font-size: .85rem; }
.breadcrumb-item.active { font-size: .85rem; color: #2c3e50; }
.breadcrumb-item + .breadcrumb-item::before { color: #aaa; }

/* ===========================
   Mobiili parandused
=========================== */
@media (max-width: 991.98px) {
    /* Vähem padding sisul */
    .store-content { padding: .85rem .75rem; }

    /* Toodikaartide ruudustik: 2 veergu, väiksem vahe */
    #productsRow { --bs-gutter-x: .5rem; --bs-gutter-y: .5rem; }
    .product-card-body { padding: .6rem; }
    .product-card-name { font-size: .82rem; }
    .product-price { font-size: 1.05rem; }
    .btn-add-cart { padding: .4rem .5rem; font-size: .78rem; }

    /* Toolbar tihedam */
    .d-flex.gap-2.mb-3 { margin-bottom: .6rem !important; }

    /* Ostukorv — kogu laius */
    .cart-offcanvas { width: 100vw; }

    /* Checkout — kokkuvõte mitte sticky mobiilil */
    .order-summary { position: static; }
}

/* Kategooria toodete arv sidebar-is */
.cat-count {
    font-size: .72rem;
    color: #9ca3af;
    margin-left: .2rem;
    font-weight: 400;
}
.sidebar-link.active .cat-count,
.sidebar-link.cat-parent-has-active .cat-count {
    color: rgba(255,255,255,.55);
}
