:root {
    --sidebar-width: 250px;
    --primary-color: #d0d5dd;
    --primary-color-soft: rgba(208, 213, 221, 0.18);
    --glass-bg: rgba(22, 24, 28, 0.84);
    --glass-bg-strong: rgba(16, 18, 22, 0.92);
    --glass-border: rgba(255, 255, 255, 0.10);
    --glass-border-strong: rgba(255, 255, 255, 0.16);
    --surface-elevated: rgba(255, 255, 255, 0.03);
    --surface-shadow: 0 24px 60px rgba(0, 0, 0, 0.40);
    --surface-shadow-soft: 0 14px 30px rgba(0, 0, 0, 0.28);
}
body {
    background-color: #0b0c0f;
    background-image:
        radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.06) 0%, transparent 22%),
        radial-gradient(circle at 80% 18%, rgba(80, 84, 92, 0.24) 0%, transparent 28%),
        linear-gradient(180deg, #17191e 0%, #0d0f13 100%);
    background-attachment: fixed;
    color: #edf2f7;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    position: relative;
    overflow-x: hidden;
}
body::before,
body::after {
    content: none;
}
/* Bootstrap 5 Modal Fixes */
.modal {
    z-index: 1055 !important;
}
.modal-backdrop {
    z-index: 1050 !important;
}
body.modal-open {
    overflow: hidden !important;
    padding-right: 0 !important;
}

/* Fix Select2 height */
.select2-container .select2-selection--single {
    min-height: 38px;
    border: 1px solid var(--glass-border) !important;
    padding: 5px !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
    min-height: 36px;
}
.select2-container {
    width: 100% !important;
}
.select2-dropdown {
    z-index: 1070 !important;
}
.select2-container--open {
    z-index: 1070 !important;
}

#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: linear-gradient(180deg, rgba(18, 20, 24, 0.96), rgba(12, 14, 18, 0.94));
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03), 0 8px 30px rgba(0, 0, 0, 0.24);
    color: white;
    transition: left 0.3s ease;
    z-index: 1000;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 991.98px) {
    #sidebar {
        left: calc(-1 * var(--sidebar-width));
        z-index: 1040;
    }

    #content {
        margin-left: 0 !important;
    }

    #sidebar.active {
        left: 0;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        display: block;
        opacity: 0;
        pointer-events: none;
        background: rgba(7, 10, 14, 0.58);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        transition: opacity 0.2s ease;
        z-index: 1035;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}

#content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: all 0.3s;
}
#sidebar .nav-link {
    color: rgba(255,255,255,0.8);
    padding: 15px 20px;
}
#sidebar .nav-link:hover, #sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}
.card,
.glass-card,
.glass-panel,
.dropdown-menu,
.qr-popover,
.offcanvas,
.toast,
.alert,
.list-group,
.table-responsive {
    border: 1px solid var(--glass-border);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015)),
        rgba(14, 17, 48, 0.90);
    backdrop-filter: blur(18px) saturate(135%);
    -webkit-backdrop-filter: blur(18px) saturate(135%);
    box-shadow: var(--surface-shadow-soft);
    border-radius: 16px;
    color: #e2e8f0;
}
.card,
.glass-card,
.glass-panel {
    margin-bottom: 20px;
}
/* Glass effect specifically for large distinctive elements to avoid GPU lag */
.glass-card, .glass-panel {
    border: 1px solid var(--glass-border-strong);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.012)),
        rgba(13, 28, 20, 0.62);
    box-shadow:
        0 18px 42px rgba(0, 0, 0, 0.20),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    color: #e2e8f0;
}

.dashboard-main-row {
    align-items: flex-start;
}

.sidebar-brand {
    padding-top: 1.5rem;
    padding-bottom: 1rem;
}

.sidebar-logo {
    display: block;
    width: min(100%, 160px);
    max-height: 52px;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
}

.sidebar-brand-text {
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
}

.imei-check-card .form-control {
    min-width: 0;
}

.imei-check-result .alert {
    margin-bottom: 0;
}

.ifreeicloud-preview {
    max-width: 100%;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.ifreeicloud-preview img {
    display: block;
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    border-radius: 14px;
    object-fit: contain;
    filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.24));
}

