/* شكل السايدبار — قائمة السيارات عائمة على الجانب الأيسر */
#sidebar {
    /* مثبّتة من الأعلى تحت الهيدر بارتفاع محدّد يضمن ظهور كل السيارات مع تمرير */
    left: 16px;
    top: 58px;
    bottom: auto;
    height: calc(100vh - 82px);
    max-height: calc(100vh - 82px);
    /* flex عمودي: يوزّع الارتفاع المحدّد على المحتوى فيعمل التمرير */
    display: flex;
    flex-direction: column;
    /* تدوير كل الزوايا + ظل عائم واضح */
    border-radius: 20px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(220, 226, 223, 0.6);
    transition: height 0.3s ease, max-height 0.3s ease;
}

/* عند فتح لوحة السجل السفلية: قصّر السايدبار فوقها عشان مفيش جزء يتغطى */
body.history-bottom-open #sidebar {
    height: calc(100vh - 58px - var(--bottom-history-height, 0px) - 12px);
    max-height: calc(100vh - 58px - var(--bottom-history-height, 0px) - 12px);
}

/* رفع أزرار التنبيهات/السماعة/المساعد فوق لوحة السجل */
body.history-bottom-open .notifications-fab,
body.history-bottom-open .amni-sound-fab,
body.history-bottom-open .ai-agent-fab-wrap {
    transition: bottom 0.3s ease;
}

/* محتوى القائمة يتبع زوايا البطاقة العائمة ويملأ ارتفاعها */
#sidebar .sidebar-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    overflow: hidden;
    border-right: none;
}
/* شريط التبويبات ثابت أعلى البطاقة */
#sidebar .sidebar-content > .nav-tabs {
    flex: 0 0 auto;
}
/* حاوية التبويبات تملأ باقي ارتفاع البطاقة */
#sidebar .sidebar-content > .tab-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
/* التبويب النشط يملأ حاوية التبويبات (لتمرير القائمة عند كثرة العناصر) */
#sidebar .sidebar-content > .tab-content > .tab-pane.active {
    flex: 1 1 auto;
    min-height: 0;
}

/* زر الطي — شكل جديد على هيئة قبضة عائمة خضراء */
#sidebar .btn-collapse {
    background: linear-gradient(135deg, #12a56d 0%, #0b7a52 100%);
    border: none;
    box-shadow: 0 6px 16px rgba(15, 138, 92, 0.35);
    width: 24px;
    height: 64px;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: all 0.25s ease;
    z-index: 1000;
}
#sidebar .btn-collapse:hover {
    transform: translateY(-50%) scale(1.06);
    box-shadow: 0 8px 22px rgba(15, 138, 92, 0.45);
}

/* إخفاء المثلثات الافتراضية للحصول على شكل نظيف */
#sidebar .btn-collapse:before,
#sidebar .btn-collapse:after {
    display: none !important;
}

/* سهم أبيض واضح داخل الزر */
#sidebar .btn-collapse i,
#sidebar .btn-collapse i:before {
    color: #fff;
    border: none !important;
    font-size: 12px;
}

/* أنميشن القوائم والسايدبار */
#sidebar {
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* أنميشن التبويبات (Tabs) لكافة النظام */
.nav-tabs > li > a {
    transition: all 0.3s ease !important;
}
.nav-tabs > li > a:hover {
    transform: translateY(-2px);
}

/* تعميم الأنميشن على كافة عناصر القوائم والجداول في السيستم */
.table tbody tr, .list-group-item {
    transition: all 0.25s ease-in-out;
}
.table-list tbody tr:hover, .list-group-item:hover {
    transform: translateX(4px);
    background-color: rgba(240, 240, 240, 0.6);
    box-shadow: -3px 0px 8px rgba(0,0,0,0.04);
}

/* أنميشن الأزرار كافة في السيستم (Buttons) */
button, .btn {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}
button:hover, .btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

/* أنميشن حقول الإدخال (Inputs) */
.form-control {
    transition: all 0.3s ease;
}
.form-control:focus {
    transform: scale(1.01);
    box-shadow: 0 4px 15px rgba(11, 163, 96, 0.15) !important;
}

