:root {
    --sidebar-gap: 12px;
    --sidebar-radius: 16px;

    /* Styling „glass” – możesz się pobawić tymi wartościami */
    --sidebar-blur: 18px;
    --sidebar-bg-main: rgba(248, 246, 242, 0.92);
    /* jasne, lekko mleczne */
    --sidebar-bg-alt: rgba(255, 255, 255, 0.88);
    --sidebar-border: rgba(255, 255, 255, 0.55);
    --sidebar-border-hover: rgba(255, 255, 255, 0.8);
    --sidebar-shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.25);
    --sidebar-shadow-strong: 0 24px 55px rgba(15, 23, 42, 0.35);
}

/* ── Dark mode sidebar — zmienne (style właściwe w master.html <style>) ── */
[data-bs-theme=”dark”] {
    --sidebar-bg-main: rgba(30, 30, 45, 0.95);
    --sidebar-bg-alt: rgba(24, 24, 38, 0.92);
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-border-hover: rgba(255, 255, 255, 0.12);
    --sidebar-shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.4);
    --sidebar-shadow-strong: 0 24px 55px rgba(0, 0, 0, 0.5);
}

/* Desktop – floating glass sidebar */
@media (min-width: 992px) {

    /* Kontener – gap od krawędzi aplikacji */
    .sidebar-wrapper {
        padding-left: var(--sidebar-gap);
        padding-top: var(--sidebar-gap);
        padding-bottom: var(--sidebar-gap);
    }

    #kt_app_sidebar {
        margin-left: var(--sidebar-gap);
        margin-top: var(--sidebar-gap);
        margin-bottom: var(--sidebar-gap);

        border-radius: var(--sidebar-radius);
        overflow: visible;

        /* Glassmorphism */
        background: linear-gradient(135deg,
                var(--sidebar-bg-main),
                var(--sidebar-bg-alt));
        border: 1px solid var(--sidebar-border);

        box-shadow: var(--sidebar-shadow-soft);

        /* Smooth animacje */
        transition:
            transform 0.22s ease-out,
            box-shadow 0.22s ease-out,
            background 0.22s ease-out,
            border-color 0.22s ease-out;
    }

    /* Blur tylko tam, gdzie wspierane */
    @supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
        #kt_app_sidebar {
            backdrop-filter: blur(var(--sidebar-blur));
            -webkit-backdrop-filter: blur(var(--sidebar-blur));
        }
    }

    /* Subtelny lift na hoverze */
    #kt_app_sidebar:hover {
        transform: translateY(-2px);
        box-shadow: var(--sidebar-shadow-strong);
        border-color: var(--sidebar-border-hover);
    }
}

/* Mobile – klasyczny pełny sidebar bez bajerów */
@media (max-width: 991.98px) {
    .sidebar-wrapper {
        padding: 0;
    }

    #kt_app_sidebar {
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        border: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: var(--bs-body-bg);
    }
}

/* User panel przyklejony do dołu */
.app-sidebar-user {
    position: sticky;
    bottom: 0;
    margin-top: auto;
}



/* ✅ Menu filtrów — scrollowalne przy dużej ilości opcji */
#kt_offers_filter_menu > .px-7.py-5:last-child,
#kt_clients_filter_menu > .px-7.py-5:last-child {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* ✅ Poprawa wyglądu Select2 multiple - ikonki usuwania */
.select2-container--bootstrap5 .select2-selection--multiple .select2-selection__choice {
    background-color: var(--bs-gray-100);
    border: 1px solid var(--bs-gray-300);
    border-radius: 0.475rem;
    padding: 0.375rem 0.75rem;
    margin: 0.25rem 0.25rem 0.25rem 0;
    font-size: 0.925rem;
    font-weight: 500;
}

.select2-container--bootstrap5 .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--bs-gray-500);
    margin-right: 0.5rem;
    font-weight: bold;
    float: left;
    cursor: pointer;
}

.select2-container--bootstrap5 .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: var(--bs-danger);
}

/* Select2 dropdown ponad modalem Bootstrap (z-index: 1055) */
.select2-container--open {
    z-index: 1056 !important;
}

