:root {
    --saf-red: #cc0000;
    --saf-red-dark: #a30000;
    --saf-chrome: #212529;
    --saf-bg: #f8fafc;
    --saf-success: #198754;
    --saf-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

body {
    background-color: var(--saf-bg);
    font-family: 'Inter', sans-serif;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
}

/* Buttons */
.btn {
    border-radius: 50rem;
    box-shadow: none;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: var(--saf-red);
    border-color: var(--saf-red);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--saf-red-dark);
    border-color: var(--saf-red-dark);
    box-shadow: 0 4px 6px rgba(204, 0, 0, 0.2);
    transform: translateY(-1px);
}

/* Stark Cards */
.stark-card {
    border: none;
    border-left: 4px solid var(--saf-red);
    border-radius: 8px;
    box-shadow: var(--saf-shadow);
    background-color: #ffffff;
    margin-bottom: 1.5rem;
}

.stark-card .card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-weight: 600;
}

/* KPI Cards */
.kpi-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: none;
    border-left: 4px solid var(--saf-red);
    border-radius: 8px;
    box-shadow: var(--saf-shadow);
    background-color: #ffffff;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

.kpi-card .inner h3 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--saf-chrome);
}

/* Tables */
/* Improved Table Header Styling - Fortified for DataTables & Bootstrap 5 */
table.table-stark thead th {
    background-color: var(--saf-chrome) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    border-bottom: 3px solid var(--saf-red) !important; /* Premium Highlight */
    padding: 12px 15px !important;
    vertical-align: middle;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    position: relative;
}

/* Ensure DataTables Sort Icons are visible against dark background */
table.table-stark thead .sorting:before,
table.table-stark thead .sorting:after,
table.table-stark thead .sorting_asc:before,
table.table-stark thead .sorting_asc:after,
table.table-stark thead .sorting_desc:before,
table.table-stark thead .sorting_desc:after {
    color: #ffffff !important;
    opacity: 0.3 !important;
}

table.table-stark thead .sorting_asc:before,
table.table-stark thead .sorting_asc:after,
table.table-stark thead .sorting_desc:before,
table.table-stark thead .sorting_desc:after {
    opacity: 1 !important;
}


.table-stark tbody tr {
    transition: background-color 0.2s ease;
}

.table-stark tbody tr:hover {
    background-color: rgba(204, 0, 0, 0.05); /* Soft red hover */
}

/* Badges - Soft UI */
.badge-soft {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    color: var(--saf-chrome);
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

/* DataTables Global Loading Indicator - Stark Glassmorphism */
.dataTables_wrapper {
    position: relative;
}

.dataTables_processing {
    position: absolute;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1050 !important;
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    border-radius: 50rem !important;
    padding: 1rem 2rem !important;
    color: var(--saf-chrome) !important;
    font-weight: 700 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1) !important;
    text-align: center;
    min-width: 180px;
    margin: 0 !important;
}

.dataTables_processing i {
    color: var(--saf-red);
    font-size: 1.25rem;
    vertical-align: middle;
}

.badge-soft-primary {
    background-color: rgba(204, 0, 0, 0.1);
    color: var(--saf-red);
}

.badge-soft-success {
    background-color: rgba(25, 135, 84, 0.1);
    color: #198754;
}

.badge-soft-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #997404;
}

.badge-soft-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* Sidebar Active State (Stark Identity) */
.active-saf {
    background-color: var(--saf-red) !important;
    color: #ffffff !important;
    font-weight: 600;
}
.active-saf i {
    color: #ffffff !important;
}

/* Glassmorphism */
.glass-modal .modal-content,
.glass-dropdown {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Form Controls - Stark Identity */
.form-control:focus, .form-select:focus {
    border-color: var(--saf-red);
    box-shadow: 0 0 0 0.25rem rgba(204, 0, 0, 0.15);
}

.form-control.is-invalid:focus, .form-select.is-invalid:focus {
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

/* AdminLTE Overrides */
.app-header, .app-sidebar {
    background-color: var(--saf-chrome) !important;
}
.app-header .nav-link {
    color: #ffffff !important;
}
.brand-link {
    color: #ffffff !important;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
}
.sidebar .nav-link {
    color: rgba(255,255,255,0.8);
}
.sidebar .nav-link:hover {
    color: #ffffff;
}

/* Filter Box */
.stark-filter-box {
    background-color: #ffffff;
    border-left: 4px solid var(--saf-red);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border-top: 1px solid rgba(0,0,0,0.05);
    border-right: 1px solid rgba(0,0,0,0.05);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* Text Truncation Utilities */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;  
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
}

/* DataTable Column Wrapping */
.col-designation {
    min-width: 150px;
    max-width: 250px;
    white-space: normal !important;
    word-break: break-word;
    line-height: 1.5;
    color: inherit;
}

.col-question-text {
    min-width: 400px;
    max-width: 650px;
    white-space: normal !important;
    word-break: break-word;
    line-height: 1.6;
    color: inherit;
    font-weight: 500;
}

/* Touch-Friendly Responsive Buttons */
.app-btn {
    min-height: 48px;
    padding: 0.5rem 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
}

/* Compact buttons for tables */
.table-stark .app-btn {
    min-height: 34px !important;
    padding: 0.25rem 0.75rem !important;
    font-size: 0.85rem;
}

@media (min-width: 768px) {
    .app-btn {
        min-height: 44px;
    }
}

.app-btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.app-btn-group .btn {
    width: 100%;
    margin: 0 !important;
}

@media (min-width: 768px) {
    .app-btn-group {
        flex-direction: row;
        width: auto;
        justify-content: flex-end;
    }
    
    .app-btn-group .btn {
        width: auto;
    }
}

.table-action-buttons {
    display: flex !important;
    flex-wrap: nowrap !important;
    flex-direction: row !important;
    gap: 0.35rem !important;
    justify-content: center;
    align-items: center;
    white-space: nowrap !important;
    width: max-content;
    margin: 0 auto;
}

.col-actions {
    min-width: 150px !important;
    max-width: 180px !important;
    width: 150px !important;
    white-space: nowrap !important;
    text-align: center !important;
}

.table-action-buttons .btn {
    margin: 0 !important;
}