/* أنميشن القوائم المنسدلة (Dropdowns) */
.dropdown-menu {
    animation: fadeInDown 0.3s ease forwards;
    transform-origin: top;
}

/* أنميشن القوائم الفرعية المتفرعة (Sub-menus) لتخرج من الجنب بسلاسة */
.dropdown-submenu > .dropdown-menu {
    animation: slideOutSide 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards !important;
    transform-origin: left;
}

@keyframes slideOutSide {
    from {
        opacity: 0;
        transform: translateX(-15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px) scaleY(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scaleY(1);
    }
}

/* أنميشن النوافذ المنبثقة (Modals & Popups) لكل السيستم */
.modal.fade .modal-content {
    animation: modalSlideUp 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* إشعارات toastr: أسفل يمين فوق الزر العائم */
#toast-container.toast-bottom-right {
    right: 20px;
    bottom: 92px;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}
#toast-container.toast-bottom-right.is-collapsed {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(12px);
}
/* إشعارات toastr — أخضر متناسق مع المنصة */
#toast-container > div {
    border-color: #d4e8de !important;
    box-shadow: 0 4px 20px rgba(15, 90, 60, 0.08) !important;
}
#toast-container > div:hover {
    box-shadow: 0 6px 24px rgba(15, 90, 60, 0.11) !important;
}
#toast-container > .toast-info,
#toast-container > div.toast-info,
.toast-info {
    border-left-color: #0f8a5c !important;
    background-color: #f4fbf7 !important;
}
#toast-container > .toast-success,
#toast-container > div.toast-success,
.toast-success {
    border-left-color: #148a5e !important;
    background-color: #f2faf5 !important;
}
#toast-container > .toast-warning,
#toast-container > div.toast-warning,
.toast-warning {
    border-left-color: #a67c14 !important;
    background-color: #fffdf6 !important;
}
#toast-container > .toast-error,
#toast-container > div.toast-error,
.toast-error {
    border-left-color: #c75c5c !important;
    background-color: #fdf8f8 !important;
}
#toast-container .toast-title {
    color: #153b28 !important;
}
#toast-container .toast-message {
    color: #3d5248 !important;
}
#toast-container .toast-message a,
#toast-container .toast-message label {
    color: #0b7a52 !important;
}
#toast-container .toast-message a:hover {
    color: #095c3e !important;
}
#toast-container .toast-close-button {
    color: #6b8578 !important;
}
#toast-container .toast-close-button:hover {
    color: #153b28 !important;
}
.toast {
    border-left-color: #5a7a68 !important;
}
:root {
    --map-fab-size: 48px;
    --map-fab-gap: 12px;
    --map-fab-right: 20px;
    --map-fab-bottom: 20px;
    --map-fab-inline-end: 20px;
}
.notifications-fab {
    position: fixed;
    right: auto;
    inset-inline-end: var(--map-fab-inline-end, var(--map-fab-right));
    bottom: var(--map-fab-bottom);
    z-index: 1098;
    width: var(--map-fab-size);
    height: var(--map-fab-size);
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #0f8a5c;
    color: #fff;
    box-shadow: 0 6px 20px rgba(15, 138, 92, 0.28);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, inset-inline-end 0.25s ease;
}
.notifications-fab:hover,
.notifications-fab:focus {
    background: #0c6e48;
    box-shadow: 0 8px 26px rgba(15, 138, 92, 0.35);
    transform: scale(1.04);
    outline: none;
}
.notifications-fab:active {
    transform: scale(0.98);
}
.notifications-fab .icon {
    font-size: 20px;
    line-height: 1;
    color: #fff;
}
.notifications-fab .icon::before {
    color: #fff;
}
.notifications-fab .notifications-fab__badge {
    display: none;
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #c75c5c;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.amni-sound-fab {
    position: fixed;
    right: auto;
    inset-inline-end: var(--map-fab-inline-end, var(--map-fab-right));
    bottom: var(--map-fab-bottom);
    z-index: 1098;
    width: var(--map-fab-size);
    height: var(--map-fab-size);
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 50%;
    background: #0f8a5c;
    color: #fff;
    box-shadow: 0 6px 20px rgba(15, 138, 92, 0.28);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, inset-inline-end 0.25s ease, bottom 0.25s ease;
}
.amni-sound-fab:hover,
.amni-sound-fab:focus {
    background: #0c6e48;
    box-shadow: 0 8px 26px rgba(15, 138, 92, 0.35);
    transform: scale(1.04);
    outline: none;
}
.amni-sound-fab:active {
    transform: scale(0.98);
}
.amni-sound-fab.is-muted {
    opacity: 0.85;
}
.amni-sound-fab.is-disabled {
    cursor: not-allowed;
    opacity: 0.65;
    transform: none;
}
.amni-sound-fab .icon.alert-speech-icon {
    position: relative;
    width: auto;
    height: auto;
    background: transparent;
    color: inherit;
    line-height: 1;
}
.amni-sound-fab .icon.alert-speech-icon .fa {
    font-size: 20px;
    line-height: 1;
    color: inherit;
}
/* بطاقة حدث — تنسيق نص واضح ومربعات متناسقة */
.events-item-card {
    display: block;
    text-align: inherit;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.events-item-card__top {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 32px;
    padding: 0;
}
.events-item-glyph {
    box-sizing: border-box;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    margin-top: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(27, 153, 189, 0.11);
    color: #1b99bd;
    font-size: 14px;
    line-height: 1;
    box-shadow: inset 0 0 0 1px rgba(27, 153, 189, 0.12);
}
.events-item-glyph .icon {
    line-height: 1;
}
.events-item-glyph .icon::before {
    color: inherit;
}
.events-item-glyph--overspeed { background: rgba(196, 160, 53, 0.14); color: #8a6f0f; box-shadow: inset 0 0 0 1px rgba(196, 160, 53, 0.2); }
.events-item-glyph--sos { background: rgba(199, 92, 92, 0.14); color: #b54545; box-shadow: inset 0 0 0 1px rgba(199, 92, 92, 0.22); }
.events-item-glyph--zone_in,
.events-item-glyph--zone_out { background: rgba(42, 157, 143, 0.12); color: #1f6b60; box-shadow: inset 0 0 0 1px rgba(42, 157, 143, 0.2); }
.events-item-glyph--fuel_fill { background: rgba(42, 157, 143, 0.12); color: #1a6b5e; box-shadow: inset 0 0 0 1px rgba(42, 157, 143, 0.18); }
.events-item-glyph--fuel_theft { background: rgba(199, 92, 92, 0.14); color: #a33d3d; box-shadow: inset 0 0 0 1px rgba(199, 92, 92, 0.2); }
.events-item-glyph--ignition_on,
.events-item-glyph--ignition_off,
.events-item-glyph--move_start { background: rgba(81, 96, 112, 0.1); color: #45505c; box-shadow: inset 0 0 0 1px rgba(81, 96, 112, 0.15); }
.events-item-glyph--offline_duration { background: rgba(119, 119, 119, 0.1); color: #555555; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); }
.events-item-glyph--stop_duration,
.events-item-glyph--idle_duration,
.events-item-glyph--ignition_duration,
.events-item-glyph--time_duration { background: rgba(27, 153, 189, 0.1); color: #157fa1; box-shadow: inset 0 0 0 1px rgba(27, 153, 189, 0.15); }
.events-item-glyph--distance { background: rgba(107, 124, 143, 0.1); color: #3d4a57; box-shadow: inset 0 0 0 1px rgba(107, 124, 143, 0.15); }
.events-item-glyph--task_new,
.events-item-glyph--task_complete,
.events-item-glyph--task_failed,
.events-item-glyph--task_in_progress,
.events-item-glyph--poi_stop_duration,
.events-item-glyph--poi_idle_duration { background: rgba(27, 153, 189, 0.08); color: #136d88; box-shadow: inset 0 0 0 1px rgba(27, 153, 189, 0.12); }
.events-item-glyph--driver_unauthorized { background: rgba(199, 92, 92, 0.12); color: #a84040; box-shadow: inset 0 0 0 1px rgba(199, 92, 92, 0.18); }
.events-item-glyph--custom { background: rgba(90, 105, 120, 0.1); color: #4a5664; box-shadow: inset 0 0 0 1px rgba(90, 105, 120, 0.12); }
.events-item-card__meta {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 11px;
    line-height: 1.35;
    padding-top: 0;
}
.events-item-card__meta .datetime {
    flex: 0 1 auto;
    min-width: 0;
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px 6px;
}
.events-item-card__meta .datetime .time {
    font-weight: 600;
    font-size: 11px;
    color: #202020;
    letter-spacing: 0.01em;
}
.events-item-card__meta .datetime .date {
    color: #777777;
    font-size: 10px;
    font-weight: 400;
    white-space: nowrap;
}
.events-item-card__sep {
    flex: 0 0 auto;
    color: #d0d0d0;
    font-weight: 700;
    font-size: 10px;
    line-height: 1;
    user-select: none;
    transform: translateY(-1px);
}
.events-item-card__device {
    flex: 1 1 120px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    font-size: 11px;
    color: #136d88;
    letter-spacing: 0.01em;
}
.events-item-card__title {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: #f6f8fa;
    border: 1px solid #eceef0;
    font-size: 12px;
    line-height: 1.45;
    color: #333333;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    hyphens: auto;
}
.events-item-card__extra {
    margin-top: 8px;
    margin-left: 0;
    margin-right: 0;
}
.events-item-card__extra.row {
    margin-left: 0 !important;
    margin-right: 0 !important;
}
.events-item-card__extra .col-sm-12 {
    padding-left: 0;
    padding-right: 0;
    padding-top: 8px;
    margin-top: 0;
    border-top: 1px solid #e9e9e9;
    font-size: 10px;
    line-height: 1.4;
    color: #666666;
}
.events-item-card__extra .col-sm-12:empty {
    display: none;
}
/* لوحة أحداث عائمة — ألوان ومسافات متوافقة مع المنصة */
/* transform يفسد position:fixed لقوائم data-position="fixed" داخل اللوحة */
.events-float-panel {
    position: fixed;
    bottom: 88px;
    right: 20px;
    width: 336px;
    max-width: calc(100vw - 32px);
    height: min(500px, calc(100vh - 120px));
    background: #f9f9f9;
    border-radius: 12px;
    box-shadow:
        0 8px 28px rgba(32, 32, 32, 0.1),
        0 0 0 1px #d9d9d9;
    display: flex;
    flex-direction: column;
    overflow: visible;
    z-index: 9998;
    font-family: inherit;
    font-size: 12px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 0.28s ease, visibility 0.28s ease, transform 0.28s ease;
}
.events-float-panel.events-float-panel--open {
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}
.events-float-panel__header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #0f8a5c;
    color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.events-float-panel__title {
    font-size: 13px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.01em;
}
.events-float-panel__close {
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}
.events-float-panel__close:hover {
    background: rgba(255, 255, 255, 0.28);
}
.events-float-panel__toolbar {
    flex-shrink: 0;
    padding: 8px 10px;
    background: #ffffff;
    border-bottom: 1px solid #e9e9e9;
}
.events-float-panel__toolbar .input-group {
    width: 100%;
}
.events-float-panel__toolbar .form-group {
    margin-bottom: 0;
}
.events-float-panel__toolbar .form-control {
    font-size: 12px;
    height: 30px;
    padding: 6px 10px;
    border-color: #d9d9d9;
}
.events-float-panel__toolbar .btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-color: #d9d9d9;
    background: #f9f9f9;
    color: #555555;
}
.events-float-panel__toolbar .btn-sm:hover {
    background: #eeeeee;
    border-color: #cccccc;
    color: #202020;
}
.events-float-panel__body {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px;
    background: #f9f9f9;
    border-radius: 0 0 12px 12px;
    -webkit-overflow-scrolling: touch;
}
/* قائمة خيارات الحدث فوق البطاقات المجاورة */
.events-float-panel__body .btn-group.open,
#ajax-events .btn-group.open {
    z-index: 10060;
}
.events-float-panel__body .btn-group.open .dropdown-menu,
#ajax-events .btn-group.open .dropdown-menu {
    z-index: 10061;
}
/* بطاقات حدث — مدمجة ومتناسقة */
.events-float-panel__body table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}
.events-float-panel__body thead {
    display: none;
}
.events-float-panel__body tbody {
    display: block;
}
.events-float-panel__body tbody tr,
#ajax-events tbody tr {
    margin-bottom: 10px;
    min-height: 0;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e4e6ea;
    box-shadow: 0 1px 2px rgba(32, 32, 32, 0.04);
    cursor: pointer;
    position: relative;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
/* صف حدث: عمود للمحتوى + عمود للقائمة — محاذاة أعلى الصف (لا يُنزل الزر) */
.events-float-panel__body tbody tr[data-event-id],
#ajax-events tbody tr[data-event-id] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) min-content;
    align-items: start;
    column-gap: 8px;
    row-gap: 0;
    padding: 10px 12px;
}
.events-float-panel__body tbody tr:not([data-event-id]),
#ajax-events tbody tr:not([data-event-id]) {
    display: block;
    padding: 11px 12px;
}
.events-float-panel__body tbody tr:hover,
#ajax-events tbody tr:hover {
    border-color: #d0d4db;
    box-shadow: 0 3px 10px rgba(32, 32, 32, 0.06);
}
.events-float-panel__body tbody tr td,
#ajax-events tbody tr td {
    display: block;
    border: none;
    padding: 0;
}
.events-float-panel__body tbody tr:not([data-event-id]) td,
#ajax-events tbody tr:not([data-event-id]) td {
    width: 100% !important;
}
.events-float-panel__body tbody tr[data-event-id] td:first-child,
#ajax-events tbody tr[data-event-id] td:first-child {
    width: auto !important;
    max-width: 100%;
    min-width: 0;
    grid-column: 1;
}
.events-float-panel__body tbody tr[data-event-id] td:last-child,
#ajax-events tbody tr[data-event-id] td:last-child {
    position: static !important;
    width: auto !important;
    grid-column: 2;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 0 !important;
    margin: 0;
    /* محاذاة مع سطر الأيقونة والوقت (grid + flex-start) */
    padding-top: 0;
}
.events-float-panel__body tbody tr[data-event-id] td:last-child .btn-group,
#ajax-events tbody tr[data-event-id] td:last-child .btn-group {
    margin: 0;
}
.events-float-panel__body tbody tr[data-event-id] td:last-child .btn.icon,
#ajax-events tbody tr[data-event-id] td:last-child .btn.icon {
    margin: 0;
    padding: 4px;
    line-height: 1;
}
.events-float-panel__body tbody tr td:last-child .btn-group .btn.icon,
.events-float-panel__body tbody tr td:last-child .btn-group > .icon,
#ajax-events tbody tr td:last-child .btn-group .btn.icon,
#ajax-events tbody tr td:last-child .btn-group > .icon {
    opacity: 0.75;
}
.events-float-panel__body tbody tr td:last-child .btn-group:hover .btn.icon,
.events-float-panel__body tbody tr td:last-child .btn-group:hover > .icon,
#ajax-events tbody tr td:last-child .btn-group:hover .btn.icon,
#ajax-events tbody tr td:last-child .btn-group:hover > .icon {
    opacity: 1;
}
.events-float-panel__body tbody tr td.no-data,
#ajax-events tbody tr td.no-data {
    position: static !important;
    width: 100% !important;
}
.events-float-panel__body tbody tr[data-toggle="scroll"],
#ajax-events tbody tr[data-toggle="scroll"] {
    padding: 8px;
    min-height: 20px;
    background: transparent;
    box-shadow: none;
    border: none;
    cursor: default;
}
.events-float-panel__body tbody tr .no-data,
#ajax-events tbody tr .no-data {
    padding: 20px 14px;
    text-align: center;
    color: #777777;
    font-size: 12px;
    line-height: 1.45;
    cursor: default;
}
@media (max-width: 480px) {
    .events-float-panel {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 80px;
        height: min(460px, calc(100vh - 100px));
    }
}