.global-search-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.global-search-toggle.btn-primary {
    box-shadow: 0 0 0 3px rgba(80, 165, 241, 0.2);
}

/* Adjust search input padding when button is present */
[data-kt-filemanager-table-filter="search"] {
    padding-right: 50px !important;
}

/* Make parent position relative */
.d-flex.align-items-center.position-relative {
    position: relative !important;
}

.file-name-truncate {
    display: block;
    /* musi być blok */
    max-width: 100%;
    /* nie wychodzimy poza kontener */
    overflow: hidden;
    /* obetnij nadmiar */
    white-space: nowrap;
    /* bez zawijania */
    text-overflow: ellipsis;
    /* dodaj "..." */
}

/* Baza – spójne z ikonami Quilla */
.ql-toolbar .ql-attach .ql-ki-icon {
    font-size: 18px;
    width: 18px;
    height: 18px;
    line-height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;

    /* Metronic-like smoothness */
    transition:
        transform .18s ease,
        color .18s ease,
        filter .18s ease,
        opacity .18s ease;
    opacity: .85;
}

/* Duotone – bazowy kolor z tekstu toolbara */
.ql-toolbar .ql-attach .ql-ki-icon .path1,
.ql-toolbar .ql-attach .ql-ki-icon .path2 {
    transition: fill .18s ease, stroke .18s ease;
}

/* Hover – Metronic vibe: lekki zoom, podbity kolor, delikatny glow */
.ql-toolbar .ql-attach:hover .ql-ki-icon {
    transform: scale(1.12) translateY(-1px);
    opacity: 1;
    color: var(--bs-primary);
    /* Metronicowa zmienna */
    filter: drop-shadow(0 0 4px rgba(59, 125, 221, 0.45));
    /* delikatny glow */
}

/* Jeśli chcesz też podbić duotone ścieżki pod primary */
.ql-toolbar .ql-attach:hover .ql-ki-icon .path1,
.ql-toolbar .ql-attach:hover .ql-ki-icon .path2 {
    fill: var(--bs-primary);
    stroke: var(--bs-primary);
}

/* Focus via klawiatura – bardziej dostępne */
.ql-toolbar .ql-attach:focus-visible .ql-ki-icon {
    outline: none;
    transform: scale(1.12) translateY(-1px);
    filter: drop-shadow(0 0 4px rgba(59, 125, 221, 0.7));
}

/* 1) BAZA: wszystkie przyciski w toolbarze Quilla */
.ql-toolbar button {
    position: relative;
    transition:
        background-color .18s ease,
        color .18s ease,
        box-shadow .18s ease;
    outline: none;
}

/* 2) BAZA IKON: Quill SVG + nasza KI-ikonka – rozmiar + smooth animacja */
.ql-toolbar button svg,
.ql-toolbar button .ql-ki-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 18px;

    transition:
        transform .18s ease,
        filter .18s ease,
        opacity .18s ease;
    opacity: .85;
}

/* 3) Kolory wewnątrz SVG Quilla – stroke/fill */
/* Quill standardowo używa klas .ql-stroke, .ql-fill itd. */
.ql-toolbar button .ql-stroke {
    stroke: currentColor;
    transition: stroke .18s ease;
}

.ql-toolbar button .ql-fill {
    fill: currentColor;
    transition: fill .18s ease;
}

/* 4) Bazowy kolor ikon – szary jak w Metronicu */
.ql-toolbar {
    color: #7e8299;
    /* możesz spiąć z jakąś zmienną Metronica, np. var(--bs-gray-600) */
}

/* 5) HOVER / FOCUS – efekt Metronic-like dla WSZYSTKICH klawiszy */
.ql-toolbar button:hover svg,
.ql-toolbar button:hover .ql-ki-icon,
.ql-toolbar button:focus-visible svg,
.ql-toolbar button:focus-visible .ql-ki-icon {
    transform: scale(1.12) translateY(-1px);
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(59, 125, 221, 0.45));
    /* delikatny glow */
}