.ifreeicloud-details {
    display: grid;
    gap: 8px;
}

.ifreeicloud-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.ifreeicloud-row strong {
    font-weight: 700;
}

.ifreeicloud-row--findmy,
.ifreeicloud-row--lostmode {
    font-weight: 800;
}

.ifreeicloud-row--yes {
    color: #ff5f6d;
    border-color: rgba(220, 53, 69, 0.28);
    background: rgba(220, 53, 69, 0.12);
}

.ifreeicloud-row--no {
    color: #43d17a;
    border-color: rgba(25, 135, 84, 0.28);
    background: rgba(25, 135, 84, 0.12);
}

.ifreeicloud-row--yes .ifreeicloud-value,
.ifreeicloud-row--no .ifreeicloud-value {
    font-weight: 800;
}

.dropdown-menu {
    z-index: 2005;
}

.table-responsive .dropdown-menu,
.modal .dropdown-menu {
    z-index: 3000;
}

.card-header,
.card-footer,
.modal-header,
.modal-footer {
    background: rgba(255, 255, 255, 0.02) !important;
    border-color: rgba(122, 136, 255, 0.08) !important;
}

.navbar {
    background: linear-gradient(180deg, rgba(18, 21, 58, 0.94), rgba(15, 18, 48, 0.90)) !important;
    backdrop-filter: blur(18px) saturate(130%);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
    border-bottom: 1px solid rgba(122, 136, 255, 0.08);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}
.table {
    color: #dbe4ee;
    border-collapse: separate;
    border-spacing: 0;
}
.table thead th {
    background: rgba(255,255,255,0.02);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    color: #98c89d;
    border-bottom: 1px solid rgba(119,214,124,0.08);
}
.table td {
    border-color: rgba(255,255,255,0.05);
}
.clickable-order-row {
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.clickable-order-row:hover > td {
    background-color: rgba(255, 255, 255, 0.05) !important;
}
.order-row--company > td {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(180, 186, 196, 0.04)),
        rgba(24, 26, 30, 0.92) !important;
    color: #eff3f8 !important;
    box-shadow: inset 3px 0 0 rgba(190, 196, 204, 0.30);
}
.order-row--company td { border-color: rgba(255, 255, 255, 0.06) !important; }
.order-row--company a,
.order-row--company small,
.order-row--company .text-white-75,
.order-row--company strong,
.order-row--company .badge {
    color: #eff3f8 !important;
}
.order-row--company .badge {
    border-color: rgba(255, 255, 255, 0.14) !important;
}
.order-row--high > td {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(210, 210, 210, 0.06)),
        rgba(28, 30, 34, 0.94) !important;
    color: #fffaf0 !important;
    box-shadow: inset 3px 0 0 rgba(214, 218, 224, 0.44);
}
.order-row--high td { border-color: rgba(255, 255, 255, 0.08) !important; }
.order-row--high a,
.order-row--high small,
.order-row--high .text-white-75,
.order-row--high strong,
.order-row--high .badge {
    color: #fffaf0 !important;
}
.order-row--high .badge {
    border-color: rgba(255, 255, 255, 0.18) !important;
}

/* Custom text class to replace low contrast text-white-50 */
.text-white-75 {
    color: rgba(255, 255, 255, 0.78) !important;
}

/* Fancybox dark theme fix */
.fancybox__backdrop {
    background: rgba(4, 10, 6, 0.84) !important;
}

.dropdown-menu,
.qr-popover,
.offcanvas,
.toast,
.alert,
.list-group,
.table-responsive {
    border: 1px solid var(--glass-border-strong);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
        rgba(12, 24, 18, 0.72);
    backdrop-filter: blur(18px) saturate(125%);
    -webkit-backdrop-filter: blur(18px) saturate(125%);
    box-shadow: var(--surface-shadow);
    border-radius: 14px;
}
.dropdown-menu,
.qr-popover {
    border-radius: 12px;
}