/* علامة موقع الحدث المختار على الخريطة */
.leaflet-event-highlight-marker-wrapper {
    background: transparent !important;
    border: none !important;
}
@keyframes leaflet-event-highlight-pulse {
    0% {
        transform: scale(0.9);
        opacity: 0.9;
    }
    70% {
        transform: scale(1.85);
        opacity: 0;
    }
    100% {
        opacity: 0;
    }
}
.leaflet-event-highlight-marker {
    width: 18px;
    height: 18px;
    margin: 9px;
    border-radius: 50%;
    background: #0f8a5c;
    border: 3px solid #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    position: relative;
}
.leaflet-event-highlight-marker::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border-radius: 50%;
    border: 2px solid #0f8a5c;
    box-sizing: border-box;
    animation: leaflet-event-highlight-pulse 1.4s ease-out infinite;
    pointer-events: none;
}

/* تبويب السيارات: بحث + إحصائيات ثابتة + قائمة قابلة للتمرير */
#sidebar #objects_tab.active {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
/* تبويب السجل: نفس توزيع الارتفاع عشان القائمة تتمرر فوق اللوحة السفلية */
#sidebar #history_tab.active {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#sidebar #history_tab > .tab-pane-header {
    flex: 0 0 auto;
}
#sidebar #history_tab > .tab-pane-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
#sidebar #objects_tab > .tab-pane-header {
    flex: 0 0 auto;
}
#sidebar #objects_tab > #objects-sidebar-stats {
    flex: 0 0 auto;
    margin: 0 8px 6px;
    width: auto;
    max-width: none;
}
#sidebar #objects_tab > .tab-pane-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 0;
}
/* القائمة تملأ المساحة بالـ flex (بدون height:100% حتى لا تنهار داخل flex) وتعمل تمرير */
#sidebar #objects_tab .tab-pane-body #ajax-items {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
#sidebar #objects_tab #ajax-items .group {
    display: block;
}
#sidebar #objects_tab #ajax-items .group-heading {
    display: table;
    width: 100%;
}
#sidebar #objects_tab #ajax-items .group-list {
    display: block;
}
#sidebar #objects_tab #ajax-items .group-list > li {
    display: block;
}

