/* FieldService demo: global overrides scoped to .fsm-demo-root.
   Loaded globally; all selectors scoped to the demo root class.
   Mirrors the tubular-demo.css pattern for layout consistency. */

/* ── MudMainContent: remove default appbar padding ── */
.fsm-demo-root .mud-main-content {
    padding-top: 0 !important;
    height: 100vh;
    overflow: auto;
}

/* ── Drawer panel: dark slate, full height ── */
.fsm-demo-root .navigation-drawer {
    background-color: #0F172A !important;
    background-image: none !important;
    height: 100vh;
    max-height: 100%;
}

/* ── Drawer header ── */
.fsm-demo-root .drawer-header .navigation-drawer-header {
    width: 100%;
    display: flex;
    align-items: center;
}

.fsm-demo-root .drawer-logo-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 0.75rem;
    text-decoration: none;
    color: inherit;
}

.fsm-demo-root .drawer-logo-link:hover {
    text-decoration: none;
}

.fsm-demo-root .drawer-logo-img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.fsm-demo-root .drawer-toggle-btn {
    flex: 0 0 auto;
    color: rgba(255, 255, 255, 0.85) !important;
}

.fsm-demo-root .drawer-toggle-btn:hover {
    color: #fff !important;
}

/* ── Drawer body flex layout ── */
.fsm-demo-root .drawer-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
}

.fsm-demo-root .drawer-body > .w-100 {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ── Drawer footer ── */
.fsm-demo-root .drawer-footer {
    padding-bottom: 1.5rem;
}

.fsm-demo-root .sidebar-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.fsm-demo-root .copyright-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.4;
}

.fsm-demo-root .sidebar-footer-text {
    margin: 0.1rem 0;
}

/* ── Header bar (nav-buttons-container): sticky at top of content area ── */
.fsm-demo-root .nav-buttons-container {
    display: flex;
    gap: 10px;
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
}

/* ── Back to Demos button: pill style, teal primary ── */
.fsm-demo-root .back-to-demos-btn {
    min-width: 10rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    border-radius: 50rem;
    background-color: #0F172A !important;
    color: #fff !important;
    border-color: #0F172A !important;
}

.fsm-demo-root .back-to-demos-btn:hover {
    filter: brightness(1.1);
    color: #fff !important;
}

/* ── Main content body ── */
.fsm-demo-root .main-content-body {
    padding: 0;
    background: #F9FAFB;
    min-height: calc(100vh - 64px);
}

/* ── Auth controls ── */
.fsm-demo-root .auth-controls.display-desktop {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

@media (max-width: 768px) {
    .fsm-demo-root .auth-controls.display-desktop {
        display: none;
    }
}

.fsm-demo-root .user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    color: var(--bs-dark);
    cursor: default;
}

.fsm-demo-root .user-info:hover {
    background-color: transparent;
}

/* ── Sidebar / NavMenu ── */
.fsm-demo-root #sidebar {
    min-width: 13rem;
    max-width: 13rem;
    transition: transform 0.1s ease-out;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: inherit;
}

.fsm-demo-root .menu {
    background-color: inherit;
}

/* MudNavLink: light text for dark sidebar */
.fsm-demo-root .menu .mud-nav-link {
    color: #94A3B8 !important;
    border-radius: 0.5rem;
    margin: 0.125rem 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 400;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.fsm-demo-root .menu .mud-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
    color: #F8FAFC !important;
}

.fsm-demo-root .menu .mud-nav-link .mud-nav-link-icon {
    color: #64748B !important;
}

.fsm-demo-root .menu .mud-nav-link:hover .mud-nav-link-icon {
    color: #F8FAFC !important;
}

/* Active / selected page highlight — teal */
.fsm-demo-root .menu .mud-nav-link.active {
    background-color: #0F766E !important;
    color: #FFFFFF !important;
    font-weight: 500;
}

.fsm-demo-root .menu .mud-nav-link.active .mud-nav-link-icon {
    color: #FFFFFF !important;
}

/* ── Asset grid: freeze first 2 columns (Asset ID + Asset Name) ── */
.fsm-demo-root .fsm-asset-grid .mud-table-container {
    overflow-x: auto !important;
    max-width: 100%;
}

.fsm-demo-root .fsm-asset-grid table {
    min-width: 1200px !important;
}

.fsm-demo-root .fsm-asset-grid .mud-table-cell {
    white-space: nowrap;
}

/* Column 1: Asset ID — pinned at left edge */
.fsm-demo-root .fsm-asset-grid tr > .mud-table-cell:nth-child(1) {
    position: sticky !important;
    left: 0 !important;
    z-index: 2 !important;
    background: #fff !important;
    min-width: 120px;
    max-width: 120px;
}

/* Column 2: Asset Name — pinned after Asset ID */
.fsm-demo-root .fsm-asset-grid tr > .mud-table-cell:nth-child(2) {
    position: sticky !important;
    left: 120px !important;
    z-index: 2 !important;
    background: #fff !important;
    min-width: 200px;
    max-width: 200px;
    border-right: 1px solid #E5E7EB !important;
}

/* Header sticky cells need higher z-index for overlap with both directions */
.fsm-demo-root .fsm-asset-grid .mud-table-head .mud-table-cell:nth-child(1),
.fsm-demo-root .fsm-asset-grid .mud-table-head .mud-table-cell:nth-child(2) {
    z-index: 3 !important;
}

/* ── WO grid: freeze first 2 columns (WO # + Title) ── */
.fsm-demo-root .fsm-wo-grid .mud-table-container {
    overflow-x: auto !important;
    max-width: 100%;
}

.fsm-demo-root .fsm-wo-grid table {
    min-width: 1200px !important;
}

.fsm-demo-root .fsm-wo-grid .mud-table-cell {
    white-space: nowrap;
}

