/* 
 * ═══════════════════════════════════════════════════════════════════════════
 * Global Application Default Zoom Level (90%)
 * ═══════════════════════════════════════════════════════════════════════════ 
 */
html {
    zoom: 90%;
    zoom: 0.9;
}

/* Site wide styles to prevent MIME type error */
body {
    min-height: 100vh;
}

/* 
 * ═══════════════════════════════════════════════════════════════════════════
 * Brand Guidelines Override (Blue & Orange)
 * ═══════════════════════════════════════════════════════════════════════════ 
 */
/* 
 * ═══════════════════════════════════════════════════════════════════════════
 * Brand Guidelines Override (Light & Dark Theme Aware)
 * ═══════════════════════════════════════════════════════════════════════════ 
 */

:root, [data-bs-theme="light"] {
    /* Primary Brand: Blue */
    --bs-primary: #155bb5 !important; 
    --kt-primary: #155bb5 !important;
    --bs-primary-active: #0c3c82 !important;
    --bs-primary-light: #ebf3fc !important;
    --bs-primary-inverse: #ffffff !important;
    --bs-primary-rgb: 21, 91, 181 !important;

    /* Secondary/Accent Brand: Orange */
    --bs-secondary: #f07b14 !important;
    --kt-secondary: #f07b14 !important;
    --bs-secondary-active: #d06509 !important;
    --bs-secondary-light: #fdf3ea !important;
    --bs-secondary-inverse: #ffffff !important;
    --bs-secondary-rgb: 240, 123, 20 !important;
    
    --bs-warning: #f07b14 !important;
    --kt-warning: #f07b14 !important;
}

[data-bs-theme="dark"] {
    /* Primary Brand: Vibrant Blue for Dark Backgrounds */
    --bs-primary: #3E97FF !important; 
    --kt-primary: #3E97FF !important;
    --bs-primary-active: #2575FC !important;
    --bs-primary-light: #1C2B46 !important;
    --bs-primary-inverse: #ffffff !important;
    --bs-primary-rgb: 62, 151, 255 !important;

    /* Secondary/Accent Brand: Bright Vibrant Orange for Dark Backgrounds */
    --bs-secondary: #FF9F43 !important;
    --kt-secondary: #FF9F43 !important;
    --bs-secondary-active: #E67E22 !important;
    --bs-secondary-light: #3A2719 !important;
    --bs-secondary-inverse: #ffffff !important;
    --bs-secondary-rgb: 255, 159, 67 !important;
    
    --bs-warning: #FF9F43 !important;
    --kt-warning: #FF9F43 !important;

    /* Dark Mode Core Surface & Body Colors */
    --bs-body-bg: #151521 !important;
    --bs-body-color: #CDD2E0 !important;
    --bs-card-bg: #1E1E2D !important;
    --bs-border-color: #2B2B40 !important;
}

/* Force Metronic Utilities */
.text-primary { color: var(--bs-primary) !important; }
.bg-primary { background-color: var(--bs-primary) !important; color: white !important; }
.border-primary { border-color: var(--bs-primary) !important; }

.text-secondary, .text-warning, .text-accent { color: var(--bs-secondary) !important; }
.bg-secondary, .bg-warning { background-color: var(--bs-secondary) !important; color: white !important; }

/* Buttons */
.btn-primary, .btn-primary:focus { 
    background-color: var(--bs-primary) !important; 
    border-color: var(--bs-primary) !important; 
    color: white !important; 
}
.btn-primary:hover, .btn-primary:active, .btn-primary.active, .show>.btn-primary.dropdown-toggle {
    background-color: var(--bs-primary-active) !important;
    border-color: var(--bs-primary-active) !important;
    color: white !important;
}

.btn-secondary, .btn-warning {
    background-color: var(--bs-secondary) !important;
    border-color: var(--bs-secondary) !important;
    color: white !important;
}
.btn-secondary:hover, .btn-secondary:active, .btn-secondary.active, .btn-warning:hover, .btn-warning:active, .btn-warning.active {
    background-color: var(--bs-secondary-active) !important;
    border-color: var(--bs-secondary-active) !important;
    color: white !important;
}

/* Outline Buttons Hover Fix */
.btn-outline.btn-outline-primary:hover, .btn-outline.btn-outline-primary:active, .btn-outline.btn-outline-primary.active {
    background-color: var(--bs-primary) !important;
    color: white !important;
}
.btn-outline.btn-outline-warning:hover, .btn-outline.btn-outline-warning:active, .btn-outline.btn-outline-warning.active {
    background-color: var(--bs-secondary) !important;
    color: white !important;
}