/* Pagination */
.pagination .page-link {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e2e8f0;
    font-weight: 500;
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}
.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}
.pagination .page-link:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Phone QR Popover */
.phone-qr-trigger:hover {
    color: var(--primary-color) !important;
    text-decoration: underline;
}
.qr-popover {
    position: fixed;
    border-radius: 16px;
    padding: 12px;
    z-index: 1045 !important;
    display: none;
    text-align: center;
    color: #e2e8f0;
}
.qr-popover #qrContainer { margin: 0 auto 8px; }
.qr-popover #qrContainer img { display: block; border-radius: 4px; }
.qr-popover .qr-phone-label { font-size: 12px; color: #94a3b8; margin-bottom: 4px; }
.qr-popover .qr-call-btn { display: inline-block; margin-top: 6px; font-size: 12px; }

/* SLA badges */
.sla-warning { background-color: rgba(255, 193, 7, 0.2) !important; }
.sla-danger { background-color: rgba(220, 53, 69, 0.2) !important; }

/* Customer option in Select2 */
.customer-option .meta { display: block; font-size: 12px; color: #94a3b8; }
.badge {
    font-weight: 500;
    padding: 0.52em 0.82em;
    border-radius: 999px;
    background-color: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
}
.status-new { color: #0d6efd; }
.status-progress { color: #fd7e14; }
.status-waiting { color: #6c757d; }
.status-completed { color: #198754; }
.status-collected { color: #0dcaf0; }

/* Select2 Dark Mode Override */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple,
.form-control,
.form-select,
.input-group-text {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #fff !important;
    backdrop-filter: blur(12px) saturate(135%);
    border-radius: 12px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered,
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    color: #fff !important;
}
.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}
.select2-dropdown {
    background-color: #1a1f24 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    backdrop-filter: blur(15px);
}
.select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}
.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff !important;
}
.select2-container--default .select2-results__option {
    color: #fff !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: rgba(255, 255, 255, 0.5) transparent transparent transparent !important;
}
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent rgba(255, 255, 255, 0.5) transparent !important;
}

/* Match highlighting in Select2 search results */
.select2-results__option .match {
    background: rgba(255, 255, 0, 0.2);
    color: #fff;
    padding: 0 2px;
    border-radius: 3px;
}
.select2-results__option--highlighted .match {
    background: rgba(255, 255, 255, 0.2);
    color: #fff !important;
}

/* Animations from view_order.php */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}
.animate-shake { animation: shake 0.6s ease-in-out; }

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}
.animate-pulse { animation: pulse 0.5s ease-in-out; }

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.animate-bounce { animation: bounce 1s ease-in-out infinite; }

/* Select2 Multiple dark theme fixes */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: rgba(13, 127, 242, 0.3) !important;
    border: 1px solid rgba(13, 127, 242, 0.5) !important;
    color: #fff !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #fff !important;
    border-right: 1px solid rgba(13, 127, 242, 0.5) !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    background-color: rgba(13, 127, 242, 0.5) !important;
    color: #fff !important;
}

/* Inventory button styles */
.btn-white { background: white; }
.ring-2 { box-shadow: 0 0 0 2px currentColor; }

/* Glow badge variants */
.bg-success-glow {
    background-color: rgba(25, 135, 84, 0.25) !important;
    color: #75b798 !important;
    box-shadow: 0 0 8px rgba(25, 135, 84, 0.4);
}
.bg-info-glow {
    background-color: rgba(13, 202, 240, 0.25) !important;
    color: #6edff6 !important;
    box-shadow: 0 0 8px rgba(13, 202, 240, 0.4);
}

/* ------------------------------------------------------------------
   Modern dashboard surface overhaul
   ------------------------------------------------------------------ */
#content {
    padding: 28px;
}

.navbar {
    max-width: calc(100% - 8px);
    margin: 0 auto 24px;
    padding: 10px 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(34, 36, 42, 0.88), rgba(20, 22, 28, 0.84)) !important;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 18px 44px rgba(0, 0, 0, 0.34);
}

.card,
.glass-card,
.glass-panel,
.dropdown-menu,
.qr-popover,
.offcanvas,
.toast,
.alert,
.list-group,
.table-responsive {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
        linear-gradient(135deg, rgba(28, 30, 36, 0.50), rgba(14, 16, 20, 0.58));
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
    border-radius: 18px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        inset 0 -1px 0 rgba(255, 255, 255, 0.015),
        0 20px 48px rgba(0, 0, 0, 0.28);
}