/* Column 1: WO # — pinned at left edge */
.fsm-demo-root .fsm-wo-grid tr > .mud-table-cell:nth-child(1) {
    position: sticky !important;
    left: 0 !important;
    z-index: 2 !important;
    background: #fff !important;
    min-width: 100px;
    max-width: 100px;
}

/* Column 2: Title — pinned after WO # */
.fsm-demo-root .fsm-wo-grid tr > .mud-table-cell:nth-child(2) {
    position: sticky !important;
    left: 100px !important;
    z-index: 2 !important;
    background: #fff !important;
    min-width: 230px;
    max-width: 230px;
    border-right: 1px solid #E5E7EB !important;
    overflow-x: auto;
}

/* Keep title cell content from expanding beyond the pinned width */
.fsm-demo-root .fsm-wo-grid tr > .mud-table-cell:nth-child(2) > * {
    display: block;
    max-width: 214px;          /* 230px column − 16px cell padding */
    overflow-x: auto;
    white-space: nowrap;
}

/* Header sticky cells need higher z-index */
.fsm-demo-root .fsm-wo-grid .mud-table-head .mud-table-cell:nth-child(1),
.fsm-demo-root .fsm-wo-grid .mud-table-head .mud-table-cell:nth-child(2) {
    z-index: 3 !important;
}

/* ── Hamburger button in header (nav closed) ── */
.fsm-demo-root .nav-buttons-container .menu-button .mud-icon-root {
    color: #0F172A !important;
}

/* ── Modal overlay (z-index 100 — below MudBlazor popover at 1300 so dropdowns work) ── */
.fsm-demo-root .fsm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.fsm-demo-root .fsm-modal {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 14px;
    padding: 2rem;
    width: 640px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

/* ── Sibling-based modal (backdrop + panel as siblings, not parent/child) ──
   This pattern prevents @onclick:stopPropagation from interfering with
   MudBlazor popover event handling inside modals. ── */
.fsm-demo-root .fsm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 100;
}

.fsm-demo-root .fsm-modal-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 14px;
    padding: 2rem;
    width: 640px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    z-index: 101;
}

/* ── Modal panel buttons: taller padding ── */
.fsm-demo-root .fsm-modal-panel .mud-button-root {
    padding-top: 10px;
    padding-bottom: 10px;
    min-height: 42px;
}

/* ── Native form elements (replacing MudSelect/MudDatePicker for v9.0.0 compat) ── */
.fsm-demo-root .fsm-form-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.fsm-demo-root .fsm-label {
    font-size: 0.75rem;
    font-weight: 400;
    color: #6B7280;
    margin-bottom: 4px;
    letter-spacing: 0.01em;
}

.fsm-demo-root .fsm-select,
.fsm-demo-root .fsm-date-input,
.fsm-demo-root .fsm-text-input,
.fsm-demo-root .fsm-textarea,
.fsm-demo-root .fsm-number-input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font-size: 0.875rem;
    font-family: inherit;
    color: #1F2937;
    background: #fff;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
}

.fsm-demo-root .fsm-text-input::placeholder,
.fsm-demo-root .fsm-textarea::placeholder,
.fsm-demo-root .fsm-number-input::placeholder {
    color: #9CA3AF;
}

.fsm-demo-root .fsm-number-input {
    -moz-appearance: textfield;
}

.fsm-demo-root .fsm-number-input::-webkit-outer-spin-button,
.fsm-demo-root .fsm-number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.fsm-demo-root .fsm-textarea {
    height: auto;
    min-height: 72px;
    padding: 8px 12px;
    resize: vertical;
}

.fsm-demo-root .fsm-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8.825a.5.5 0 01-.354-.146l-3.5-3.5a.5.5 0 11.708-.708L6 7.618l3.146-3.147a.5.5 0 01.708.708l-3.5 3.5A.5.5 0 016 8.825z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 32px;
}

.fsm-demo-root .fsm-select:focus,
.fsm-demo-root .fsm-date-input:focus,
.fsm-demo-root .fsm-text-input:focus,
.fsm-demo-root .fsm-textarea:focus,
.fsm-demo-root .fsm-number-input:focus {
    border-color: #7C3AED;
    box-shadow: 0 0 0 1px #7C3AED;
}

.fsm-demo-root .fsm-select:disabled,
.fsm-demo-root .fsm-date-input:disabled,
.fsm-demo-root .fsm-text-input:disabled,
.fsm-demo-root .fsm-textarea:disabled,
.fsm-demo-root .fsm-number-input:disabled {
    background: #F3F4F6;
    color: #9CA3AF;
    cursor: not-allowed;
}

/* ── Submission drawer (slide-in from right) ── */
.fsm-demo-root .fsm-drawer-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 520px;
    max-width: 90vw;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 101;
    overflow-y: auto;
    padding: 24px;
    animation: fsm-slide-in 0.25s ease-out;
}

@keyframes fsm-slide-in {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.fsm-demo-root .fsm-drawer-field {
    padding: 8px 0;
    border-bottom: 1px solid #F3F4F6;
}

.fsm-demo-root .fsm-drawer-field-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6B7280;
    margin-bottom: 2px;
}

.fsm-demo-root .fsm-drawer-field-value {
    font-size: 0.875rem;
    color: #1F2937;
    white-space: pre-wrap;
}

.fsm-demo-root .fsm-drawer-loop-section {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.fsm-demo-root .fsm-drawer-loop-item {
    padding: 8px 0;
}

.fsm-demo-root .fsm-drawer-loop-item + .fsm-drawer-loop-item {
    border-top: 1px dashed #E5E7EB;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .fsm-demo-root #sidebar {
        min-width: inherit;
        max-width: inherit;
        display: block;
    }
}
