/**
 * Modern Table Styles for Security Module
 * Consistent, clean, and professional table design
 */

/* Modern table container */
.modern-table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: visible !important;
    margin-top: 20px;
    position: relative;
}

/* Modern table base styles */
.table.modern-table {
    margin-bottom: 0;
    background: white;
    z-index: 1;
    overflow: visible !important;
    /* Safari fix: prevent table from interfering with dropdown z-index */
    -webkit-transform: none !important;
    transform: none !important;
    table-layout: auto;
}

.table.modern-table thead {
    background: #f8f9fa !important;
    border-bottom: 2px solid #dee2e6;
    position: relative;
    z-index: 2;
}

.table.modern-table thead th {
    border: none !important;
    padding: 16px 12px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.8px;
    vertical-align: middle;
    white-space: nowrap;
    color: #495057 !important;
    background: #f8f9fa !important;
}

.table.modern-table thead tr {
    background: #f8f9fa !important;
}

.table.modern-table tbody {
    overflow: visible !important;
    position: relative;
    z-index: 3;
}

.table.modern-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: all 0.2s ease;
    overflow: visible !important;
    position: relative;
    /* Safari fix: prevent row isolation from breaking dropdowns */
    isolation: auto;
}

.table.modern-table tbody tr:last-child {
    border-bottom: none;
}

