/* ==========================================================================
   MICROSOFT FLUENT UI DESIGN SYSTEM - BASE & CUSTOM OVERRIDES
   ========================================================================== */

html, body {
    font-family: 'Segoe UI', 'Segoe UI Variable', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    background-color: #F3F2F1;
    color: #323130;
    margin: 0;
    padding: 0;
}

a, .btn-link {
    color: #0078D4;
    text-decoration: none;
    transition: color 0.15s ease-in-out;
}

a:hover, .btn-link:hover {
    color: #106EBE;
    text-decoration: underline;
}

.btn-primary {
    color: #FFFFFF;
    background-color: #0078D4;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    transition: background-color 0.15s ease-in-out;
}

.btn-primary:hover {
    background-color: #106EBE;
}

.btn-primary:active {
    background-color: #005A9E;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 2px #FFFFFF, 0 0 0 4px #0078D4;
    outline: none;
}

.content {
    padding-top: 1.1rem;
}

h1:focus, h2:focus, h3:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #107C41;
}

.invalid {
    outline: 1px solid #A80000;
}

.validation-message {
    color: #A80000;
}

/* Custom Scrollbar for Fluent Look */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #C8C6C4;
    border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #A19F9D;
}

/* Micro-transitions */
.transition-all {
    transition: all 0.15s ease-in-out;
}

/* Ensure Toast notifications appear on top of Dialogs and Headers */
fluent-toast-provider,
fluent-toasts,
fluent-toast-container,
fluent-toast,
.fluent-toast-provider,
.fluent-toasts,
.fluent-toast-container,
.fluent-toast {
    z-index: 999999 !important;
}

/* Layout Responsiveness Override */
.header-brand-text {
    font-weight: 600;
    font-size: 16px;
    color: #323130;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .header-brand-text {
        display: none !important; /* Hide brand name on very small mobile screens */
    }
}

.header-search-container {
    width: 240px;
}

@media (max-width: 768px) {
    .header-search-container {
        display: none !important; /* Hide search bar on mobile/tablet */
    }
}

/* Nav Sidebar Responsiveness */
.nav-sidebar {
    height: 100%;
    border-right: 1px solid #EDEBE9;
    background-color: #F3F2F1;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.nav-sidebar.expanded {
    width: 260px;
}
.nav-sidebar.collapsed {
    width: 60px;
}

@media (max-width: 768px) {
    .nav-sidebar {
        position: fixed;
        left: 0;
        top: 52px;
        bottom: 0;
        z-index: 100;
        box-shadow: 4px 0 12px rgba(0,0,0,0.1);
    }
    .nav-sidebar.collapsed {
        width: 0px !important;
        border-right: none !important;
    }
    .nav-sidebar.expanded {
        width: 260px !important;
    }
}

/* Main Layout root and header layout wrappers */
.main-layout-root {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    max-width: 100vw;
    overflow: hidden;
    box-sizing: border-box;
}

.main-layout-header {
    background-color: #FFFFFF;
    color: #323130;
    border-bottom: 1px solid #EDEBE9;
    height: 52px;
    padding: 0 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
    box-sizing: border-box;
    width: 100%;
    flex-shrink: 0;
}

/* Main Layout flexbox container layout */
.main-layout-container {
    display: flex;
    flex-direction: row;
    width: 100vw !important;
    max-width: 100vw !important;
    height: calc(100vh - 52px);
    overflow: hidden;
    background-color: #FAF9F8;
    box-sizing: border-box;
}

/* Main body content padding responsiveness */
.main-body-content {
    flex: 1 1 0px !important;
    width: 100% !important;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll on the main layout container */
    background-color: #FAF9F8;
    padding: 32px;
    box-sizing: border-box;
    transition: padding 0.2s ease;
    min-width: 0; /* Prevent flex item from expanding beyond viewport width */
    max-width: 100% !important;
}

.main-body-content.no-padding {
    padding: 0 !important;
    overflow-x: auto !important;
}

@media (max-width: 768px) {
    .main-body-content {
        padding: 16px !important; /* Less padding on tablet and mobile */
    }
    fluent-grid-item, .fluent-grid-item, [class*="fluent-grid-item"] {
        width: 100% !important;
        max-width: 100% !important;
        flex-basis: 100% !important;
    }
}

/* Right Sidebar Responsiveness */
.right-sidebar {
    height: 100%;
    border-left: 1px solid #EDEBE9;
    background-color: #FFFFFF;
    width: 280px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 20px;
    gap: 20px;
    overflow-y: auto;
    box-sizing: border-box;
}

@media (max-width: 1024px) {
    .right-sidebar {
        display: none !important; /* Hide right sidebar completely on mobile/tablet */
    }
}

.header-menu-toggle {
    display: inline-flex !important;
}

@media (max-width: 768px) {
    fluent-header {
        padding: 0 12px !important;
    }
    fluent-grid {
        margin: 0 !important;
        width: 100% !important;
        --grid-spacing: 12px !important;
    }
}

/* Ensure root layout and grid containers are strictly responsive and don't overflow viewports */
fluent-layout {
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
}

fluent-stack, .fluent-stack, [class*="fluent-stack"] {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

fluent-label, .fluent-label, [class*="fluent-label"] {
    display: inline-block !important;
    max-width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    box-sizing: border-box !important;
}

fluent-grid, .fluent-grid, [class*="fluent-grid"] {
    display: flex !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

fluent-grid-item, .fluent-grid-item, [class*="fluent-grid-item"] {
    display: block !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

fluent-card, .fluent-card, [class*="fluent-card"] {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* Custom Dialog Override */
fluent-dialog.custom-dialog {
    --dialog-width: 1100px !important;
    max-width: 1100px !important;
    width: 1100px !important;
}
fluent-dialog.custom-dialog::part(control) {
    max-width: 1100px !important;
    width: 1100px !important;
    max-height: 90vh !important;
}