/* ═══════════════════════════════════════════════════════
   Mecha CRM — custom overrides for Tabler
   ═══════════════════════════════════════════════════════ */

/* ─── Design tokens ─── */
:root,
[data-bs-theme=light],
[data-bs-theme=dark] {
    --tblr-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --tblr-body-font-family: var(--tblr-font-sans-serif);

    /* Violet primary */
    --tblr-primary:           #7c3aed;
    --tblr-primary-rgb:       124, 58, 237;
    --tblr-primary-lt:        #ede9fe;
    --tblr-primary-darken:    #6d28d9;

    --tblr-border-radius:     6px;
    --tblr-border-radius-sm:  4px;
    --tblr-border-radius-lg:  10px;
    --tblr-border-radius-xl:  16px;
    --tblr-border-radius-xxl: 20px;

    /* Sidebar tokens */
    --mecha-sidebar-bg:           #0f0a1e;
    --mecha-sidebar-active-bg:    rgba(124, 58, 237, .35);
    --mecha-sidebar-hover-bg:     rgba(124, 58, 237, .12);
    --mecha-sidebar-group-color:  #4c3d6e;
    --mecha-sidebar-text:         #c4b5fd;
    --mecha-sidebar-text-muted:   #7c6a9e;
}

/* Тіні для світлої теми — використовують темний колір */
:root,
[data-bs-theme=light] {
    --tblr-box-shadow:    0 1px 4px rgba(var(--tblr-dark-rgb), .07), 0 3px 10px rgba(var(--tblr-dark-rgb), .04);
    --tblr-box-shadow-sm: 0 1px 3px rgba(var(--tblr-dark-rgb), .06);
    --tblr-box-shadow-lg: 0 4px 24px rgba(var(--tblr-dark-rgb), .09);
}

/* Тіні для темної теми — глибокі чорні для об'єму */
[data-bs-theme=dark] {
    --tblr-box-shadow:    0 1px 6px rgba(0, 0, 0, .35), 0 3px 12px rgba(0, 0, 0, .25);
    --tblr-box-shadow-sm: 0 1px 4px rgba(0, 0, 0, .3);
    --tblr-box-shadow-lg: 0 4px 28px rgba(0, 0, 0, .45);
}

/* ─── Картки: тінь + більший радіус ─── */
.card {
    border-radius: var(--tblr-border-radius-lg) !important;
    box-shadow: var(--tblr-box-shadow);
    border-color: var(--tblr-border-color);
}
.card-header { border-radius: var(--tblr-border-radius-lg) var(--tblr-border-radius-lg) 0 0 !important; }
.card-footer { border-radius: 0 0 var(--tblr-border-radius-lg) var(--tblr-border-radius-lg) !important; }

/* ─── Кнопки: плавніші ─── */
.btn { border-radius: var(--tblr-border-radius) !important; font-weight: 500; }
.btn-sm { border-radius: var(--tblr-border-radius-sm) !important; }
.btn-lg { border-radius: var(--tblr-border-radius-lg) !important; }

/* ─── Поля вводу ─── */
.form-control,
.form-select { border-radius: var(--tblr-border-radius) !important; }
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 .2rem rgba(var(--tblr-primary-rgb), .12) !important;
}
.input-group > .form-control:not(:last-child),
.input-group > .form-select:not(:last-child) { border-radius: var(--tblr-border-radius) 0 0 var(--tblr-border-radius) !important; }
.input-group > .form-control:not(:first-child),
.input-group > .form-select:not(:first-child) { border-radius: 0 var(--tblr-border-radius) var(--tblr-border-radius) 0 !important; }

/* ─── Badges ─── */
.badge { border-radius: var(--tblr-border-radius-sm) !important; font-weight: 500; letter-spacing: .02em; }

/* ─── Dropdown ─── */
.dropdown-menu {
    border-radius: var(--tblr-border-radius-lg) !important;
    box-shadow: var(--tblr-box-shadow-lg);
    border-color: var(--tblr-border-color);
    padding: .375rem;
}
.dropdown-item { border-radius: var(--tblr-border-radius) !important; padding: .4rem .625rem; }
.dropdown-divider { margin: .375rem 0; }

/* ─── Modal ─── */
.modal-content { border-radius: var(--tblr-border-radius-xl) !important; box-shadow: var(--tblr-box-shadow-lg); }
.modal-header  { border-radius: var(--tblr-border-radius-xl) var(--tblr-border-radius-xl) 0 0 !important; }
.modal-footer  { border-radius: 0 0 var(--tblr-border-radius-xl) var(--tblr-border-radius-xl) !important; }

