/* Fusion Plugin Styles - Integrated with WS Theme System */
/* All selectors scoped under .ws-fusion-container or .ws-fusion-dialog to prevent platform conflicts */

/* ==============================================
   FUSION LAYOUT STRUCTURE
   ============================================== */

/* Fusion Container Layout */
.ws-fusion-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background-color: var(--ws-bg-body);
    color: var(--ws-text-base);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.ws-fusion-sidebar {
    width: 280px;
    background-color: var(--ws-navmenu-bg);
    color: var(--ws-navmenu-text);
    overflow-y: auto;
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}

.ws-fusion-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ws-fusion-top-row {
    background-color: var(--ws-appbar-bg);
    border-bottom: var(--ws-appbar-border-bottom-width) solid var(--ws-appbar-border-bottom-color);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.ws-fusion-top-row a {
    color: var(--ws-appbar-text);
    text-decoration: none;
}

.ws-fusion-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
    background-color: var(--ws-bg-body);
    color: var(--ws-text-base);
}

/* Scheduler / Employee-scheduling full-height overrides.
   These pages need the entire viewport height with no scrolling.
   We override the platform MainLayout containers via :has() so
   the flex height chain is unbroken from viewport to page content. */
.main-content:has(.scheduler-page-wrapper),
.main-content:has(.emp-schedule-page) {
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.main-content:has(.scheduler-page-wrapper) .main-grid,
.main-content:has(.emp-schedule-page) .main-grid {
    flex: 1 !important;
    min-height: 0 !important;
    grid-template-rows: 1fr !important;
}

main:has(> .scheduler-page-wrapper),
main:has(> .emp-schedule-page) {
    padding: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

/* ==============================================
   FUSION NAVIGATION MENU
   ============================================== */

.ws-fusion-nav-menu {
    padding: 0;
}

.ws-fusion-brand {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--ws-border-muted);
    margin-bottom: 1rem;
}

.ws-fusion-brand h3 {
    color: var(--ws-navmenu-text);
    font-size: 1.25rem;
    margin: 0;
    font-weight: 600;
}

.ws-fusion-brand .oi {
    color: var(--ws-primary);
    margin-right: 0.5rem;
}

.ws-fusion-container .nav-section-header {
    color: var(--ws-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 1rem 1rem 0.5rem 1rem;
    margin-top: 0.5rem;
}

.ws-fusion-nav-menu .nav-item {
    margin-bottom: 0.25rem;
}

.ws-fusion-nav-menu .nav-link {
    color: var(--ws-navmenu-text);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.ws-fusion-nav-menu .nav-link:hover {
    background-color: var(--ws-navmenu-bg-hover);
    border-left-color: var(--ws-primary);
}

.ws-fusion-nav-menu .nav-link.active {
    background-color: var(--ws-primary);
    color: var(--ws-primary-text);
    border-left-color: var(--ws-primary-text);
    font-weight: 600;
}

.ws-fusion-nav-menu .nav-link .oi {
    margin-right: 0.75rem;
    font-size: 1rem;
}

/* ==============================================
   CARDS (scoped under .ws-fusion-container)
   ============================================== */

.ws-fusion-container .card {
    border: 1px solid var(--ws-border-muted);
    box-shadow: var(--ws-box-shadow-surface);
    margin-bottom: 1.5rem;
    background-color: var(--ws-bg-base);
    color: var(--ws-text-base);
    transition: background-color 0.3s ease, color 0.3s ease;
    border-radius: var(--ws-border-radius);
}

.ws-fusion-container .card-body {
    background-color: var(--ws-bg-base);
    color: var(--ws-text-base);
}

.ws-fusion-container .card-header {
    background-color: var(--ws-bg-alt);
    border-bottom: 2px solid var(--ws-border-muted);
    font-weight: 600;
    color: var(--ws-text-base);
}

.ws-fusion-container .card-header h5 {
    margin: 0;
    color: var(--ws-text-base);
}

.ws-fusion-container .card-header .oi {
    margin-right: 0.5rem;
    color: var(--ws-primary);
}

/* ==============================================
   PAGE STYLES (scoped under .ws-fusion-container)
   ============================================== */

.ws-fusion-container .page-header {
    border-bottom: 2px solid var(--ws-border-muted);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.ws-fusion-container .page-title {
    color: var(--ws-text-base);
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.ws-fusion-container .page-title .oi {
    color: var(--ws-primary);
    margin-right: 1rem;
}

/* ==============================================
   SYNCFUSION GRID CUSTOMIZATIONS (scoped)
   ============================================== */

.ws-fusion-container .e-grid .e-toolbar {
    background-color: var(--ws-bg-alt);
    border-bottom: 2px solid var(--ws-border-muted);
    transition: background-color 0.3s ease;
}

.ws-fusion-container .e-grid .e-headercell {
    background-color: var(--ws-bg-alt);
    font-weight: 600;
    color: var(--ws-text-base);
}

.ws-fusion-container .e-grid .e-row:hover {
    background-color: var(--ws-table-bg-color-hover);
}

/* ==============================================
   SYNCFUSION DIALOG CUSTOMIZATIONS (scoped)
   Dialogs render outside .ws-fusion-container (body portals),
   so we scope under .ws-fusion-dialog CssClass.
   Also duplicate under .ws-fusion-container for inline dialogs.
   ============================================== */

.ws-fusion-dialog.e-dialog,
.ws-fusion-container .e-dialog {
    background-color: var(--ws-bg-base);
    color: var(--ws-text-base);
    border-color: var(--ws-border-muted);
}

/* Dialog header bar */
.ws-fusion-dialog .e-dlg-header-content,
.ws-fusion-container .e-dialog .e-dlg-header-content {
    background-color: var(--ws-bg-alt);
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ws-border-muted);
}

.ws-fusion-dialog .e-dlg-header,
.ws-fusion-container .e-dialog .e-dlg-header {
    background-color: transparent;
    color: var(--ws-text-base);
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
    border: none;
}

/* Dialog close button — override Syncfusion .e-btn defaults */
.ws-fusion-dialog .e-dlg-closeicon-btn.e-btn,
.ws-fusion-container .e-dialog .e-dlg-closeicon-btn.e-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    padding: 0 !important;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--ws-text-muted, #6c757d);
    transition: background-color 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
    order: 1;
}

.ws-fusion-dialog .e-dlg-closeicon-btn.e-btn:hover,
.ws-fusion-dialog .e-dlg-closeicon-btn.e-btn:focus,
.ws-fusion-container .e-dialog .e-dlg-closeicon-btn.e-btn:hover,
.ws-fusion-container .e-dialog .e-dlg-closeicon-btn.e-btn:focus {
    background-color: rgba(0, 0, 0, 0.08) !important;
    color: var(--ws-text-base, #212529);
}

.ws-fusion-dialog .e-dlg-closeicon-btn .e-btn-icon,
.ws-fusion-container .e-dialog .e-dlg-closeicon-btn .e-btn-icon {
    font-size: 12px;
    margin: 0 !important;
    line-height: 1;
}

.ws-fusion-dialog .e-dlg-content,
.ws-fusion-container .e-dialog .e-dlg-content {
    background-color: var(--ws-bg-base);
    color: var(--ws-text-base);
}

.ws-fusion-dialog .e-footer-content,
.ws-fusion-container .e-dialog .e-footer-content {
    background-color: var(--ws-bg-base);
    border-top-color: var(--ws-border-muted);
}

/* Syncfusion Dialog Edit Form */
.ws-fusion-dialog .e-dlg-content .e-field,
.ws-fusion-container .e-dialog .e-dlg-content .e-field {
    margin-bottom: 1rem;
}

/* ==============================================
   SYNCFUSION BUTTONS (scoped)
   ============================================== */

.ws-fusion-container .e-btn.e-primary,
.ws-fusion-dialog .e-btn.e-primary {
    background-color: var(--ws-primary);
    border-color: var(--ws-primary);
    color: var(--ws-primary-text);
}

.ws-fusion-container .e-btn.e-primary:hover,
.ws-fusion-dialog .e-btn.e-primary:hover {
    background-color: var(--ws-primary-hover);
    border-color: var(--ws-primary-hover);
}

.ws-fusion-container .e-btn.e-success,
.ws-fusion-dialog .e-btn.e-success {
    background-color: var(--ws-success);
    border-color: var(--ws-success);
    color: var(--ws-success-text);
}

.ws-fusion-container .e-btn.e-danger,
.ws-fusion-dialog .e-btn.e-danger {
    background-color: var(--ws-danger);
    border-color: var(--ws-danger);
    color: var(--ws-danger-text);
}

/* ==============================================
   IMPORT DIALOG OVERRIDES (portal-rendered)
   ============================================== */

.import-dialog .e-dlg-content {
    padding: 0 !important;
    overflow: hidden;
}

.hierarchical-import-dialog .e-dlg-content {
    padding: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
}

/* Raise import dialog above the platform fixed nav menu (z-index: 1001) */
.e-dlg-container:has(.hierarchical-import-dialog) {
    z-index: 100000 !important;
}

/* Position hierarchical import dialog within the content area (past the 215px nav) */
.hierarchical-import-dialog.e-dialog {
    position: fixed !important;
    left: 225px !important;
    right: 20px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: auto !important;
    max-width: none !important;
}

/* Ensure grids inside import dialogs can scroll horizontally */
.hierarchical-import-dialog .e-grid,
.import-dialog .e-grid {
    overflow-x: auto !important;
}

.hierarchical-import-dialog .import-body .e-grid .e-gridcontent,
.import-dialog .import-body .e-grid .e-gridcontent {
    overflow-x: auto !important;
}

/* Validation cell/row styles (applied via C# to portal-rendered grids) */
.import-dialog .validation-error-cell,
.hierarchical-import-dialog .validation-error-cell {
    background-color: #fff3cd !important;
    border-left: 3px solid #dc3545 !important;
}

.import-dialog .validation-error-row,
.hierarchical-import-dialog .validation-error-row {
    background-color: #fff3cd50 !important;
}

.hierarchical-import-dialog .child-validation-error {
    background-color: #ffe5e5 !important;
}

/* ==============================================
   DARK THEME - ROUTING OPERATIONS PAGE
   (body-level class, cannot use scoped CSS)
   ============================================== */

.dark-theme .ws-fusion-container .routing-operations-page .e-grid .e-row {
    background-color: #0d1117 !important;
    color: #c9d1d9 !important;
    border-color: #21262d !important;
}

.dark-theme .ws-fusion-container .routing-operations-page .e-grid .e-altrow {
    background-color: #161b22 !important;
}

.dark-theme .ws-fusion-container .routing-operations-page .e-grid tr:hover {
    background-color: #21262d !important;
}

.dark-theme .ws-fusion-container .routing-operations-page .e-grid .e-rowcell.e-selectionbackground {
    background-color: rgba(13, 110, 253, 0.2) !important;
    color: #dee2e6 !important;
}

.dark-theme .ws-fusion-container .routing-operations-page .e-grid .e-rowcell.e-selectionbackground.e-active {
    background-color: rgba(13, 110, 253, 0.25) !important;
    color: #dee2e6 !important;
}

.dark-theme .ws-fusion-container .routing-operations-page .e-grid .e-altrow .e-rowcell.e-selectionbackground {
    background-color: rgba(13, 110, 253, 0.18) !important;
    color: #dee2e6 !important;
}

.dark-theme .ws-fusion-container .routing-operations-page .e-grid tr.e-updatedrow {
    background-color: rgba(13, 110, 253, 0.25) !important;
}

.dark-theme .ws-fusion-container .routing-operations-page .e-grid td {
    color: #e6edf3 !important;
}

/* ==============================================
   RESPONSIVE DESIGN
   ============================================== */

@media (max-width: 768px) {
    .ws-fusion-container {
        flex-direction: column;
    }

    .ws-fusion-sidebar {
        width: 100%;
        height: auto;
        max-height: 50vh;
    }

    .ws-fusion-main {
        height: auto;
    }

    .ws-fusion-container .page-title {
        font-size: 1.5rem;
    }
}

/* ==============================================
   SCROLLBAR STYLING
   ============================================== */

.ws-fusion-sidebar::-webkit-scrollbar,
.ws-fusion-content::-webkit-scrollbar {
    width: 8px;
}

.ws-fusion-sidebar::-webkit-scrollbar-track {
    background: var(--ws-bg-muted);
}

.ws-fusion-sidebar::-webkit-scrollbar-thumb {
    background: var(--ws-border-base);
    border-radius: 4px;
}

.ws-fusion-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--ws-text-muted);
}

.ws-fusion-content::-webkit-scrollbar-track {
    background: var(--ws-bg-body);
}

.ws-fusion-content::-webkit-scrollbar-thumb {
    background: var(--ws-border-base);
    border-radius: 4px;
}

.ws-fusion-content::-webkit-scrollbar-thumb:hover {
    background: var(--ws-text-muted);
}