/* Tabs & Links */
.nav-line-tabs .nav-item .nav-link.active,
.nav-line-tabs .nav-item.show .nav-link,
.nav-line-tabs .nav-item .nav-link:hover:not(.disabled) {
    border-bottom-color: var(--bs-primary) !important;
    color: var(--bs-primary) !important;
}
a:hover { color: var(--bs-primary-active) !important; }
.menu-state-primary .menu-item.hover>.menu-link:not(.disabled):not(.active), 
.menu-state-primary .menu-item .menu-link:hover:not(.disabled):not(.active) {
    color: var(--bs-primary) !important;
}
.menu-state-primary .menu-item .menu-link.active {
    color: var(--bs-primary) !important;
    background-color: var(--bs-primary-light) !important;
}

/* 
 * ═══════════════════════════════════════════════════════════════════════════
 * Forms Styling (Brand & Theme Integration)
 * ═══════════════════════════════════════════════════════════════════════════ 
 */
 
/* Form Labels (Theme Aware) */
[data-bs-theme="light"] .form-label, 
[data-bs-theme="light"] label.col-form-label {
    color: var(--bs-primary) !important;
    font-weight: 600 !important;
}
[data-bs-theme="dark"] .form-label, 
[data-bs-theme="dark"] label.col-form-label {
    color: #E1E3EA !important;
    font-weight: 600 !important;
}

/* Subtle accent for required asterisk */
.form-label.required:after,
.required::after {
    color: var(--bs-secondary) !important;
}

/* Input Focus States */
.form-control:focus, 
.form-select:focus {
    border-color: var(--bs-secondary) !important;
    box-shadow: 0 0 0 0.25rem rgba(240, 123, 20, 0.25) !important;
}

/* Dark Mode Form Inputs */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #1B1B29 !important;
    border-color: #323248 !important;
    color: #FFFFFF !important;
}

/* Checkboxes & Switches */
.form-check-input:checked {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
}

/* Card Headers */
[data-bs-theme="light"] .card-header .card-title {
    color: var(--bs-primary) !important;
}
[data-bs-theme="dark"] .card-header .card-title {
    color: #FFFFFF !important;
}

.text-hover-primary:hover {
    color: var(--bs-secondary) !important; 
}

/* 
 * ═══════════════════════════════════════════════════════════════════════════
 * DataTables & Native Tables Branding (Light & Dark Theme Aware)
 * ═══════════════════════════════════════════════════════════════════════════ 
 */
 
/* Force Table Headers */
[data-bs-theme="light"] table.dataTable thead th,
[data-bs-theme="light"] table.dataTable thead td,
[data-bs-theme="light"] .table thead th {
    color: var(--bs-primary) !important;
    font-weight: 700 !important;
}

[data-bs-theme="dark"] table.dataTable thead th,
[data-bs-theme="dark"] table.dataTable thead td,
[data-bs-theme="dark"] .table thead th {
    color: #3E97FF !important;
    font-weight: 700 !important;
    border-bottom: 1px solid #2B2B40 !important;
}

/* Dark Mode Table Row Text & Borders */
[data-bs-theme="dark"] .table td,
[data-bs-theme="dark"] table.dataTable tbody td {
    color: #CDD2E0 !important;
    border-color: #2B2B40 !important;
}

/* Dark Mode Light-Variant Badges */
[data-bs-theme="dark"] .badge.badge-light-primary {
    background-color: #1C2B46 !important;
    color: #3E97FF !important;
}
[data-bs-theme="dark"] .badge.badge-light-success {
    background-color: #1C3829 !important;
    color: #47BE7D !important;
}
[data-bs-theme="dark"] .badge.badge-light-warning {
    background-color: #3A2719 !important;
    color: #FF9F43 !important;
}
[data-bs-theme="dark"] .badge.badge-light-danger {
    background-color: #3A1C24 !important;
    color: #F1416C !important;
}
[data-bs-theme="dark"] .badge.badge-light-info {
    background-color: #1A3344 !important;
    color: #7239EA !important;
}
[data-bs-theme="dark"] .badge.badge-light-secondary {
    background-color: #2B2B40 !important;
    color: #A1A5B7 !important;
}

/* Dark Mode Dropdowns & Modals */
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .menu-sub-dropdown {
    background-color: #1E1E2D !important;
    border-color: #2B2B40 !important;
    color: #CDD2E0 !important;
}

/* Colorize the sorting arrows using the orange accent */
table.dataTable thead th.sorting:after,
table.dataTable thead th.sorting_asc:after,
table.dataTable thead th.sorting_desc:after,
table.dataTable thead th.sorting:before,
table.dataTable thead th.sorting_asc:before,
table.dataTable thead th.sorting_desc:before {
    color: var(--bs-secondary) !important;
    opacity: 0.6 !important;
}