/* ─── Offcanvas ─── */
.offcanvas { border-radius: var(--tblr-border-radius-xl) 0 0 var(--tblr-border-radius-xl); }
.offcanvas.offcanvas-end { border-radius: 0 var(--tblr-border-radius-xl) var(--tblr-border-radius-xl) 0; }

/* ─── Toast ─── */
.toast { border-radius: var(--tblr-border-radius-lg) !important; box-shadow: var(--tblr-box-shadow-lg); }

/* ─── Navbar top ─── */
header.navbar {
    border-bottom: 1px solid rgba(124, 58, 237, .15);
    box-shadow: none;
}

/* ─── Sidebar nav items ─── */
.navbar-vertical .nav-item .nav-link {
    border-radius: var(--tblr-border-radius) !important;
    margin-inline: .375rem;
    padding-inline: .625rem;
    transition: background .15s, color .15s;
    color: var(--mecha-sidebar-text);
}
.navbar-vertical .nav-item.active > .nav-link,
.navbar-vertical .nav-item .nav-link.active {
    background: linear-gradient(90deg, var(--mecha-sidebar-active-bg), transparent) !important;
    border-left: 2px solid var(--tblr-primary);
    color: #fff !important;
}
.navbar-vertical .nav-item .nav-link:hover:not(.active) {
    background: var(--mecha-sidebar-hover-bg);
    color: #fff;
}
.navbar-vertical .nav-link-secondary .nav-link-title {
    color: var(--mecha-sidebar-group-color) !important;
}

/* ─── Page body background ─── */
.page-body { background: var(--tblr-body-bg); }

/* ─── Sticky footer ─── */
.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.page-body { flex: 1; }

/* ─── DataTables (DT 2.x / Bootstrap 5) ─── */

/* Label text */
div.dt-container div.dt-length label,
div.dt-container div.dt-search label {
    color: var(--tblr-body-color);
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
}

/* Length select — DT adds form-select form-select-sm automatically,
   we just override colours; appearance:none is set by Bootstrap already */
div.dt-container div.dt-length select {
    border-color: var(--tblr-border-color) !important;
    background-color: var(--tblr-bg-surface) !important;
    color: var(--tblr-body-color) !important;
    /* Remove appearance:auto — Bootstrap's form-select already draws one arrow
       via background-image. Adding appearance:auto would add a SECOND native arrow. */
}
div.dt-container div.dt-length select:focus {
    border-color: var(--tblr-primary) !important;
    box-shadow: 0 0 0 .2rem rgba(var(--tblr-primary-rgb), .15) !important;
    outline: none;
}

/* Search input */
div.dt-container div.dt-search input {
    border: var(--tblr-border-width) solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    padding: .25rem .6rem;
    background: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
    font-size: .875rem;
    outline: none;
}
div.dt-container div.dt-search input:focus {
    border-color: var(--tblr-primary);
    box-shadow: 0 0 0 .2rem rgba(var(--tblr-primary-rgb), .15);
}

/* Spacing */
div.dt-container div.dt-length,
div.dt-container div.dt-search { margin-block: 1rem; }

