/**
 * App Custom Styles
 * 
 * Sdílené CSS styly pro celou aplikaci.
 * Tento soubor obsahuje drobné custom styly, které nejsou součástí Bootstrap.
 */

/* ==================================================
 * 0. Main Background
 * ================================================== */

/**
 * Dekorační pozadí aplikace s obrázkem.
 * Obrázek je jako cover, horizontálně vycentrovaný, vertikálně nahoře.
 * Zesvětleno pomocí poloprůhledného bílého overlay.
 */

main {
    position: relative;
    min-height: calc(100vh - 56px);
    /* Výška minus navbar */
}

main::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('/img/bg.webp');
    background-size: cover;
    background-position: 42% top;
    background-repeat: no-repeat;
    background-attachment: fixed;
    z-index: -2;
}

/* Když je viditelný navbar, posunout pozadí o jeho výšku */
.has-navbar main::before {
    background-position: 42% 56px;
}

main::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    z-index: -1;
}

/* ==================================================
 * 1. Flash Messages Animations
 * ================================================== */

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.flash-message.fade-out {
    animation: slideOutRight 0.3s ease-in forwards;
}


/* ==================================================
 * 2. Form Controls
 * ================================================== */

.form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}


/* ==================================================
 * 3. User Management
 * ================================================== */

.user-email-link {
    text-decoration: none;
    transition: color 0.2s;
}

.user-email-link:hover {
    text-decoration: underline;
    color: var(--bs-primary) !important;
}


/* ==================================================
 * 4. Category Tree
 * ================================================== */

.category-item {
    position: relative;
}

.category-item:before {
    content: '';
    position: absolute;
    left: -12px;
    top: 0;
    bottom: 0;
    border-left: 1px dashed #dee2e6;
}

.category-item:first-child:before {
    top: 50%;
}

.category-item:last-child:before {
    height: 50%;
}

.category-item:after {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    width: 12px;
    border-bottom: 1px dashed #dee2e6;
}

/* Pro hlavní úroveň (level 0) skrýt čáry */
.category-tree>.category-item:before,
.category-tree>.category-item:after {
    display: none;
}


/* ==================================================
 * 5. Purchase Shop - Tiles & Modal
 * ================================================== */

/* Hover efekty pro dlaždice */
.category-tile:hover,
.product-tile:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Numpad tlačítka pro dotyk */
.numpad-btn {
    min-height: 50px;
    font-weight: 500;
}

.numpad-btn:active {
    transform: scale(0.95);
}

/* Quantity modal - responsivní layout */
.quantity-modal-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quantity-modal-info {
    flex: 1;
}

.quantity-modal-numpad {
    display: flex;
    justify-content: center;
}

/* CSS Grid pro numpad */
.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-width: 200px;
    width: 100%;
}

.numpad-grid .numpad-btn {
    width: 100%;
    padding: 0.75rem 0;
    font-size: 1.25rem;
}

/* Clear button - stejný styl jako numpad-btn */
.numpad-grid .numpad-clear-btn {
    width: 100%;
    padding: 0.75rem 0;
    font-size: 1.25rem;
}

/* Unit selection buttons */
.unit-buttons-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.unit-select-btn {
    padding: 0.5rem 1rem;
    font-weight: 500;
    min-width: 60px;
    transition: all 0.15s ease-in-out;
}

.unit-select-btn:active {
    transform: scale(0.95);
}

/* Na široké obrazovce - dvousloupcový layout 50/50 */
@media (min-width: 576px) {
    .quantity-modal-layout {
        flex-direction: row;
        align-items: stretch;
        gap: 1.5rem;
    }

    .quantity-modal-info {
        flex: 1 1 50%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .quantity-modal-numpad {
        flex: 1 1 50%;
        border-left: 1px solid #dee2e6;
        padding-left: 1.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .numpad-grid {
        max-width: 100%;
        width: 100%;
    }

    .numpad-grid .numpad-btn,
    .numpad-grid .numpad-clear-btn {
        padding: 0.875rem 0;
        font-size: 1.35rem;
        min-height: 56px;
    }
}

/* Breadcrumb styl */
#categoryBreadcrumb .breadcrumb {
    background-color: #f8f9fa;
}

#categoryBreadcrumb a {
    color: var(--bs-primary);
}