/* Brighten the active sorting arrow */
table.dataTable thead th.sorting_asc:before,
table.dataTable thead th.sorting_desc:after {
    opacity: 1 !important;
    color: var(--bs-secondary) !important;
}
/* 
 * ═══════════════════════════════════════════════════════════════════════════
 * Header & Responsiveness Optimization
 * ═══════════════════════════════════════════════════════════════════════════ 
 */

/* Prevent horizontal scroll on body */
body {
    overflow-x: hidden !important;
}

/* Primary Header Container Layout Guarantee - Absolute Overlap Prevention */
#kt_app_header_primary_container {
    display: flex !important;
    align-items: stretch !important;
    justify-content: space-between !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 0.5rem !important;
}

#kt_app_header_primary_container > .d-flex:first-child {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

/* Header Stacking & Sticky Layering */
.app-header-primary {
    z-index: 105 !important;
}

.app-header-primary[data-kt-sticky="true"].active {
    background-color: var(--bs-body-bg) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
}

[data-bs-theme="dark"] .app-header-primary[data-kt-sticky="true"].active {
    background-color: var(--bs-card-bg) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
}

.app-header-secondary {
    z-index: 95 !important;
    position: relative;
}

/* Right Navbar Pinning - ALWAYS guaranteed visible and strictly separated from menu */
.app-navbar {
    display: flex !important;
    align-items: center !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
    z-index: 100 !important;
}

/* User Avatar & Profile/Logout Dropdown Anchor */
#kt_header_user_menu_toggle {
    position: relative !important;
    flex-shrink: 0 !important;
    z-index: 1060 !important;
}

/* Ensure User Profile / Logout Dropdown is NEVER clipped or pushed outside the window */
#kt_header_user_menu_toggle .menu-sub-dropdown {
    right: 0 !important;
    left: auto !important;
    max-width: calc(100vw - 20px) !important;
    z-index: 1070 !important;
}

/* Compact horizontal header menu items on desktop with smooth graceful scroll */
@media (min-width: 992px) {
    .app-header-menu {
        overflow-x: auto !important;
        overflow-y: visible !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }
    .app-header-menu::-webkit-scrollbar {
        display: none !important;
    }
    .menu-lg-row {
        flex-wrap: nowrap !important;
    }
    .menu-lg-row .menu-item .menu-link {
        padding-left: 0.35rem !important;
        padding-right: 0.35rem !important;
    }
    .menu-lg-row .menu-item {
        margin-right: 0.1rem !important;
        flex-shrink: 0 !important;
    }
    .menu-lg-row .menu-title {
        font-size: 0.81rem !important;
        white-space: nowrap !important;
    }
}

/* Global native mobile tables (acts like .table-responsive for all views automatically) */
@media (max-width: 767.98px) {
    .table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile PWA & Touch Form/Card Responsiveness */
@media (max-width: 575.98px) {
    .card-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }
    .card-header .card-title,
    .card-header .card-toolbar {
        width: 100% !important;
        justify-content: space-between !important;
        flex-wrap: wrap !important;
    }
    .card-header form {
        width: 100% !important;
        flex-wrap: wrap !important;
    }
    .card-header .w-250px,
    .card-header .w-200px,
    .card-header .w-150px,
    .card-header .mw-150px,
    .card-header .w-100.mw-150px {
        width: 100% !important;
        max-width: 100% !important;
    }
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
    .btn {
        touch-action: manipulation;
    }
}

/* Card Elevate Micro-Animations & Sleek Hover Effects */
.transition-300 {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.hover-elevate-up:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.08) !important;
}

/* Compact badges on smaller screens */
@media (max-width: 1550px) {
    .app-navbar-item .badge {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
}

/* 
 * ═══════════════════════════════════════════════════════════════════════════
 * Bilingual support (Urdu)
 * ═══════════════════════════════════════════════════════════════════════════ 
 */
.urdu-content, .urdu-font {
    font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', 'Segoe UI Urdu', 'Tahoma', 'Arial', sans-serif !important;
    line-height: 2.2 !important;
    direction: rtl;
    display: inline-block;
}

.urdu-content {
    font-size: 1.25rem !important;
    font-weight: 500 !important;
    opacity: 0.95;
    margin-top: 4px;
}

.urdu-font {
    font-size: 1.35em !important;
    font-weight: 600 !important;
}

/* Force legible sizes for Urdu text in compact layouts (Hard Overrides) */
.fs-10.urdu-font, .fs-9.urdu-font, .fs-10 .urdu-font, .fs-9 .urdu-font {
    font-size: 16px !important;
}

.fs-8.urdu-font, .fs-7.urdu-font, .fs-8 .urdu-font, .fs-7 .urdu-font {
    font-size: 18px !important;
}

.card .urdu-font {
    line-height: 2.4 !important;
}