/* 6) Zmiana koloru na primary przy hover/focus */
.ql-toolbar button:hover,
.ql-toolbar button:focus-visible {
    color: var(--bs-primary);
}

/* Duotone KI – jeśli chcesz, żeby oba pathy też się podbarwiały */
.ql-toolbar button:hover .ql-ki-icon .path1,
.ql-toolbar button:hover .ql-ki-icon .path2,
.ql-toolbar button:focus-visible .ql-ki-icon .path1,
.ql-toolbar button:focus-visible .ql-ki-icon .path2 {
    fill: var(--bs-primary);
    stroke: var(--bs-primary);
}

/* 7) Aktywny przycisk (np. bold włączony) – lekko podkreślony */
.ql-toolbar button.ql-active {
    color: var(--bs-primary);
}

.ql-toolbar button.ql-active svg,
.ql-toolbar button.ql-active .ql-ki-icon {
    opacity: 1;
}

/* 8) Extra: konkretnie attach (możesz, ale nie musisz zostawiać – ujednoliciliśmy resztę) */
.ql-toolbar .ql-attach .ql-ki-icon {
    font-size: 18px;
}

.text-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ellipsis-2-lines {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-attachment {
    overflow: hidden;
    /* nic nie wyjdzie poza szary box */
}

.note-attachment-name {
    display: block;
    max-width: calc(100% - 0.5rem);
    /* ✨ obcinamy ~8px przed krawędzią */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Filters button badge */
.filter-count-badge {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    min-width: 1.5rem;
    font-weight: 600;
}

/* Mobile */
@media (max-width: 767px) {
    .filter-count-badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.4rem;
        min-width: 1.25rem;
    }
}

/* ===== Calculator — Refined Financial Design ===== */

/* All row-coloring classes neutralized — clean white data rows */
.calc-row-blue,
.calc-row-green,
.calc-row-yellow,
.calc-row-orange,
.calc-row-salmon,
.calc-row-vat,
.excel-blue,
.excel-green,
.excel-yellow,
.excel-orange,
.excel-salmon,
.excel-vat,
.excel-vat-bg { /* no background — intentionally blank */ }

/* ===== Section header row ===== */
.calc-section-header {
    background-color: var(--bs-gray-100) !important;
    border-left: 3px solid var(--bs-primary) !important;
}
.calc-section-header td {
    padding-top: 0.6rem !important;
    padding-bottom: 0.6rem !important;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--bs-gray-700);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===== Section total ===== */
.calc-total-row td {
    background-color: var(--bs-gray-100) !important;
    font-weight: 600 !important;
    border-top: 1px solid var(--bs-gray-300) !important;
}

/* ===== Grand total ===== */
.calc-grand-total-row td {
    background-color: #EEF2FF !important;
    font-weight: 700 !important;
    color: var(--bs-gray-900) !important;
    border-top: 2px solid var(--bs-primary) !important;
}

/* ===== Client share (jedyny ciepły akcent) ===== */
.calc-summary-highlight td {
    background-color: #FFFBEB !important;
    font-weight: 700 !important;
    border-top: 1px solid #FDE68A !important;
}

/* ===== Margin row ===== */
.calc-margin-row td {
    background-color: #EEF2FF !important;
}

/* ===== KPI stat pills ===== */
.calc-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: 0.475rem;
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.calc-stat-pill .calc-stat-label {
    font-weight: 500;
    opacity: 0.7;
    font-size: 0.75rem;
}

/* Calculator comparison — redesigned */
.compare-best {
    background-color: #E8F5E9 !important;
    position: relative;
}
.compare-best::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #4CAF50;
    border-radius: 3px;
}
.compare-worst {
    background-color: #FFF3F0 !important;
    position: relative;
}
.compare-worst::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #EF5350;
    border-radius: 3px;
}
.compare-section-header td {
    background-color: #f8fafc !important;
    border-top: 2px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    padding-top: 0.85rem !important;
    padding-bottom: 0.85rem !important;
}
.compare-section-total td {
    background-color: #f1f5f9 !important;
    border-top: 2px solid #e2e8f0;
    font-variant-numeric: tabular-nums;
}