/* ==================================================
 * 6. Tom Select - Searchable Dropdowns
 * ================================================== */

/* Zajistit správnou šířku v modálech */
.modal .ts-wrapper {
    width: 100%;
}

/* Lepší zobrazení položek hierarchie kategorií */
.ts-dropdown .option {
    padding: 8px 12px;
    white-space: normal;
    line-height: 1.4;
}

/* Zvýraznění vybraného stylu */
.ts-control {
    border-color: #dee2e6;
}

.ts-control:focus-within,
.ts-wrapper.focus .ts-control {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Lepší styl pro placeholder */
.ts-control input::placeholder {
    color: #6c757d;
}

/* Zajistit, že dropdown není oříznutý v modálech */
.modal-body .ts-wrapper {
    position: relative;
}

.modal-body .ts-dropdown {
    position: absolute;
    z-index: 9999;
}

/* Styl pro "Nic nenalezeno" */
.ts-dropdown .no-results {
    padding: 10px 12px;
    color: #6c757d;
    font-style: italic;
}


/* ==================================================
 * 7. Page Header - Responsive Title & Actions
 * ================================================== */

/**
 * Responzivní page header s nadpisem a akčními tlačítky.
 * Na větších obrazovkách: nadpis vlevo, tlačítka vpravo.
 * Na mobilech: tlačítka pod nadpisem.
 */

.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-header-title h1 {
    margin-bottom: 0;
    font-size: 1.5rem;
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* Na mobilech - tlačítka pod nadpisem, plná šířka */
@media (max-width: 767.98px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header-title {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .page-header-title h1 {
        font-size: 1.25rem;
    }

    .page-header-actions {
        justify-content: flex-start;
        width: 100%;
    }

    /* Menší tlačítka na mobilech */
    .page-header-actions .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* Na velmi malých mobilech - skrýt text tlačítek, jen ikony */
@media (max-width: 480px) {
    .page-header-actions .btn-text {
        display: none;
    }

    .page-header-actions .btn {
        padding: 0.5rem 0.625rem;
    }
}


/* ==================================================
 * 8. Category Tree Picker (pro formuláře)
 * ================================================== */

/**
 * Interaktivní strom kategorií pro výběr ve formulářích.
 * Podporuje rozbalování/sbalování a vizuální hierarchii.
 */

.category-tree-picker {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: #fff;
    max-height: 280px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.category-tree-picker:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Položka "Nezařazeno" */
.category-tree-picker__none {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #eee;
    margin-bottom: 0.25rem;
}

.category-tree-picker__none-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.375rem 0.75rem;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    border-radius: 0.25rem;
    color: #6c757d;
    font-style: italic;
    transition: background-color 0.15s, color 0.15s;
}

.category-tree-picker__none-btn:hover {
    background: #f8f9fa;
    color: #495057;
}

.category-tree-picker__none-btn.active {
    background: #e8f0fe;
    color: #0d6efd;
    font-style: normal;
    font-weight: 500;
}

/* Kontejner stromu */
.category-tree-picker__tree {
    padding: 0 0.5rem;
}

/* Úroveň stromu */
.category-tree-picker__level {
    list-style: none;
    margin: 0;
    padding: 0;
}

.category-tree-picker__level--nested {
    padding-left: 1.25rem;
    border-left: 1px dashed #dee2e6;
    margin-left: 0.5rem;
    display: none;
}

.category-tree-picker__level--nested.open {
    display: block;
}

/* Položka kategorie */
.category-tree-picker__item {
    position: relative;
}

/* Řádek kategorie */
.category-tree-picker__row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0;
}

/* Tlačítko rozbalení/sbalení */
.category-tree-picker__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #6c757d;
    border-radius: 0.25rem;
    transition: background-color 0.15s, color 0.15s, transform 0.2s;
    flex-shrink: 0;
}

.category-tree-picker__toggle:hover {
    background: #e9ecef;
    color: #495057;
}

.category-tree-picker__toggle--open {
    transform: rotate(90deg);
}

/* Placeholder pro položky bez dětí */
.category-tree-picker__toggle-placeholder {
    width: 1.5rem;
    flex-shrink: 0;
}

/* Tlačítko výběru kategorie */
.category-tree-picker__select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    padding: 0.375rem 0.5rem;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: background-color 0.15s;
    min-width: 0;
}

.category-tree-picker__select:hover {
    background: #f8f9fa;
}

.category-tree-picker__select.active {
    background: #e8f0fe;
    color: #0d6efd;
    font-weight: 500;
}

/* Ikona kategorie */
.category-tree-picker__icon {
    flex-shrink: 0;
    width: 1rem;
    text-align: center;
    color: #6c757d;
}

.category-tree-picker__select.active .category-tree-picker__icon {
    color: #0d6efd;
}

/* Název kategorie */
.category-tree-picker__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Badge s počtem produktů */
.category-tree-picker__count {
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    background: #e9ecef;
    color: #6c757d;
    border-radius: 0.75rem;
}

.category-tree-picker__select.active .category-tree-picker__count {
    background: #cfe2ff;
    color: #0d6efd;
}

/* Scrollbar styling */
.category-tree-picker::-webkit-scrollbar {
    width: 6px;
}

.category-tree-picker::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.category-tree-picker::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.category-tree-picker::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}