/* Info */
div.dt-container div.dt-info {
    color: var(--tblr-secondary-color, #626976);
    font-size: .8125rem;
    padding-top: .375rem;
}

/* Sort icons — always visible, dim when inactive */
table.dataTable thead .dt-orderable-asc.dt-orderable-desc .dt-column-order::before,
table.dataTable thead .dt-orderable-asc.dt-orderable-desc .dt-column-order::after {
    visibility: visible !important;
    opacity: .25;
    background-color: var(--tblr-body-color);
}
table.dataTable thead .dt-ordering-asc .dt-column-order::before,
table.dataTable thead .dt-ordering-desc .dt-column-order::after {
    visibility: visible !important;
    opacity: .7;
    background-color: var(--tblr-primary);
}

/* Thead cells */
table.dataTable thead > tr > th {
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--tblr-secondary-color, #626976);
    border-bottom: 1px solid var(--tblr-border-color) !important;
    padding-top: .75rem;
    padding-bottom: .75rem;
    vertical-align: middle;
}
table.dataTable thead > tr > th:hover { outline: none !important; }

/* Pagination */
div.dt-container div.dt-paging .pagination { margin: .25rem 0; gap: .125rem; }
div.dt-container div.dt-paging .page-link {
    border-radius: var(--tblr-border-radius) !important;
    font-size: .8125rem;
    padding: .25rem .5rem;
    min-width: 2rem;
    text-align: center;
    line-height: 1.5;
    color: var(--tblr-body-color);
    border-color: var(--tblr-border-color);
    background: transparent;
}
div.dt-container div.dt-paging .page-item.active .page-link {
    background: var(--tblr-primary);
    border-color: var(--tblr-primary);
    color: #fff;
}
div.dt-container div.dt-paging .page-item:not(.active):not(.disabled) .page-link:hover {
    background: var(--tblr-primary-lt);
    color: var(--tblr-primary);
    border-color: transparent;
}
div.dt-container div.dt-paging .page-item.disabled .page-link {
    opacity: .45;
    color: var(--tblr-secondary-color, #626976);
}

/* Processing spinner */
div.dt-processing {
    background: var(--tblr-bg-surface) !important;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    box-shadow: var(--tblr-box-shadow);
    color: var(--tblr-body-color);
    font-size: .875rem;
}

/* ── Footer (info + paging row — appears after the table) ── */
div.dt-container .dt-layout-table ~ .row {
    margin-top: 0 !important;
    padding: .5rem 0 .25rem;
    border-top: var(--tblr-border-width) solid var(--tblr-border-color);
    align-items: center;
}
/* Top search/length row */
div.dt-container .row:first-child {
    padding-bottom: .25rem;
    border-bottom: var(--tblr-border-width) solid var(--tblr-border-color);
    margin-bottom: 0 !important;
}
/* Remove duplicate mt-2 spacing between rows */
div.dt-container .row { margin-top: 0 !important; }

/* ─── Select2 single ─── */
.select2-container .select2-selection--single {
    /* flexbox centres the text vertically regardless of height */
    display: flex !important;
    align-items: center;
    height: calc(1.4285714em + .75rem + 2px) !important;
    padding: 0 .75rem;
    border: var(--tblr-border-width) solid var(--tblr-border-color) !important;
    border-radius: var(--tblr-border-radius) !important;
    background-color: var(--tblr-bg-surface) !important;
    color: var(--tblr-body-color);
    outline: none;
}
.select2-container .select2-selection--single .select2-selection__rendered {
    flex: 1;
    color: var(--tblr-body-color) !important;
    line-height: 1.4285714;
    padding: 0;
    padding-right: 1.5rem; /* room for the arrow */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.select2-container .select2-selection--single .select2-selection__placeholder {
    color: var(--tblr-secondary-color, #626976);
}
.select2-container .select2-selection--single .select2-selection__arrow {
    position: absolute;
    top: 0; right: .5rem;
    height: 100%;
    display: flex;
    align-items: center;
}
.select2-container--open .select2-selection--single {
    border-color: var(--tblr-primary) !important;
    box-shadow: 0 0 0 .2rem rgba(var(--tblr-primary-rgb), .15);
}
.select2-dropdown {
    border: var(--tblr-border-width) solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background: var(--tblr-bg-surface);
    box-shadow: var(--tblr-box-shadow);
    z-index: 9999;
}
.select2-results__option {
    color: var(--tblr-body-color);
    padding: .4rem .75rem;
}
.select2-results__option--highlighted {
    background: var(--tblr-primary) !important;
    color: #fff !important;
}
.select2-search--dropdown .select2-search__field {
    border: var(--tblr-border-width) solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
    padding: .3rem .5rem;
}

/* ─── Select2 multiple ─── */
.select2-container .select2-selection--multiple {
    min-height: calc(1.4285714em + .75rem + 2px);
    padding: .25rem .375rem;
    border: var(--tblr-border-width) solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background-color: var(--tblr-bg-surface);
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--tblr-primary-lt);
    border: 1px solid rgba(var(--tblr-primary-rgb), .2);
    border-radius: var(--tblr-border-radius-sm, .2rem);
    color: var(--tblr-primary);
    padding: 1px 6px 1px 6px;
    font-size: .75rem;
    line-height: 1.5;
    margin: 2px 3px 2px 0;
    float: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--tblr-primary);
    font-weight: 600;
    order: 1;
    border: none;
    background: none;
    padding: 0;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: var(--tblr-danger);
    background: none;
}
.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--tblr-primary);
    box-shadow: 0 0 0 .2rem rgba(var(--tblr-primary-rgb), .15);
    outline: 0;
}
.select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field {
    color: var(--tblr-body-color);
    margin-top: 3px;
}
.select2-container--default .select2-selection--multiple .select2-selection__placeholder {
    color: var(--tblr-secondary-color, #626976);
}

/* ─── Flatpickr ─── */
.flatpickr-calendar {
    background: var(--tblr-bg-surface);
    border: var(--tblr-border-width) solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    box-shadow: var(--tblr-box-shadow);
    color: var(--tblr-body-color);
}
.flatpickr-day.selected, .flatpickr-day.selected:hover {
    background: var(--tblr-primary);
    border-color: var(--tblr-primary);
}
.flatpickr-day:hover { background: var(--tblr-primary-lt); }
.flatpickr-months .flatpickr-month,
.flatpickr-weekdays,
span.flatpickr-weekday {
    background: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
}

/* ─── Buttons: secondary variant ─── */
.btn-secondary,
.btn-outline-secondary {
    --tblr-btn-color: var(--tblr-body-color);
    --tblr-btn-border-color: var(--tblr-border-color);
    /* hover: зберігаємо темний текст на блідому фоні */
    --tblr-btn-hover-color: var(--tblr-body-color);
    --tblr-btn-hover-bg: var(--tblr-secondary-lt);
    --tblr-btn-hover-border-color: var(--tblr-border-color);
    --tblr-btn-active-color: var(--tblr-body-color);
    --tblr-btn-active-bg: var(--tblr-secondary-lt);
    --tblr-btn-active-border-color: var(--tblr-border-color);
}
.btn-ghost-secondary {
    color: var(--tblr-body-color);
}
.btn-ghost-secondary:hover {
    background: var(--tblr-secondary-lt);
    color: var(--tblr-body-color);
}

/* ─── Avatar helper ─── */
.avatar-xs {
    width: 1.5rem;
    height: 1.5rem;
    font-size: .6rem;
    line-height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ─── Notification badge dot ─── */
.badge-notification {
    position: absolute;
    top: -2px; right: -2px;
    min-width: 14px; height: 14px;
    font-size: 9px;
    padding: 0 3px;
    line-height: 14px;
    border-radius: 7px;
}

/* ═══════════════════════════════════════════════
   CHAT (TelegramChats)
   ═══════════════════════════════════════════════ */
.chat-history { padding: 1.25rem; }

.chat-message {
    display: flex;
    align-items: flex-end;
    margin-bottom: 1.25rem;
    gap: .625rem;
}

/* ── Client message — left ── */
.chat-message .chat-message-wrapper { max-width: 70%; }

.chat-message .chat-message-text {
    background: var(--tblr-bg-surface-secondary, #f1f5f9);
    border: var(--tblr-border-width) solid var(--tblr-border-color);
    border-radius: 0 .75rem .75rem .75rem;
    padding: .5rem .875rem;
    word-break: break-word;
}

.chat-message .chat-message-text p { color: var(--tblr-body-color); }

/* ── Manager message — right ── */
.chat-message-right {
    flex-direction: row-reverse;
}

.chat-message-right .chat-message-wrapper {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.chat-message-right .chat-message-text {
    background: var(--tblr-primary);
    border-color: var(--tblr-primary);
    border-radius: .75rem 0 .75rem .75rem;
    color: #fff;
}

.chat-message-right .chat-message-text p { color: #fff; }
.chat-message-right .text-body-secondary { text-align: right; }
.chat-message-right .text-body-secondary small { color: rgba(255,255,255,.65); }

/* Chat session sidebar */
.chat-session-item {
    cursor: pointer;
    padding: .625rem .875rem;
    border-bottom: var(--tblr-border-width) solid var(--tblr-border-color);
    transition: background .15s;
}
.chat-session-item:hover { background: var(--tblr-primary-lt); }
.chat-session-item.active { background: var(--tblr-primary-lt); border-left: 3px solid var(--tblr-primary); }
.chat-session-item.session-unread { background: rgba(var(--tblr-primary-rgb), .04); }

/* ═══════════════════════════════════════════════
   TIMELINE (Client history)
   ═══════════════════════════════════════════════ */
.timeline {
    list-style: none;
    padding: .5rem 0;
    margin: 0;
    position: relative;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 0; bottom: 0;
    width: 2px;
    background: var(--tblr-border-color);
}
.timeline-item {
    position: relative;
    padding: 0 0 1.5rem 2.75rem;
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-point {
    position: absolute;
    left: .375rem;
    top: .25rem;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 2px solid var(--tblr-bg-surface);
    box-shadow: 0 0 0 2px var(--tblr-border-color);
    z-index: 1;
}
.timeline-point-primary  { background: var(--tblr-primary); box-shadow: 0 0 0 2px var(--tblr-primary); }
.timeline-point-success  { background: var(--tblr-success); box-shadow: 0 0 0 2px var(--tblr-success); }
.timeline-point-info     { background: var(--tblr-info);    box-shadow: 0 0 0 2px var(--tblr-info); }
.timeline-point-warning  { background: var(--tblr-warning); box-shadow: 0 0 0 2px var(--tblr-warning); }
.timeline-point-danger   { background: var(--tblr-danger);  box-shadow: 0 0 0 2px var(--tblr-danger); }
.timeline-point-secondary{ background: var(--tblr-secondary);box-shadow: 0 0 0 2px var(--tblr-secondary); }

.timeline-event {
    background: var(--tblr-bg-surface);
    border: var(--tblr-border-width) solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius-lg, .5rem);
    padding: .75rem 1rem;
}
.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    flex-wrap: wrap;
}
.timeline-header h6 { margin: 0; font-size: .875rem; }

/* ═══════════════════════════════════════════════
   FULLCALENDAR + Tabler
   ═══════════════════════════════════════════════ */
.fc {
    --fc-border-color: var(--tblr-border-color);
    --fc-button-bg-color: var(--tblr-primary);
    --fc-button-border-color: var(--tblr-primary);
    --fc-button-hover-bg-color: var(--tblr-primary-darken, #1a56db);
    --fc-button-hover-border-color: var(--tblr-primary-darken, #1a56db);
    --fc-button-active-bg-color: var(--tblr-primary-darken, #1a56db);
    --fc-today-bg-color: var(--tblr-primary-lt);
    --fc-page-bg-color: var(--tblr-bg-surface);
    --fc-neutral-bg-color: var(--tblr-bg-surface-secondary);
    --fc-list-event-hover-bg-color: var(--tblr-primary-lt);
    --fc-highlight-color: var(--tblr-primary-lt);
}
/* Toolbar */
.fc .fc-toolbar.fc-header-toolbar {
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1rem;
}
.fc .fc-toolbar-title { font-size: 1.125rem; font-weight: 600; color: var(--tblr-body-color); }

/* Buttons */
.fc .fc-button {
    border-radius: var(--tblr-border-radius) !important;
    font-size: .8125rem;
    font-weight: 500;
    padding: .3rem .75rem;
}
.fc .fc-button:focus { box-shadow: 0 0 0 .2rem rgba(var(--tblr-primary-rgb),.25); }

/* Month grid */
.fc .fc-daygrid-day-number { color: var(--tblr-body-color); font-size: .8rem; padding: .25rem .5rem; }
.fc .fc-daygrid-day-top { justify-content: flex-end; }
.fc .fc-col-header-cell-cushion { color: var(--tblr-muted); font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.fc .fc-daygrid-day.fc-day-today { background: var(--tblr-primary-lt) !important; }
.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number { color: var(--tblr-primary); font-weight: 700; }

/* Events */
.fc .fc-daygrid-event {
    border-radius: .25rem;
    font-size: .75rem;
    padding: 1px 4px;
    font-weight: 500;
}
.fc .fc-event {
    border: none;
    cursor: pointer;
}
.fc .fc-event:hover { opacity: .85; }

/* More link */
.fc .fc-daygrid-more-link { color: var(--tblr-primary); font-size: .75rem; font-weight: 500; }

/* Nested card inside calendar — no extra radius/shadow */
.app-calendar-content .card { border-radius: 0 !important; box-shadow: none !important; }

/* Dark mode */
[data-bs-theme=dark] .fc { --fc-page-bg-color: var(--tblr-bg-surface); }

/* ── Calendar mobile responsive ── */
@media (max-width: 767px) {
    .fc .fc-timeGridWeek-button,
    .fc .fc-timeGridDay-button { display: none !important; }
    .fc .fc-toolbar.fc-header-toolbar { gap: .25rem; margin-bottom: .75rem; }
    .fc .fc-toolbar-title { font-size: .9rem; }
    .fc .fc-button { font-size: .73rem !important; padding: .2rem .45rem !important; }
    .fc .fc-sidebarToggle-button { padding-left: 0 !important; min-width: unset; }
    .fc .fc-daygrid-day-number { font-size: .7rem; padding: .125rem .25rem; }
    .fc .fc-col-header-cell-cushion { font-size: .6rem; padding: .25rem 0; }
    .fc .fc-daygrid-event { font-size: .68rem; padding: 0 3px; }
}

/* ─── Dark mode: ghost buttons — чіткіший контраст ─── */
[data-bs-theme=dark] .btn-ghost-secondary {
    color: var(--tblr-body-color);
}
[data-bs-theme=dark] .btn-ghost-secondary:hover,
[data-bs-theme=dark] .btn-ghost-secondary:focus {
    background: var(--tblr-bg-surface-secondary);
    color: var(--tblr-emphasis-color);
}
[data-bs-theme=dark] .btn-ghost-primary {
    color: var(--tblr-primary);
}
[data-bs-theme=dark] .btn-ghost-success {
    color: var(--tblr-success-text-emphasis);
}
[data-bs-theme=dark] .btn-ghost-danger {
    color: var(--tblr-danger-text-emphasis);
}

/* ─── Dark mode: загальні виправлення ─── */
[data-bs-theme=dark] .flatpickr-day {
    color: var(--tblr-body-color);
}
[data-bs-theme=dark] .flatpickr-day:hover {
    background: var(--tblr-primary-lt);
    color: var(--tblr-primary);
}
[data-bs-theme=dark] .flatpickr-day.flatpickr-disabled,
[data-bs-theme=dark] .flatpickr-day.prevMonthDay,
[data-bs-theme=dark] .flatpickr-day.nextMonthDay {
    color: var(--tblr-secondary-color);
}
[data-bs-theme=dark] .numInputWrapper:hover,
[data-bs-theme=dark] .numInputWrapper input {
    background: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
}
[data-bs-theme=dark] .flatpickr-time input {
    background: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
}

/* ─── Dark mode: secondary/outline-secondary — читабельні в будь-якому стані ─── */
[data-bs-theme=dark] .btn-secondary,
[data-bs-theme=dark] .btn-outline-secondary {
    --tblr-btn-color: var(--tblr-body-color);
    --tblr-btn-border-color: var(--tblr-border-color);
    --tblr-btn-hover-color: var(--tblr-emphasis-color);
    --tblr-btn-hover-bg: var(--tblr-bg-surface-secondary);
    --tblr-btn-hover-border-color: var(--tblr-border-color);
    --tblr-btn-active-color: var(--tblr-emphasis-color);
    --tblr-btn-active-bg: var(--tblr-bg-surface-secondary);
    --tblr-btn-active-border-color: var(--tblr-border-color);
}
[data-bs-theme=dark] .btn-secondary {
    --tblr-btn-bg: var(--tblr-bg-surface);
}

/* ─── Dark mode: DataTables info/label кольори ─── */
[data-bs-theme=dark] div.dt-container div.dt-info {
    color: var(--tblr-secondary-color);
}

/* ─── Print ─── */
@media print {
    .navbar-vertical, header.navbar, #toast-container { display: none !important; }
    .page-wrapper { margin-left: 0 !important; }
}

/* ─── UA License Plate ─── */
.ua-plate {
    display: inline-flex;
    align-items: stretch;
    border: 1.5px solid #1a1a1a;
    border-radius: 3px;
    overflow: hidden;
    background: #fff;
    vertical-align: middle;
    box-shadow: 0 1px 3px rgba(0,0,0,.25), 0 0 0 .5px rgba(0,0,0,.1);
    white-space: nowrap;
    flex-shrink: 0;
    text-decoration: none;
    line-height: 1;
}
.ua-plate .ua-plate-eu {
    background: #003DA5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: .18rem .3rem;
    min-width: 1.4rem;
    gap: .08rem;
}
.ua-plate .ua-stars {
    color: #FFD700;
    font-size: .38rem;
    letter-spacing: -.5px;
    line-height: 1;
}
.ua-plate .ua-code {
    color: #fff;
    font-size: .52rem;
    font-weight: 900;
    letter-spacing: .08em;
    line-height: 1;
    font-family: Arial, sans-serif;
}
.ua-plate .ua-plate-num {
    padding: .22rem .5rem .22rem .4rem;
    color: #000;
    font-family: 'Arial Black', 'Franklin Gothic Heavy', Impact, Arial, sans-serif;
    font-weight: 900;
    font-size: .82rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
}
/* Розміри варіанти */
.ua-plate-lg .ua-plate-num { font-size: 1rem; padding: .3rem .65rem .3rem .5rem; }
.ua-plate-lg .ua-plate-eu  { min-width: 1.65rem; padding: .2rem .35rem; }
.ua-plate-lg .ua-stars     { font-size: .44rem; }
.ua-plate-lg .ua-code      { font-size: .6rem; }

/* ─── Dark mode: "dark" color variants → readable ─── */
[data-bs-theme=dark] .bg-dark-lt {
    background-color: rgba(255, 255, 255, .09) !important;
}
[data-bs-theme=dark] .text-dark {
    color: rgba(255, 255, 255, .8) !important;
}

/* ─── Offcanvas z-index ─── */
.offcanvas-backdrop { z-index: 1040; }
.offcanvas { z-index: 1050; }

/* ─── Search shortcuts hover ─── */
a.d-flex.align-items-center.border:hover {
    background-color: var(--tblr-bg-surface-secondary);
    border-color: var(--tblr-primary) !important;
    text-decoration: none;
}

/* ═══════════════════════════════════════════════
   NOTIFICATION DROPDOWN
   ═══════════════════════════════════════════════ */
.notif-dropdown {
    min-width: min(320px, calc(100vw - 1rem));
    max-width: min(360px, calc(100vw - 1rem));
}

/* ═══════════════════════════════════════════════
   SEARCH MODAL
   ═══════════════════════════════════════════════ */
.search-modal-dialog {
    margin-top: clamp(.5rem, 8vh, 80px);
}
@media (max-width: 767px) {
    .search-modal-dialog {
        margin: .5rem;
        max-width: calc(100vw - 1rem);
    }
    #searchResults { max-height: 55vh !important; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE / MOBILE
   ═══════════════════════════════════════════════ */

/* ── Offcanvas: cap width on small screens ── */
@media (max-width: 575px) {
    .offcanvas.offcanvas-end,
    .offcanvas.offcanvas-start { width: 100vw !important; }
}
@media (min-width: 576px) and (max-width: 767px) {
    .offcanvas.offcanvas-end,
    .offcanvas.offcanvas-start { width: min(480px, 95vw) !important; }
}

/* ── Sidebar collapsed: remove page-wrapper left space ── */
@media (max-width: 991px) {
    .page-wrapper { margin-left: 0 !important; }
    .page-body { padding-top: 1rem; padding-bottom: 1.25rem; }
}

/* ── Mobile topbar buttons inside sidebar header ── */
.mobile-topbar-btn {
    color: rgba(255, 255, 255, .75);
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--tblr-border-radius);
    font-size: 1.1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: none;
    flex-shrink: 0;
}
.mobile-topbar-btn:hover,
.mobile-topbar-btn:focus {
    color: #fff;
    background: rgba(255, 255, 255, .12);
    outline: none;
}

/* ── Notification dropdown: fixed position on mobile so it never clips ── */
@media (max-width: 767px) {
    .notif-dropdown {
        position: fixed !important;
        top: 3.5rem !important;
        inset-inline: .5rem !important;
        width: auto !important;
        min-width: unset !important;
        max-width: none !important;
        transform: none !important;
        margin: 0 !important;
    }
}

/* ── Mobile (<768px) ── */
@media (max-width: 767px) {
    /* Card/form padding */
    .card-body { padding: 1rem; }
    .card-header, .card-footer { padding: .75rem 1rem; }
    .p-6 { padding: 1rem !important; }
    .px-6 { padding-left: 1rem !important; padding-right: 1rem !important; }
    .py-6 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
    .p-4 { padding: 1rem !important; }

    /* Table cells */
    .table th, .table td {
        font-size: .8rem;
        padding: .5rem .625rem;
    }
    table.dataTable th:first-child,
    table.dataTable td:first-child { padding-inline: .75rem; }
    table.dataTable th:last-child,
    table.dataTable td:last-child { padding-inline-end: .75rem; }

    /* Action buttons in tables */
    .btn-sm.btn-icon { width: 1.75rem; height: 1.75rem; padding: .2rem; }

    /* DT toolbar — tighter */
    div.dt-container div.dt-length,
    div.dt-container div.dt-search { margin-block: .5rem; }

    /* Offcanvas sticky footer — readable on phone */
    .border-top.px-4.py-3 { padding: .75rem 1rem !important; }

    /* WorkOrders/Create form */
    .row.g-5 { --bs-gutter-y: 1rem; --bs-gutter-x: 1rem; }

    /* Form labels */
    .form-label { margin-bottom: .25rem; }

    /* Quick-create modal */
    .modal-dialog:not(.modal-dialog-centered) { margin: .75rem; max-width: calc(100vw - 1.5rem); }

    /* Full-width buttons inside cards */
    .card-body .btn { font-size: .875rem; }

    /* Stat number size */
    .card-body h4 { font-size: 1.25rem; }

    /* Avatar */
    .avatar { width: 2rem; height: 2rem; font-size: .75rem; line-height: 2rem; }
    .avatar-xs { width: 1.25rem; height: 1.25rem; font-size: .55rem; }

    /* Timeline — tighter on mobile */
    .timeline::before { left: .75rem; }
    .timeline-item { padding-left: 2.25rem; }
    .timeline-point { left: .125rem; }

    /* Page title in header */
    .page-pretitle { font-size: .6875rem; }
    .page-title { font-size: 1.1rem; }
}

/* ── Very small phones (<400px) ── */
@media (max-width: 400px) {
    .container-xl { padding-inline: .625rem; }
    .card { border-radius: var(--tblr-border-radius-lg) !important; }
    .page-body .row.g-3 { --bs-gutter-x: .625rem; --bs-gutter-y: .625rem; }
    .btn { padding: .375rem .625rem; }
    .btn-sm { padding: .2rem .4rem; font-size: .75rem; }
}

/* ── Sidebar mobile header polish ── */
@media (max-width: 991px) {
    /* Toggler more visible */
    .navbar-vertical .navbar-toggler {
        padding: .25rem .5rem;
        border-color: rgba(255,255,255,.25);
    }
    .navbar-vertical .navbar-toggler:focus { box-shadow: none; }

    /* Collapsed menu scroll */
    .navbar-vertical .navbar-collapse { max-height: calc(100vh - 4rem); overflow-y: auto; }

    /* Nav items: bigger tap targets */
    .navbar-vertical .nav-link { padding-top: .55rem; padding-bottom: .55rem; }
}

/* ── Таблиця горизонтальний скрол на мобільному ── */
@media (max-width: 767px) {
    .table-responsive { -webkit-overflow-scrolling: touch; }
    /* Prevent table from shrinking content too much */
    .table-responsive table { min-width: 480px; }
}

/* ═══════════════════════════════════════════════
   MOBILE TAB BAR
   ═══════════════════════════════════════════════ */
.mobile-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--tblr-bg-surface);
    border-top: 1px solid var(--tblr-border-color);
    z-index: 1030;
    align-items: center;
    justify-content: space-around;
    padding: 0 4px;
}
.mobile-tab-bar .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--tblr-secondary-color);
    text-decoration: none;
    cursor: pointer;
    padding: 4px 0;
    gap: 2px;
    border: none;
    background: none;
    position: relative;
}
.mobile-tab-bar .tab-item i { font-size: 1.2rem; }
.mobile-tab-bar .tab-item.active { color: var(--tblr-primary); }
.mobile-tab-bar .tab-item .tab-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 14px);
    min-width: 16px;
    height: 16px;
    background: var(--tblr-danger);
    color: #fff;
    border-radius: 8px;
    font-size: 9px;
    line-height: 16px;
    text-align: center;
    padding: 0 3px;
}
.mobile-tab-bar .tab-fab {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    background: var(--tblr-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(124, 58, 237, .45);
    text-decoration: none;
    border: none;
    cursor: pointer;
    margin-top: -8px;
    flex-shrink: 0;
    transition: transform .15s, box-shadow .15s;
}
.mobile-tab-bar .tab-fab:hover,
.mobile-tab-bar .tab-fab:focus {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(124, 58, 237, .55);
}

/* Page body bottom padding on mobile to clear tab bar */
@media (max-width: 767px) {
    .page-body { padding-bottom: 72px !important; }
}

/* ═══════════════════════════════════════════════
   MOBILE LIST CARDS
   ═══════════════════════════════════════════════ */
.mobile-list-card {
    display: block;
    padding: .75rem 1rem;
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius-lg);
    text-decoration: none;
    color: inherit;
    transition: background .12s, box-shadow .12s;
    position: relative;
    border-left-width: 3px;
}
.mobile-list-card:hover {
    background: var(--tblr-bg-surface-secondary);
    box-shadow: var(--tblr-box-shadow-sm);
    color: inherit;
    text-decoration: none;
}
.mobile-list-card-title { font-weight: 600; font-size: .9375rem; color: var(--tblr-body-color); }
.mobile-list-card-sub { font-size: .8125rem; color: var(--tblr-secondary-color); margin-top: .125rem; }
.mobile-list-card-meta { font-size: .75rem; color: var(--tblr-secondary-color); margin-top: .25rem; }

.filter-chips {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
    flex-shrink: 0;
    padding: .25rem .75rem;
    border-radius: 1rem;
    font-size: .8125rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    color: var(--tblr-secondary-color);
    white-space: nowrap;
    transition: background .12s, color .12s, border-color .12s;
}
.filter-chip.active {
    background: var(--tblr-primary-lt);
    border-color: var(--tblr-primary);
    color: var(--tblr-primary);
}

/* ─── Mobile offcanvas menu nav items ─── */
#mobileMenuOffcanvas .nav-link {
    color: var(--mecha-sidebar-text);
    border-radius: var(--tblr-border-radius);
    margin-inline: .25rem;
    padding-inline: .625rem;
    transition: background .15s, color .15s;
}
#mobileMenuOffcanvas .nav-item.active > .nav-link {
    background: linear-gradient(90deg, var(--mecha-sidebar-active-bg), transparent) !important;
    border-left: 2px solid var(--tblr-primary);
    color: #fff !important;
}
#mobileMenuOffcanvas .nav-link:hover:not(.active) {
    background: var(--mecha-sidebar-hover-bg);
    color: #fff;
    text-decoration: none;
}
#mobileMenuOffcanvas .nav-link-secondary .nav-link-title {
    color: var(--mecha-sidebar-group-color) !important;
}

/* ─── Sticky mobile action footer (detail pages) ─── */
.mobile-sticky-footer {
    position: fixed;
    bottom: 56px;
    left: 0; right: 0;
    background: var(--tblr-bg-surface);
    border-top: 1px solid var(--tblr-border-color);
    padding: .625rem 1rem;
    display: flex;
    gap: .5rem;
    z-index: 1020;
    box-shadow: 0 -2px 8px rgba(0,0,0,.06);
}