/* Summary cards */
.compare-summary-card {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1.25rem;
    height: 100%;
    transition: box-shadow 0.2s ease;
}
.compare-summary-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.compare-summary-card.is-default {
    border-color: var(--bs-primary);
    border-width: 2px;
}
.compare-summary-value {
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.compare-summary-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--bs-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.compare-summary-meta {
    font-size: 0.8rem;
    color: var(--bs-gray-600);
}
.compare-summary-badge-best {
    background: #E8F5E9;
    color: #2E7D32;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 0.35rem;
}
.compare-summary-badge-worst {
    background: #FFF3F0;
    color: #C62828;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 0.35rem;
}

/* Table refinements */
#compare_table {
    font-variant-numeric: tabular-nums;
    table-layout: fixed;
}
#compare_table thead th {
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#compare_table td {
    position: relative;
    overflow-wrap: break-word;
}
#compare_table .compare-data-row td:first-child {
    padding-left: 2.5rem !important;
}
.compare-item-name {
    font-size: 0.85rem;
    color: var(--bs-gray-700);
}
.compare-value {
    font-weight: 600;
    white-space: nowrap;
}
.compare-value-zero {
    color: var(--bs-gray-400);
    font-weight: 400;
}
.compare-diff-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--bs-gray-500);
    margin-top: 2px;
}

/* Center icon inside Metronic "symbol" pill */
.calc-demo .symbol {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
}
.calc-demo .symbol i {
    margin: 0 !important;
    line-height: 1 !important;
}
.calc-demo .symbol i>span {
    margin: 0 !important;
}


/* ================================
   Metronic-style inputs in calc cells
================================ */

.excel-input {
    background-color: var(--bs-gray-100) !important;
    border: 1px solid var(--bs-gray-300) !important;
    border-radius: 0.475rem;
    text-align: right;
    font-weight: 500;
    padding-right: 0.75rem;
}

.excel-input:hover {
    background-color: var(--bs-gray-200) !important;
}

.excel-input:focus {
    background-color: #ffffff !important;
    border-color: var(--bs-primary) !important;
    box-shadow: 0 0 0 0.15rem rgba(0, 158, 247, 0.25);
}

.excel-input::-webkit-outer-spin-button,
.excel-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.excel-input {
    -moz-appearance: textfield;
}


input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

.excel-input {
    font-variant-numeric: tabular-nums;
}

#result_table tbody td:first-child { padding-left: 1.5rem !important; }
#result_table tbody td:last-child  { padding-right: 1.5rem !important; }
#result_table tbody td { vertical-align: middle; }

/* ===== Notification shake animation ===== */
@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-12deg); }
    40% { transform: rotate(12deg); }
    60% { transform: rotate(-8deg); }
    80% { transform: rotate(8deg); }
}
.animation-shake {
    animation: shake 0.6s ease-in-out;
}