/* ==================================================
 * 9. Purchase Cart - Collapsible
 * ================================================== */

/**
 * Rozbalovací/sbalovací košík v nákupu.
 * Defaultně kompaktní zobrazení, po kliknutí se rozbalí detail.
 */

/* Toggle tlačítko v headeru */
.cart-toggle-btn {
    background: transparent;
    border: none;
    color: inherit;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.cart-toggle-btn:hover {
    opacity: 0.8;
}

.cart-toggle-btn .bi {
    transition: transform 0.3s ease;
}

.cart-toggle-btn.expanded .bi-chevron-down {
    transform: rotate(180deg);
}

/* Kompaktní zobrazení košíku */
.cart-compact {
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.cart-compact-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}

.cart-compact-list::-webkit-scrollbar {
    width: 4px;
}

.cart-compact-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.cart-compact-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    border-bottom: 1px dashed #e9ecef;
    font-size: 0.875rem;
}

.cart-compact-item:last-child {
    border-bottom: none;
}

.cart-compact-item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 0.5rem;
}

.cart-compact-item-qty {
    font-weight: 600;
    color: var(--bs-primary);
    white-space: nowrap;
}

/* Celkem v kompaktním zobrazení */
.cart-compact-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 2px solid #dee2e6;
    font-weight: 600;
}

.cart-compact-total-amount {
    font-size: 1.125rem;
    color: var(--bs-primary);
}

/* Detailní zobrazení - animace */
.cart-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, opacity 0.3s ease;
    opacity: 0;
}

.cart-detail.expanded {
    max-height: 2000px;
    opacity: 1;
    transition: max-height 0.5s ease-in, opacity 0.3s ease 0.1s;
}

/* Prázdný košík v kompaktním zobrazení */
.cart-compact-empty {
    text-align: center;
    color: #6c757d;
    padding: 1rem 0;
}

.cart-compact-empty i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.25rem;
}

/* Highlight efekt při přidání položky */
@keyframes cartItemAdded {
    0% {
        background-color: rgba(25, 135, 84, 0.3);
    }

    100% {
        background-color: transparent;
    }
}

.cart-compact-item.just-added {
    animation: cartItemAdded 1s ease-out;
}

/* Responzivní úpravy */
@media (max-width: 991.98px) {
    .cart-compact-list {
        max-height: 150px;
    }
}


/* ==================================================
 * 10. Dashboard - Transparent Cards
 * ================================================== */

/**
 * Panely na nástěnce s lehkým průhledným pozadím.
 * Při hoveru se průhlednost odstraní pro lepší čitelnost.
 */

/* Selektory pro karty na nástěnce (Homepage) */
body .card.border-success,
body .card.border-primary {
    background-color: rgba(255, 255, 255, 0.75);
    _backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

body .card.border-success:hover,
body .card.border-primary:hover {
    background-color: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}