/* حجم خط قائمة السيارات على الجانب الأيسر */
#sidebar #objects_tab .vehicle-list-item > .name > [data-device="name"],
#sidebar #objects_tab .vehicle-list-item__name {
    font-size: 12px;
    line-height: 1.3;
}
#sidebar #objects_tab .vehicle-list-item__speed,
#sidebar #objects_tab .vehicle-list-item__speed-compact {
    font-size: 11px;
}
#sidebar #objects_tab .vehicle-list-item__time-compact,
#sidebar #objects_tab .vehicle-list-item__time,
#sidebar #objects_tab .vehicle-list-item__status-label {
    font-size: 10px;
}
#sidebar #objects_tab #ajax-items .group-title {
    font-size: 13px;
}
#sidebar .nav-tabs > li > a {
    font-size: 14px;
}

/* Device terminal modal */
#device_terminal .modal-dialog.modal-terminal {
    width: 680px;
    max-width: calc(100vw - 24px);
    margin: 24px auto;
}
#device_terminal .modal-content {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #dce3df;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}
#device_terminal .modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid #e8ecea;
    background: #fff;
}
#device_terminal .modal-header .modal-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    padding-right: 28px;
}
#device_terminal .modal-body {
    padding: 0;
    background: #fff;
}
#device_terminal .modal-body > .nav {
    margin: 0;
    padding: 0 16px;
    border-bottom: 1px solid #e8ecea;
    background: #fafbfa;
}
#device_terminal .modal-body > .nav > li > a {
    border-radius: 0;
    padding: 11px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #5f6b66;
    border: none;
    margin-bottom: -1px;
}
#device_terminal .modal-body > .nav > li.active > a,
#device_terminal .modal-body > .nav > li.active > a:hover,
#device_terminal .modal-body > .nav > li.active > a:focus {
    color: #12a56d;
    background: #fff;
    border: none;
    border-bottom: 2px solid #12a56d;
}
.device-terminal-tab-content {
    padding: 16px;
}
#device-terminal-feed.tab-pane.active {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.device-terminal-command-bar {
    flex: 0 0 auto;
}
.device-terminal-command-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2f3a35;
}
.device-terminal-command-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}
.device-terminal-command-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 38px;
    border-radius: 8px;
    border: 1px solid #d5ddd8;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    box-shadow: none;
}
.device-terminal-command-input:focus {
    border-color: #12a56d;
    box-shadow: 0 0 0 2px rgba(18, 165, 109, 0.12);
}
.device-terminal-send-btn {
    flex: 0 0 auto;
    min-width: 84px;
    height: 38px;
    border-radius: 8px;
    font-weight: 600;
}
.device-terminal-options-btn {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.device-terminal-alert {
    margin-top: 8px;
    margin-bottom: 0;
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 8px;
}
.cli-wrapper {
    width: 100%;
    flex: 1 1 auto;
    background: #141414;
    border-radius: 10px;
    border: 1px solid #2a2a2a;
    overflow: hidden;
    box-sizing: border-box;
}
.cli {
    width: 100%;
    height: 400px;
    min-height: 400px;
    max-height: 400px;
    overflow: auto;
    padding: 12px 14px;
    box-sizing: border-box;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #d4d4d4;
    white-space: normal;
    word-break: normal;
}
.cli-entry {
    display: block;
    width: 100%;
}
.cli-section {
    margin: 8px 0 4px;
    font-size: 11px;
}
.cli-row {
    display: block;
    width: 100%;
    white-space: nowrap;
    overflow-x: auto;
    padding: 1px 0;
    scrollbar-width: thin;
}
.cli-row--indent {
    padding-left: 16px;
}
.cli-row--indent-1 {
    padding-left: 16px;
}
.cli .feed.green {
    color: #7ec699;
}
.cli .feed.gray {
    color: #80868b;
}
.cli .feed.val {
    color: #c5c8c6;
}
.device-terminal-queue-empty {
    padding: 24px 0;
    text-align: center;
}
#device_terminal .modal-footer {
    padding: 10px 16px;
    border-top: 1px solid #e8ecea;
    background: #fafbfa;
}
@media (max-width: 720px) {
    #device_terminal .modal-dialog.modal-terminal {
        width: auto;
        margin: 12px;
    }
    .cli {
        height: 52vh;
        min-height: 280px;
        max-height: 52vh;
    }
}

