/* Global Utility Classes (Flexbox, Grid, Spacing) */

/* Flexbox */
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.align-items-center { align-items: center; }
.gap-1 { gap: 5px; }
.gap-2 { gap: 10px; }
.gap-3 { gap: 15px; }
.gap-4 { gap: 20px; }

/* Spacing Utilities (me = margin-end, ms = margin-start) */
.m-0 { margin: 0; }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: 15px; }
.mb-4 { margin-bottom: 25px; }
.mt-1 { margin-top: 5px; }
.mt-4 { margin-top: 25px; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.me-4 { margin-right: 1.5rem !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.ms-4 { margin-left: 1.5rem !important; }

.p-0 { padding: 0; }
.py-4 { padding-top: 25px; padding-bottom: 25px; }
.px-4 { padding-left: 25px; padding-right: 25px; }
.pb-3 { padding-bottom: 15px; }

/* Global FontAwesome Icon Spacing Safeguards */
i.fas[class*="me-"], i.far[class*="me-"], i.fab[class*="me-"], i.fa[class*="me-"] {
    display: inline-block;
}
i.fas:not([class*="me-"]):not(:only-child), 
i.far:not([class*="me-"]):not(:only-child), 
i.fab:not([class*="me-"]):not(:only-child) {
    margin-right: 6px;
}

/* Typography & Colors */
.text-center { text-align: center; }
.text-end { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-light { color: var(--text-light); }

/* Basic Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -10px;
    margin-left: -10px;
}
.row > [class*="col-"] {
    padding-right: 10px;
    padding-left: 10px;
    box-sizing: border-box;
}

.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

.col-md-3 { flex: 0 0 25%; max-width: 25%; }
.col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-md-6 { flex: 0 0 50%; max-width: 50%; }
.col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-md-12 { flex: 0 0 100%; max-width: 100%; }

/* Responsive Grid Adjustments */
@media (max-width: 768px) {
    .row > [class*="col-md-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th, .table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}
.table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.table-hover tbody tr:hover {
    background-color: rgba(255,255,255,0.02);
}

/* System-Wide Theme-Aware Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.35);
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* System-Wide Split Sidebar & Content Independent Scrolling */
.settings-layout, .split-layout, .panel-split-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 25px;
    align-items: start;
    height: calc(100vh - 120px);
    max-height: calc(100vh - 120px);
    overflow: hidden;
}

.settings-sidebar, .split-sidebar {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.settings-content, .split-content {
    min-width: 0;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
}

@media (max-width: 992px) {
    .settings-layout, .split-layout, .panel-split-layout {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
        overflow: visible;
    }
    .settings-sidebar, .split-sidebar, .settings-content, .split-content {
        height: auto;
        max-height: none;
        overflow: visible;
    }
}

/* System-Wide Sidebar Hover Link Color Fix (Light & Dark Themes) */
.settings-link, 
.sidebar-link, 
.sub-menu-item, 
.menu-item, 
.settings-nav-item {
    color: var(--text-light);
    transition: all var(--transition-speed);
}

.settings-link:hover, 
.sidebar-link:hover, 
.sub-menu-item:hover, 
.menu-item:hover, 
.settings-nav-item:hover {
    background-color: rgba(249, 115, 22, 0.12) !important;
    color: var(--primary) !important;
}

.settings-link:hover i, 
.sidebar-link:hover i, 
.sub-menu-item:hover i, 
.menu-item:hover i, 
.settings-nav-item:hover i {
    color: var(--primary) !important;
}

[data-theme="light"] .settings-link:hover,
[data-theme="light"] .sidebar-link:hover,
[data-theme="light"] .sub-menu-item:hover,
[data-theme="light"] .menu-item:hover,
[data-theme="light"] .settings-nav-item:hover {
    background-color: rgba(249, 115, 22, 0.12) !important;
    color: var(--primary) !important;
}

[data-theme="light"] .settings-link:hover i,
[data-theme="light"] .sidebar-link:hover i,
[data-theme="light"] .sub-menu-item:hover i,
[data-theme="light"] .menu-item:hover i,
[data-theme="light"] .settings-nav-item:hover i {
    color: var(--primary) !important;
}