.table.modern-table tbody tr:hover {
    background-color: #f8f9ff;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

.table.modern-table tbody td {
    padding: 14px 12px;
    vertical-align: middle;
    color: #495057;
    font-size: 14px;
    overflow: visible !important;
    /* Safari & Chrome: Allow dropdowns to escape table cells */
    position: static;
    -webkit-transform: none !important;
    transform: none !important;
}

.table.modern-table tbody td:first-child {
    font-weight: 500;
    color: #2c3e50;
}

/* Striped variant */
.table.modern-table.table-striped tbody tr:nth-of-type(odd) {
    background-color: #f8f9fa;
}

.table.modern-table.table-striped tbody tr:hover {
    background-color: #f0f4ff;
}

/* Status badges in tables */
.table.modern-table .badge,
.table.modern-table .label {
    padding: 5px 12px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Button groups in tables */
.table.modern-table .btn-group .btn {
    padding: 6px 12px;
    font-size: 13px;
}

/* Responsive table wrapper */
.table-responsive.modern-table-responsive {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-top: 20px;
}

.table-responsive.modern-table-responsive .table {
    margin-bottom: 0;
}

/* Empty state */
.table-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.table-empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.table-empty-state h4 {
    color: #495057;
    margin-bottom: 8px;
}

.table-empty-state p {
    color: #868e96;
}

/* Action buttons in tables */
.table.modern-table .btn-action {
    padding: 4px 10px;
    font-size: 12px;
    margin: 0 2px;
}

/* Icon columns */
.table.modern-table .icon-col {
    width: 40px;
    text-align: center;
}

.table.modern-table .icon-col i {
    font-size: 18px;
}

/* Status indicator dots */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-dot.active {
    background-color: #28a745;
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.5);
}

.status-dot.inactive {
    background-color: #dc3545;
}

.status-dot.pending {
    background-color: #ffc107;
}

/* Compact table variant */
.table.modern-table.table-compact thead th {
    padding: 8px 6px;
    font-size: 11px;
}

.table.modern-table.table-compact tbody td {
    padding: 6px 6px;
    font-size: 12px;
}

/* Extra small button */
.btn-modern-xs {
    padding: 2px 6px !important;
    font-size: 11px !important;
    line-height: 1.2;
    border-radius: 4px;
}

.btn-modern-xs i {
    font-size: 12px;
}

/* Panel with modern table */
.panel.modern-panel {
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    overflow: visible !important;
    /* Safari fix: ensure dropdowns can escape panel boundaries */
    position: relative;
    z-index: auto;
}

.panel.modern-panel > .panel-heading {
    background: #f8f9fa;
    color: #2c3e50;
    border: none;
    border-bottom: 2px solid #dee2e6;
    padding: 16px 20px;
}

.panel.modern-panel > .panel-heading .panel-title {
    font-weight: 600;
    font-size: 16px;
    color: #2c3e50;
}

.panel.modern-panel > .panel-body {
    padding: 0;
    padding-bottom: 20px;
    overflow: visible !important;
}

.panel.modern-panel > .panel-body.panel-body-spaced {
    padding: 24px 28px 28px;
}

.panel.modern-panel .table {
    margin-bottom: 0;
}

/* Table toolbar */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.table-toolbar .toolbar-left,
.table-toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Search box in toolbar */
.table-search {
    position: relative;
}

.table-search input {
    padding-left: 36px;
    border-radius: 20px;
    border: 1px solid #dee2e6;
    min-width: 250px;
}

.table-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

/* Pagination in tables */
.table-pagination {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Loading overlay for tables */
.table-loading {
    position: relative;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .table.modern-table thead th {
        padding: 12px 8px;
        font-size: 10px;
    }
    
    .table.modern-table tbody td {
        padding: 12px 8px;
        font-size: 13px;
    }
    
    .table-toolbar {
        flex-direction: column;
        gap: 12px;
    }
    
    .table-search input {
        min-width: 100%;
    }
}

/* ====================================
   Building Header Styles (Global)
   ==================================== */

/* Building header row in tables - groups items by building/location */
.modern-table .building-header,
.modern-table .building-header-row {
    background: linear-gradient(135deg, #eeeeee 0%, #ffffff 100%) !important;
    color: #2c3e50 !important;
    font-weight: bold;
    border: none !important;
}

.modern-table .building-header td,
.modern-table .building-header-row td {
    padding: 12px 15px !important;
    color: #2c3e50 !important;
    font-size: 14px;
    border: none !important;
    background: transparent !important;
}

.modern-table .building-header td strong,
.modern-table .building-header-row td strong {
    color: #2c3e50 !important;
    font-size: 15px;
    letter-spacing: 0.5px;
}

.modern-table .building-header .bi,
.modern-table .building-header-row .bi {
    margin-right: 8px;
    font-size: 16px;
    color: #2c3e50 !important;
}

.modern-table tbody tr.building-header:hover,
.modern-table tbody tr.building-header-row:hover {
    background: linear-gradient(135deg, #7CE7D3 0%, #ffffff 100%) !important;
}

/* Building header rows should not have bottom border */
.modern-table tbody tr.building-header,
.modern-table tbody tr.building-header-row {
    border-bottom: none !important;
}

/* Table card style (alternative) */
.table-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    overflow: visible;
    margin-bottom: 24px;
    border: 1px solid #e9ecef;
}

.table-card-header {
    background: #f8f9fa;
    color: #2c3e50;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #dee2e6;
}

.table-card-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.table-card-body {
    padding: 0;
}

/* ====================================
   Modern Button Styles for Actions
   ==================================== */

/* Modern action button base */
.btn-modern {
    border-radius: 6px;
    font-weight: 500;
    font-size: 13px;
    padding: 6px 14px;
    transition: all 0.2s ease;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-modern:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    text-decoration: none;
}

.btn-modern:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-modern i {
    font-size: 14px;
}

/* Disabled state for modern buttons */
.btn-modern:disabled,
.btn-modern.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
    pointer-events: none;
}

.btn-modern:disabled:hover,
.btn-modern.disabled:hover {
    transform: none !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

/* Modern button variants */
.btn-modern-primary {
    background: #6366f1;
    color: white !important;
    border: none;
}

.btn-modern-primary:hover {
    background: #4f46e5;
    color: white !important;
}

.btn-modern-success {
    background: #10b981;
    color: white !important;
    border: none;
}

.btn-modern-success:hover {
    background: #059669;
    color: white !important;
}

.btn-modern-info {
    background: #0ea5e9;
    color: white !important;
    border: none;
}

.btn-modern-info:hover {
    background: #0284c7;
    color: white !important;
}

.btn-modern-warning {
    background: #f59e0b;
    color: white !important;
    border: none;
}

.btn-modern-warning:hover {
    background: #d97706;
    color: white !important;
}

.btn-modern-danger {
    background: #ef4444;
    color: white !important;
    border: none;
}

.btn-modern-danger:hover {
    background: #dc2626;
    color: white !important;
}

.btn-modern-purple {
    background: #9333ea;
    color: white !important;
    border: none;
}

.btn-modern-purple:hover {
    background: #7e22ce;
    color: white !important;
}

/* Outline button variant */
.btn-modern-outline {
    background: white;
    color: #6b7280;
    border: 2px solid #d1d5db;
    font-weight: 500;
}

.btn-modern-outline:hover {
    background: #f9fafb;
    color: #374151;
    border-color: #9ca3af;
}

.btn-modern-secondary {
    background: #6b7280;
    color: white;
    border: none;
    font-weight: 500;
}

.btn-modern-secondary:hover {
    background: #4b5563;
    color: white;
}

/* Soft button variant (subtle, modern look with better contrast) */
.btn-modern-soft-primary {
    background: #667eea;
    color: white;
    border: none;
    opacity: 0.85;
}

.btn-modern-soft-primary:hover {
    background: #667eea;
    color: white;
    opacity: 1;
}

.btn-modern-soft-success {
    background: #10b981;
    color: white;
    border: none;
    opacity: 0.85;
}

.btn-modern-soft-success:hover {
    background: #10b981;
    color: white;
    opacity: 1;
}

.btn-modern-soft-info {
    background: #3b82f6;
    color: white;
    border: none;
    opacity: 0.85;
}

.btn-modern-soft-info:hover {
    background: #3b82f6;
    color: white;
    opacity: 1;
}

.btn-modern-soft-danger {
    background: #ef4444;
    color: white;
    border: none;
    opacity: 0.85;
}

.btn-modern-soft-danger:hover {
    background: #ef4444;
    color: white;
    opacity: 1;
}

/* Icon-only button */
.btn-modern-icon {
    padding: 8px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* Button group modern style */
.btn-group-modern {
    display: inline-flex;
    gap: 4px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.btn-group-modern .btn-modern {
    margin: 0;
}

/* PIR table action buttons - keep inline */
.modern-table .btn-group-modern {
    display: inline-flex;
    flex-wrap: nowrap;
}

/* PIR actions cell - prevent wrapping */
.pir-actions-cell {
    white-space: nowrap;
}

.pir-actions-cell .btn-group-modern {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 3px;
}

/* Table action buttons - compact style */
.table-action-btns {
    display: flex;
    gap: 3px;
    flex-wrap: nowrap;
    align-items: center;
}

.table-action-btns .btn {
    white-space: nowrap;
    padding: 5px 10px;
    font-size: 12px;
}

.table-action-btns .btn i {
    font-size: 13px;
}

/* Icon-only compact buttons for tables */
.table-action-btns .btn-icon-only {
    padding: 5px 8px;
    min-width: 32px;
}

/* Compact labels/badges for tables */
.modern-table .label {
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    display: inline-block;
    line-height: 1.2;
}

/* Make all labels in modern tables compact */
.table.modern-table .label {
    padding: 3px 8px;
    font-size: 10px;
}

/* Dropdown menu styling for action buttons */
.modern-table .btn-group {
    position: relative;
    display: inline-block;
    z-index: 1;
    /* Safari fix: prevent transform from creating stacking context */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* When dropdown is open, increase z-index */
.modern-table .btn-group.open {
    z-index: 99999 !important;
    /* Safari fix: force hardware acceleration */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.modern-table .dropdown-menu {
    position: absolute;
    top: 100%;
    z-index: 100000 !important;
    min-width: 180px;
    margin-top: 2px;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 1px solid #e0e0e0;
    padding: 8px 0;
    background-color: #fff;
    max-height: none;
    /* Safari fix: ensure dropdown appears above everything */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    isolation: isolate;
}

/* Right-aligned dropdown */
.modern-table .dropdown-menu.dropdown-menu-right,
.modern-table .dropdown-menu-right {
    right: 0;
    left: auto;
}

/* Left-aligned dropdown (default) */
.modern-table .dropdown-menu:not(.dropdown-menu-right) {
    left: 0;
    right: auto;
}

.modern-table .dropdown-menu > li > a {
    padding: 10px 16px;
    color: #333;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    white-space: nowrap;
}

.modern-table .dropdown-menu > li:last-child > a {
    margin-bottom: 0;
}

.modern-table .dropdown-menu > li > a i {
    width: 16px;
    text-align: center;
    font-size: 14px;
}

.modern-table .dropdown-menu > li > a:hover {
    background-color: #f5f5f5;
    color: #0066cc;
}

/* Currently selected item in table dropdowns */
.modern-table .dropdown-menu > li > a.selected,
.modern-table .dropdown-menu > li.active > a {
    background-color: #e5e7eb;
    color: #374151;
    font-weight: 500;
}

.modern-table .dropdown-menu > .divider {
    margin: 4px 0;
    background-color: #e8e8e8;
    height: 1px;
}

/* Action button dropdown toggle */
.modern-table .btn-group .dropdown-toggle {
    padding: 5px 12px;
    font-size: 13px;
    white-space: nowrap;
    position: relative;
    z-index: 1;
}

.modern-table .btn-group .dropdown-toggle i {
    font-size: 14px;
}

.modern-table .btn-group .dropdown-toggle .caret {
    margin-left: 4px;
}

/* Ensure table rows don't create stacking context issues */
.modern-table tbody tr {
    position: relative;
    z-index: 1;
    /* Safari fix: avoid creating new stacking context on hover */
    -webkit-transform: none;
    transform: none;
}

/* When a row has an open dropdown, increase its z-index above hover effects */
.modern-table tbody tr:has(.btn-group.open) {
    z-index: 99999 !important;
    /* Safari fix: force proper layering */
    isolation: isolate;
}

/* Prevent hover effects from overlapping dropdowns - explicitly set lower z-index */
.modern-table tbody tr:hover {
    z-index: 2;
    /* Safari fix: prevent transform from creating stacking context */
    -webkit-transform: none;
    transform: none;
}

/* But if this row has an open dropdown, keep it on top even on hover */
.modern-table tbody tr:has(.btn-group.open):hover {
    z-index: 99999 !important;
}

/* Ensure non-dropdown rows stay below open dropdowns even on hover */
.modern-table tbody tr:not(:has(.btn-group.open)):hover {
    z-index: 2 !important;
}

.modern-table tbody tr td {
    overflow: visible;
    position: relative;
    z-index: auto;
}

/* Global controls styling for inception device headers */
.global-controls {
    display: inline-block;
    margin-left: 15px;
}

.global-controls .btn-group {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.global-controls .btn-modern {
    margin: 0;
    white-space: nowrap;
}

.global-controls .dropdown-menu {
    min-width: 200px;
}

/* Fix for buttons in panel titles */
.panel-title .pull-right {
    margin-top: -3px;
}

/* Modern Status Badges */
.modern-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s ease;
}

.modern-status-badge i {
    display: block;
}

/* Text variant for status badges (icon + label) */
.modern-status-badge--text {
    font-size: 12px;
    font-weight: 600;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    border: 1px solid transparent;
}

.modern-status-badge svg {
    width: 14px;
    height: 14px;
    display: block;
}

.modern-status-badge.status-active {
    color: #10b981;
}

.modern-status-badge.status-active:hover {
    color: #059669;
    transform: scale(1.1);
}

.modern-status-badge.status-inactive {
    color: #ef4444;
}

.modern-status-badge.status-inactive:hover {
    color: #dc2626;
    transform: scale(1.1);
}

.modern-status-badge.status-neutral {
    color: #6b7280;
}

.modern-status-badge--text.status-active {
    color: #047857;
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.24);
}

.modern-status-badge--text.status-inactive {
    color: #b91c1c;
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.24);
}

.modern-status-badge--text.status-neutral {
    color: #374151;
    background: rgba(107, 114, 128, 0.12);
    border-color: rgba(107, 114, 128, 0.18);
}

.modern-status-badge--text.status-warning {
    color: #b45309;
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.28);
}

.modern-status-badge--text.status-info {
    color: #1d4ed8;
    background: rgba(147, 197, 253, 0.18);
    border-color: rgba(59, 130, 246, 0.24);
}

.modern-status-badge.status-warning {
    color: #f59e0b;
}

.modern-status-badge.status-warning:hover {
    color: #d97706;
    transform: scale(1.1);
}

.modern-status-badge.status-success {
    display: inline-block;
    padding: 4px 12px;
    background: #d1fae5;
    color: #065f46;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

.modern-status-badge.status-danger {
    display: inline-block;
    padding: 4px 12px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

.modern-status-badge.status-info {
    display: inline-block;
    padding: 4px 12px;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

/* Ensure status badges center in table cells */
.modern-table tbody td .modern-status-badge {
    margin: 0 auto;
}

/* ============================================
   MODERN DROPDOWN COMPONENT
   Global reusable dropdown styled like Actions button
   ============================================ */

/* Modern Dropdown Button */
.modern-dropdown-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white !important;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
    min-width: 120px;
}

.modern-dropdown-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
    color: white !important;
}

.modern-dropdown-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.modern-dropdown-btn i {
    margin-right: 6px;
}

.modern-dropdown-btn .caret {
    margin-left: 8px;
    border-top-color: white;
    opacity: 0.8;
}

/* Success variant */
.modern-dropdown-btn.modern-dropdown-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.modern-dropdown-btn.modern-dropdown-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

/* Danger variant */
.modern-dropdown-btn.modern-dropdown-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.modern-dropdown-btn.modern-dropdown-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

/* Warning variant */
.modern-dropdown-btn.modern-dropdown-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.modern-dropdown-btn.modern-dropdown-warning:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
}

/* Secondary/Soft variant */
.modern-dropdown-btn.modern-dropdown-secondary {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    box-shadow: 0 2px 4px rgba(107, 114, 128, 0.2);
}

.modern-dropdown-btn.modern-dropdown-secondary:hover {
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
    box-shadow: 0 4px 8px rgba(107, 114, 128, 0.3);
}

/* Light/White variant - for filter bars and form dropdowns */
.modern-dropdown-btn.modern-dropdown-light {
    background: white !important;
    color: #374151 !important;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.modern-dropdown-btn.modern-dropdown-light:hover {
    background: #f9fafb !important;
    border-color: #9ca3af;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    color: #1f2937 !important;
}

.modern-dropdown-btn.modern-dropdown-light .caret {
    border-top-color: #6b7280 !important;
    opacity: 1;
}

.modern-dropdown-btn.modern-dropdown-light span {
    color: #374151 !important;
}

/* Modern Dropdown Menu */
.modern-dropdown-menu {
    position: absolute !important;
    top: 100% !important;
    right: 0;
    z-index: 1070 !important;
    min-width: 200px;
    margin-top: 4px;
    padding: 8px 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    /* Safari fix: Force hardware acceleration */
    -webkit-transform: translateY(-10px) translateZ(0);
    will-change: transform, opacity;
}

.modern-dropdown.open .modern-dropdown-menu,
.btn-group.open .modern-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    -webkit-transform: translateY(0) translateZ(0);
}

.modern-dropdown-menu li {
    list-style: none;
    margin: 0;
    padding: 0;
}

.modern-dropdown-menu li a {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.modern-dropdown-menu li a i {
    width: 20px;
    margin-right: 10px;
    font-size: 16px;
    color: #6b7280;
    transition: color 0.15s ease;
}

.modern-dropdown-menu li a:hover {
    background: #f3f4f6;
    color: #1f2937;
    border-left-color: #3b82f6;
    padding-left: 18px;
}

.modern-dropdown-menu li a:hover i {
    color: #3b82f6;
}

/* Currently selected item */
.modern-dropdown-menu li a.selected,
.modern-dropdown-menu li.active a {
    background: #e5e7eb;
    color: #1f2937;
    font-weight: 500;
    border-left-color: #6b7280;
}

.modern-dropdown-menu li a.selected i,
.modern-dropdown-menu li.active a i {
    color: #374151;
}

/* Divider */
.modern-dropdown-menu li.divider {
    height: 1px;
    margin: 8px 0;
    background: #e5e7eb;
}

.modern-dropdown-menu li[role="separator"] {
    height: 1px;
    margin: 8px 0;
    background: #e5e7eb;
}

/* Dropdown Header (for grouping) */
.modern-dropdown-menu li.dropdown-header {
    padding: 8px 16px 4px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.modern-dropdown-menu li.dropdown-header strong {
    color: #374151;
}

/* Dropdown wrapper */
.modern-dropdown {
    position: relative;
    display: inline-block;
}

/* Global: Button groups in tables need proper z-index stacking */
.table .btn-group {
    position: relative;
    z-index: 1000;
}

.table .btn-group.open {
    z-index: 1060 !important;
}

/* Global: Ensure dropdowns in tables work properly */
.table tbody td .btn-group,
.table tbody td .modern-dropdown {
    position: relative;
}

/* Ensure table wrappers allow overflow */
div[style*="overflow"] table {
    overflow: visible !important;
}

/* Filter Dropdown Styles (for form selects styled as modern dropdowns) */
.modern-filter-dropdown {
    position: relative;
}

.modern-filter-dropdown select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 10px 40px 10px 16px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.modern-filter-dropdown select.form-control:hover {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modern-filter-dropdown select.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Make existing Bootstrap dropdowns compatible */
.btn-group .modern-dropdown-btn {
    margin: 0;
}

.btn-group.open .modern-dropdown-menu,
.btn-group.open .dropdown-menu.modern-dropdown-menu {
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .modern-dropdown-menu {
        min-width: 160px;
        right: auto;
        left: 0;
    }
    
    .modern-dropdown-btn {
        min-width: 100px;
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ====================================
   Hierarchical Tree Structure in Tables
   ==================================== */

/* Stairwell header rows */
.modern-table tbody tr.stairwell-row {
    background: #f0f4ff !important;
    font-weight: 600;
    border-bottom: 1px solid #d0d9ff !important;
}

.modern-table tbody tr.stairwell-row:hover {
    background: #e6edff !important;
}

/* Areas within stairwells - indented */
.modern-table tbody tr.area-in-stairwell {
    background: #fafbff !important;
}

.modern-table tbody tr.area-in-stairwell:hover {
    background: #f0f4ff !important;
}

/* Tree indent icon */
.tree-indent-icon {
    color: #999;
    margin-right: 5px;
    font-size: 14px;
}

/* ====================================
   PIR Log Styles
   ==================================== */

/* PIR Log Container */
.pir-log-container {
    max-height: 500px;
    min-height: 400px;
    overflow-y: auto;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
}

/* PIR Log Entry */
.pir-log-entry {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 6px;
    background: white;
    border-radius: 6px;
    border-left: 4px solid #6b7280;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-size: 13px;
    transition: all 0.15s ease;
}

.pir-log-entry:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transform: translateX(2px);
}

.pir-log-entry:last-child {
    margin-bottom: 0;
}

.pir-log-entry i {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.pir-log-entry .log-message {
    flex: 1;
    word-break: break-word;
    color: #374151;
}

/* Log type color coding */
.pir-log-entry.log-movement {
    border-left-color: #10b981;
    background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
}

.pir-log-entry.log-movement i {
    color: #10b981;
}

.pir-log-entry.log-timeout {
    border-left-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
}

.pir-log-entry.log-timeout i {
    color: #ef4444;
}

.pir-log-entry.log-radar {
    border-left-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
}

.pir-log-entry.log-radar i {
    color: #3b82f6;
}

.pir-log-entry.log-level {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
}

.pir-log-entry.log-level i {
    color: #f59e0b;
}

.pir-log-entry.log-system {
    border-left-color: #6b7280;
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
}

.pir-log-entry.log-system i {
    color: #6b7280;
}

/* PIR Log Legend */
.pir-log-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.pir-log-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #4b5563;
}

.pir-log-legend .legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.pir-log-legend .legend-dot.log-movement {
    background: #10b981;
}

.pir-log-legend .legend-dot.log-timeout {
    background: #ef4444;
}

.pir-log-legend .legend-dot.log-radar {
    background: #3b82f6;
}

.pir-log-legend .legend-dot.log-level {
    background: #f59e0b;
}

.pir-log-legend .legend-dot.log-system {
    background: #6b7280;
}

/* PIR Log Loading State */
.pir-log-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px;
    color: #6b7280;
    font-size: 14px;
}

.pir-log-loading i {
    font-size: 20px;
    animation: spin 1.5s linear infinite;
}

/* PIR Log Empty State */
.pir-log-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 60px 20px;
    color: #9ca3af;
    font-size: 14px;
}

.pir-log-empty i {
    font-size: 24px;
}

/* PIR Filter Form */
.pir-filter-form .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.pir-filter-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pir-filter-form .form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
}

.pir-filter-form .form-group label i {
    margin-right: 4px;
}

.pir-filter-form .filter-actions {
    display: flex;
    gap: 8px;
}

/* Responsive adjustments for PIR styles */
@media (max-width: 768px) {
    .pir-log-legend {
        gap: 10px;
    }
    
    .pir-log-legend .legend-item {
        font-size: 11px;
    }
    
    .pir-log-entry {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .pir-filter-form .filter-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .pir-filter-form .filter-actions {
        width: 100%;
    }
    
    .pir-filter-form .filter-actions .btn {
        flex: 1;
    }
}

/* ====================================
   Server Column Truncation
   ==================================== */

/* Truncate server ID column to prevent table from becoming too wide */
.modern-table tbody td.server-id-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modern-table tbody td.server-id-cell strong {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: help;
}