/* Notification dropdown items */
.kt-notification-item {
    border-radius: 0.475rem;
    transition: background-color 0.15s ease;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    margin-bottom: 2px;
}
.kt-notification-item.bg-light-primary {
    border-left: 3px solid var(--bs-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.kt-notification-item:hover {
    background-color: var(--bs-gray-100) !important;
    text-decoration: none;
}

/* ===== Impersonation Banner ===== */
.impersonation-banner {
    position: sticky;
    top: 0;
    z-index: 1060;
    background: linear-gradient(135deg, #ffc107 0%, #ffca2c 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
    min-height: 44px;
    flex-shrink: 0;
}

[data-bs-theme="dark"] .impersonation-banner {
    background: linear-gradient(135deg, #b8860b 0%, #daa520 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===== Empty state — prevent overflow on wide tables ===== */
/* Card body z tabelą: overflow-x zapobiega wylewaniu przy empty state */
.card-body:has(> table) {
    overflow-x: auto;
}

/* DataTables-generated empty state */
table.dataTable td.dataTables_empty,
table.dataTable td.dt-empty {
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 0;
}

table.dataTable td.dataTables_empty > div,
table.dataTable td.dt-empty > div {
    max-width: 600px;
    margin: 0 auto;
}

/* Custom modal size beyond Bootstrap modal-xl (PV/ME calculator).
   Od lg w górę (niżej i tak modal-fullscreen-lg-down / wąski domyślny). */
@media (min-width: 992px) {
    .modal-xxl .modal-dialog,
    .modal-dialog.modal-xxl {
        max-width: 1800px;
        width: 95vw;
    }
}

/* Wizard PV/ME — szerokość zależna od kroku (klasy przełączane w pv-wizard.js /
   me-wizard.js). Domyślnie dialog jest modal-xxl (kroki ze sprzętem/podsumowaniem);
   na kroku parametrów / marży zwężamy. Tylko od lg w górę — niżej modal-fullscreen-lg-down
   i tak rozciąga modal na cały ekran. Wyższa specyficzność niż .modal-dialog.modal-xxl. */
@media (min-width: 992px) {
    .modal-dialog.pv-me-wizard-dialog.pv-wizard-step-narrow {
        max-width: 680px;
        width: 92vw;
    }
    .modal-dialog.pv-me-wizard-dialog.pv-wizard-step-medium {
        max-width: 1140px;
        width: 92vw;
    }

    /* Płynna zmiana szerokości przy przejściu między krokami („morphing" modala).
       Zachowujemy bootstrapowy transform (animacja otwarcia) — `transition` nie jest
       addytywne, więc trzeba go wymienić w całości. Specyficzność 0,4,0 bije
       bootstrapowe `.modal.fade .modal-dialog` (0,3,0). Wysokość pozostaje auto
       (nieanimowalna) — w pionie modal nadal może lekko „strzelić". */
    .modal.fade .modal-dialog.pv-me-wizard-dialog {
        transition: transform 0.3s ease-out, max-width 0.28s ease, width 0.28s ease;
    }
}

@media (prefers-reduced-motion: reduce) {
    .modal.fade .modal-dialog.pv-me-wizard-dialog {
        transition: none;
    }
}

/* Sticky panel step 1 wizarda PV/ME (Model panela + Dobierz sprzęt — widoczny zawsze podczas długiej tabeli) */
.pv-wizard-sticky-panel {
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

/* Wyrownanie szerokosci dropdownow Select2 produktow w kolumnie "Produkt" tabeli wizarda.
   Dzieki display:block wszystkie selecty ciagna sie na pelna szerokosc komorki td.
   Wtedy min-w-180px (punkt 12) dziala spojnie zamiast kazdy Select2 dopasowywal sie
   do dlugosci wybranej pozycji. */
#pv_items_table .pv-product-select + .select2-container,
#pv_items_table .select2-container {
    width: 100% !important;
    display: block;
}

/* Model panela w step 1 — szerszy niz kolumny tabeli (dluga nazwa producenta + model) */
#pv_step1_panel_select + .select2-container {
    min-width: 360px;
    width: 100% !important;
    max-width: 520px;
}


/* ── Tagify widget (tagi na detailach oferty/klienta/zlecenia/wniosku/podwykonawcy)
   Zdejmujemy ramkę/tło inputa — card "Tagi" już sam jest w ramce, dublowanie
   wygląda ciężko. Chipy (badge-light-*) same w sobie niosą styling. */
.tagify-widget > tags.tagify {
    border: none;
    background: transparent;
    padding: 2px 0;
    min-height: 28px;
}
.tagify-widget > tags.tagify:hover,
.tagify-widget > tags.tagify.tagify--focus {
    border: none;
    box-shadow: none;
}
.tagify-widget > tags.tagify .tagify__input {
    padding-left: 4px;
    margin: 2px;
}
/* Anti-flash: surowy <input> pokazuje się przez ~100ms zanim JS zdąży przejąć.
   Ukrywamy go do momentu, aż tagify-widget.js ustawi data-tagify-initialized="1".
   min-height rezerwuje miejsce, żeby layout się nie skakał. */
.tagify-widget {
    min-height: 32px;
}
.tagify-widget:not([data-tagify-initialized="1"]) > .tagify-input {
    visibility: hidden;
}