/* Fixed viewport dropdowns (device options, etc.) above map controls */
.btn-group[data-position="fixed"].open > .dropdown-menu {
    z-index: 10050 !important;
}

#sidebar:has(.btn-group.open[data-position="fixed"]) {
    z-index: 1100;
}

/* Don't clip device options menu inside card rows */
.group-list > li.vehicle-list-item:has(.btn-group.open) {
    overflow: visible;
    z-index: 10049;
}

.group-list > li.vehicle-list-item .btn-group.open {
    z-index: 10050;
}

/* Map layers button — open picker to the right (away from vehicle sidebar on the left) */
#map-controls {
    z-index: 1000 !important;
}

#map-controls .leaflet-control-layers > .leaflet-control-layers-list,
#map-controls .leaflet-control-layers.leaflet-control-layers-expanded > .leaflet-control-layers-list {
    left: 100% !important;
    right: auto !important;
    top: -9px !important;
    margin-left: 8px !important;
    margin-right: 0 !important;
    z-index: 1001 !important;
}

#map-controls .leaflet-control-layers > .leaflet-control-layers-list:before {
    top: 9px !important;
    left: -8px !important;
    right: auto !important;
    border: 8px solid transparent !important;
    border-right-color: #d9d9d9 !important;
    border-left: 0 !important;
    bottom: auto !important;
}

#map-controls .leaflet-control-layers > .leaflet-control-layers-list:after {
    top: 10px !important;
    left: -7px !important;
    right: auto !important;
    border: 7px solid transparent !important;
    border-right-color: #ffffff !important;
    border-left: 0 !important;
    bottom: auto !important;
}