.modal-content {
    border: 1px solid var(--glass-border);
    background: rgba(25, 30, 36, 0.96);
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    color: #e2e8f0;
}

.card::before,
.glass-card::before,
.glass-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.06) 0%, transparent 24%),
        radial-gradient(circle at 85% 88%, rgba(255, 255, 255, 0.03) 0%, transparent 24%);
    opacity: 0.7;
}

.card-header,
.card-footer,
.modal-header,
.modal-footer {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.025) !important;
    border-color: rgba(151, 162, 255, 0.10) !important;
}

.card-body,
.table-responsive > table,
.modal-body {
    position: relative;
    z-index: 1;
}


.table-responsive {
    padding: 8px 10px;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: transparent;
    color: #98a4da;
    border-bottom: 1px solid rgba(151, 162, 255, 0.10);
}

.table tbody tr > td {
    background: transparent;
}

.btn,
.btn-primary,
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-light,
.btn-secondary {
    border-radius: 999px;
    border-color: rgba(151, 162, 255, 0.16);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.btn-primary {
    background: linear-gradient(135deg, #f5f5f7, #cfd4dc) !important;
    border-color: rgba(255, 255, 255, 0.24) !important;
    color: #111318 !important;
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-light {
    background: rgba(255, 255, 255, 0.04);
}

.form-control,
.form-select,
.input-group-text,
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    min-height: 46px;
    background: rgba(255, 255, 255, 0.028) !important;
    border: 1px solid rgba(149, 232, 153, 0.12) !important;
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.badge {
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(151, 162, 255, 0.14);
}

.row > [class*='col-'] > .card,
.row > [class*='col-'] > .glass-card,
.row > [class*='col-'] > .glass-panel {
    height: 100%;
}

/* Settings > Integrace: webhook status nesmí překrývat tlačítko Uložit */
.settings-integrations-row {
    align-items: flex-start;
}

.settings-integrations-row .webhook-status-panel {
    height: auto !important;
    min-height: 0;
}

.settings-integrations-row .webhook-status-panel .text-break {
    overflow-wrap: anywhere;
}

.settings-integrations-row > .integrations-save-row {
    position: relative;
    z-index: 2;
}

.order-row--company > td,
.order-row--high > td {
    backdrop-filter: blur(10px);
}



/* Dashboard stat cards: tighter top-row layout */
#content .row.g-4.mb-4 .card.glass-card.p-3.h-100 {
    margin-bottom: 0;
}
#content .row.g-4.mb-4 > [class*="col-"] {
    padding-left: 8px;
    padding-right: 8px;
}
#content .row.g-4.mb-4 {
    margin-left: -8px;
    margin-right: -8px;
}

/* Edit order: force readable native select dropdown options */
.edit-order-form .form-select option,
.edit-order-form .form-select optgroup,
#editOrderFullModal .form-select option,
#editOrderFullModal .form-select optgroup,
#quickOrderModal .form-select option,
#quickOrderModal .form-select optgroup {
    color: #111318 !important;
    background-color: #ffffff !important;
}

/* Keep dropdowns usable inside redesigned table wrappers */
.table-responsive {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.table-responsive .dropdown-menu,
.card .dropdown-menu,
.glass-card .dropdown-menu,
.glass-panel .dropdown-menu {
    z-index: 3000;
}

@media (max-width: 991.98px) {
    .table-responsive[style*="overflow-y: auto"] {
        max-height: none !important;
        overflow-y: visible !important;
    }

    .crm-topbar .crm-topbar-inner {
        flex-wrap: wrap;
        row-gap: 10px;
    }

    .crm-topbar .crm-topbar-left {
        order: 1;
    }

    .crm-topbar .crm-navbar-actions {
        order: 2;
        margin-left: auto;
        min-width: 0;
        gap: 0.35rem;
    }

    .crm-topbar .crm-navbar-search {
        order: 3;
        margin: 0 !important;
        flex: 1 0 100%;
        max-width: 100% !important;
    }

    .crm-topbar .crm-navbar-search--placeholder {
        display: none;
    }

    .crm-topbar .crm-role-badge,
    .crm-topbar .crm-user-name {
        display: none;
    }

    .crm-topbar .crm-lang-switch {
        min-width: 68px;
    }

    #content {
        padding: 14px;
    }
}
