/*
 * AVstackr Application Styles
 * Uses Bootstrap 5.3+ native theming via data-bs-theme attribute
 * Theme presets defined in css/themes/presets.css
 */

/* Base styles - let Bootstrap handle colors via data-bs-theme */
html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Focus states - use CSS variables */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem var(--bs-body-bg), 0 0 0 0.25rem var(--bs-primary);
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

/* Validation styles - use Bootstrap semantic colors */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--bs-success);
}

.invalid {
    outline: 1px solid var(--bs-danger);
}

.validation-message {
    color: var(--bs-danger);
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MS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/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}


/* Fix dropdown z-index layering issues */
.dropdown-menu {
    z-index: 1050 !important;
    position: absolute !important;
}


/* Fix sticky table headers to not interfere with dropdowns */
.table thead th {
    z-index: 1 !important;
}

/* Create proper stacking context for dropdown containers */
.dropdown {
    position: relative;
    z-index: auto;
}

.dropdown.show {
    z-index: 1051 !important;
}

/* Ensure modals appear above fullscreen overlays (z-index 9998-10000) */
.modal-backdrop {
    z-index: 10001 !important;
}

.modal {
    z-index: 10002 !important;
}

/* ============================================
   TOP ROW / HEADER - uses Bootstrap theming
   ============================================ */
.top-row {
    background-color: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    color: var(--bs-body-color);
}

.top-row a {
    color: var(--bs-body-color);
}

.top-row a:hover {
    color: var(--bs-primary) !important;
}

/* ============================================
   SIDEBAR - uses Bootstrap theming via CSS variables
   ============================================ */
.sidebar {
    background-color: var(--bs-tertiary-bg);
    border-right: 1px solid var(--bs-border-color);
}

.sidebar .navbar-brand {
    color: var(--bs-body-color);
}

.sidebar .nav-link {
    color: var(--bs-body-color);
}

.sidebar .nav-link svg {
    fill: currentColor;
    color: inherit;
}

.sidebar .nav-link:hover {
    background-color: var(--bs-secondary-bg);
    color: var(--bs-body-color);
}

.sidebar .nav-item a.active {
    background-color: var(--bs-primary);
    color: #fff;
}

/* ============================================
   MAIN CONTENT AREAS - uses Bootstrap theming
   Bootstrap 5.3+ handles body colors via data-bs-theme
   ============================================ */
main,
article,
.page {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* ============================================
   FORM CONTROLS - Bootstrap handles base theming
   High-contrast inputs handled in theme-base.css
   ============================================ */
/* Form select inherits Bootstrap theming */
.form-select {
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

/* ============================================
   TABLES - Bootstrap 5.3+ handles base theming
   Custom table header styling for darker header
   ============================================ */
.table {
    --bs-table-bg: var(--bs-body-bg);
    --bs-table-color: var(--bs-body-color);
    --bs-table-border-color: var(--bs-border-color);
}

.table thead th {
    background-color: var(--bs-tertiary-bg);
    border-color: var(--bs-border-color);
}

.table-responsive {
    background-color: var(--bs-body-bg);
}

/* ============================================
   CARDS - handled by theme-base.css
   ============================================ */
.card-header {
    background-color: var(--bs-tertiary-bg);
    border-bottom-color: var(--bs-border-color);
}

/* ============================================
   PAGE SECTIONS - use CSS variables
   ============================================ */
.page-title,
.section-header,
.content-header,
.panel-header,
.section-title,
.header-row {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    border-bottom: 1px solid var(--bs-border-color);
}

/* ============================================
   MODALS - handled by theme-base.css
   ============================================ */

/* ============================================
   BUTTONS - Bootstrap handles theming
   ============================================ */
/* Button outline variants use Bootstrap theming */

/* ============================================
   DROPDOWNS - handled by theme-base.css
   ============================================ */
/* Dropdown hover highlight */
.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--bs-primary);
    color: #fff;
}

.dropdown-item:hover i,
.dropdown-item:focus i {
    color: #fff;
}

/* ============================================
   ALERTS - Bootstrap handles theming
   ============================================ */

/* ============================================
   HIGHLIGHTED ROWS - Special styling for line items
   These need explicit colors for visibility
   ============================================ */
.highlighted-row,
.highlighted-row td {
    background-color: #ffc107 !important;
    color: #000 !important;
}

.highlighted-row:hover,
.highlighted-row:hover td {
    background-color: #ffca2c !important;
}

.highlighted-row input,
.highlighted-row select,
.highlighted-row textarea {
    background-color: #fff !important;
    color: #000 !important;
    border-color: #e0a800 !important;
}

.highlighted-row .btn {
    color: #000 !important;
}

.highlighted-print-row,
.highlighted-print-row td {
    background-color: #ffc107 !important;
    color: #000 !important;
}

/* ============================================
   BOOTSTRAP COMPONENTS - handled by Bootstrap 5.3
   Buttons, borders, backgrounds all use data-bs-theme
   ============================================ */


/* Limit description column width in project details table */
.table th[style*="min-width: 200px"] {
    max-width: 300px !important;
    min-width: 200px !important;
    width: 300px !important;
    word-wrap: break-word !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
}

/* Limit description column content in table cells */
.table tbody td:nth-child(3) {
    max-width: 300px !important;
    word-wrap: break-word !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    text-overflow: ellipsis !important;
}

/* ============================================
   DIVIDER ROWS - table-secondary variant
   ============================================ */
.table-secondary {
    --bs-table-bg: var(--bs-tertiary-bg);
}

/* ============================================
   EQUIPMENT ORDER SUMMARY - print-specific white bg
   ============================================ */
.equipment-order-summary,
.equipment-order-summary * {
    background-color: #fff !important;
    color: #000 !important;
}

.equipment-order-summary .table td,
.equipment-order-summary .table th {
    border-color: #dee2e6 !important;
}

/* ============================================
   QUICKGRID - Third-party component theming
   These overrides are needed due to scoped CSS
   ============================================ */
/* Column header text - match Projects list style */
.col-title {
    font-weight: 600 !important;
    font-size: 0.8rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: var(--bs-secondary) !important;
}

/* Column options button needs white icon in dark mode */
[data-bs-theme="dark"] .col-options-button {
    color: var(--bs-body-color) !important;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="1.5 0 21 24" stroke="white" stroke-width="2"><path d="M4 6h16M4 12h16M4 18h16" /></svg>') !important;
}

[data-bs-theme="dark"] .col-options-button:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
}

/* Column options dropdown panel */
[data-bs-theme="dark"] .col-options {
    background-color: var(--bs-tertiary-bg) !important;
    border-color: var(--bs-border-color) !important;
    color: var(--bs-body-color) !important;
}

/* Sort indicator invert for dark mode */
[data-bs-theme="dark"] .sort-indicator {
    filter: invert(1) !important;
}

/* ========================================
   QuickGrid Paginator - Modern Font Awesome Icons
   ======================================== */

/* Target the Paginator's nav element */
nav[role="navigation"] {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
}

/* Style all paginator buttons - high specificity to override scoped CSS */
nav[role="navigation"] button.go-first,
nav[role="navigation"] button.go-previous,
nav[role="navigation"] button.go-next,
nav[role="navigation"] button.go-last {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 32px !important;
    height: 32px !important;
    padding: 0 0.5rem !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 6px !important;
    background-color: #fff !important;
    color: #333 !important;
    font-size: 0 !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    transform: none !important; /* Override the mirroring transform */
}

/* Hide default SVG icons inside paginator buttons */
nav[role="navigation"] button.go-first svg,
nav[role="navigation"] button.go-previous svg,
nav[role="navigation"] button.go-next svg,
nav[role="navigation"] button.go-last svg,
nav[role="navigation"] button.go-first *,
nav[role="navigation"] button.go-previous *,
nav[role="navigation"] button.go-next *,
nav[role="navigation"] button.go-last * {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    position: absolute !important;
    pointer-events: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
}

nav[role="navigation"] button.go-first:hover:not(:disabled),
nav[role="navigation"] button.go-previous:hover:not(:disabled),
nav[role="navigation"] button.go-next:hover:not(:disabled),
nav[role="navigation"] button.go-last:hover:not(:disabled) {
    background-color: #f8f9fa !important;
    border-color: #adb5bd !important;
}

nav[role="navigation"] button.go-first:disabled,
nav[role="navigation"] button.go-previous:disabled,
nav[role="navigation"] button.go-next:disabled,
nav[role="navigation"] button.go-last:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

/* Base icon styling for all paginator buttons */
nav[role="navigation"] button.go-first::before,
nav[role="navigation"] button.go-previous::before,
nav[role="navigation"] button.go-next::before,
nav[role="navigation"] button.go-last::before {
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
    font-size: 0.875rem !important;
    display: inline-block !important;
    color: #333 !important;
}

/* Map icons by button class names - using chevron icons */
nav[role="navigation"] button.go-first::before {
    content: "\f100" !important; /* angles-left << */
}

nav[role="navigation"] button.go-previous::before {
    content: "\f104" !important; /* angle-left < */
}

nav[role="navigation"] button.go-next::before {
    content: "\f105" !important; /* angle-right > */
}

nav[role="navigation"] button.go-last::before {
    content: "\f101" !important; /* angles-right >> */
}

/* Dark mode paginator buttons */
[data-bs-theme="dark"] nav[role="navigation"] button.go-first,
[data-bs-theme="dark"] nav[role="navigation"] button.go-previous,
[data-bs-theme="dark"] nav[role="navigation"] button.go-next,
[data-bs-theme="dark"] nav[role="navigation"] button.go-last {
    background-color: var(--bs-tertiary-bg) !important;
    border-color: var(--bs-border-color) !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] nav[role="navigation"] button.go-first:hover:not(:disabled),
[data-bs-theme="dark"] nav[role="navigation"] button.go-previous:hover:not(:disabled),
[data-bs-theme="dark"] nav[role="navigation"] button.go-next:hover:not(:disabled),
[data-bs-theme="dark"] nav[role="navigation"] button.go-last:hover:not(:disabled) {
    background-color: var(--bs-secondary-bg) !important;
}

[data-bs-theme="dark"] nav[role="navigation"] button::before {
    color: var(--bs-body-color) !important;
}

/* ============================================
   DRAWING MEASUREMENT TOOL - CAD-STYLE TOOLBAR
   ============================================ */
.measure-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0.5rem;
    background-color: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
}

.measure-toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.measure-toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    padding-right: 10px;
    border-right: 1px solid var(--bs-border-color);
}

.measure-toolbar-group:last-child {
    border-right: none;
    padding-right: 0;
}

/* Compact toolbar buttons */
.measure-toolbar .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.25;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.measure-toolbar .btn i {
    font-size: 0.875rem;
}

.measure-toolbar .btn-sm {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
}

/* Tool mode buttons - strong active state */
.measure-toolbar .tool-btn {
    min-width: 2.25rem;
    justify-content: center;
}

.measure-toolbar .tool-btn.active {
    background-color: var(--bs-success) !important;
    border-color: var(--bs-success) !important;
    color: #fff !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.measure-toolbar .tool-btn.active-warning {
    background-color: var(--bs-warning) !important;
    border-color: var(--bs-warning) !important;
    color: #000 !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.measure-toolbar .tool-btn.active-info {
    background-color: var(--bs-info) !important;
    border-color: var(--bs-info) !important;
    color: #000 !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.measure-toolbar .tool-btn.active-purple {
    background-color: #8b5cf6 !important;
    border-color: #8b5cf6 !important;
    color: #fff !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Destructive actions */
.measure-toolbar .btn-destructive {
    color: var(--bs-danger);
    border-color: var(--bs-danger);
}

.measure-toolbar .btn-destructive:hover {
    background-color: var(--bs-danger);
    color: #fff;
}

/* Compact form controls in toolbar */
.measure-toolbar .form-check {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    min-height: auto;
}

.measure-toolbar .form-check.form-switch {
    padding-left: 2.5em;
}

.measure-toolbar .form-check-input {
    margin: 0;
    margin-top: 0;
    flex-shrink: 0;
}

.measure-toolbar .form-check-label {
    font-size: 0.75rem;
    white-space: nowrap;
    margin-left: 0.25rem;
    line-height: 1;
}

.measure-toolbar .form-range {
    width: 70px;
    height: 0.5rem;
}

/* Compact slider group - flexible, shrinks/wraps first */
.measure-toolbar .slider-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 120px;
    min-width: 120px;
}

.measure-toolbar .slider-group label {
    font-size: 0.75rem;
    margin: 0;
    white-space: nowrap;
}

.measure-toolbar .slider-group .badge {
    font-size: 0.7rem;
    min-width: 2.5rem;
    text-align: center;
}

/* Status badges */
.measure-toolbar .status-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
}

/* Dropdown adjustments */
.measure-toolbar .dropdown-toggle {
    padding: 0.25rem 0.5rem;
}

/* Linked room badge */
.measure-toolbar .linked-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===========================================
   Column Resize Styles
   =========================================== */

/* Resizable columns table - fixed layout allows columns to shrink regardless of content */
table.resizable-columns {
    table-layout: fixed;
}

table.resizable-columns td {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Part# column should never wrap - use wider width to fit values */
th.part-number-col,
td.part-number-cell {
    white-space: nowrap !important;
}

td.part-number-cell div {
    white-space: nowrap !important;
}

/* Resizable column header */
th.resizable {
    position: relative;
    user-select: none;
    overflow: hidden;
}

/* Resize handle - visible on the right edge of the header */
th.resizable .resize-handle {
    position: absolute;
    top: 0;
    right: -2px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    background: linear-gradient(90deg, transparent 0%, rgba(88, 166, 255, 0.4) 50%, transparent 100%);
    z-index: 10;
    border-radius: 3px;
}

/* Show visual indicator on hover */
th.resizable .resize-handle:hover,
th.resizable.resizing .resize-handle {
    background: linear-gradient(90deg, transparent 0%, rgba(88, 166, 255, 0.9) 50%, transparent 100%);
    box-shadow: 0 0 4px rgba(88, 166, 255, 0.6);
}

/* While actively resizing */
th.resizable.resizing {
    background-color: rgba(88, 166, 255, 0.1);
}

/* Prevent text selection while resizing */
.table-resizing {
    user-select: none;
    cursor: col-resize;
}

/* Compact table inputs - fit within narrow columns */
.table-input,
table.resizable-columns input.form-control {
    width: 100% !important;
    min-width: 0 !important;
    padding: 0.15rem 0.25rem !important;
    font-size: 0.75rem !important;
}

table.resizable-columns td {
    padding: 0.15rem 0.25rem;
}

/* Compact table headers */
table.resizable-columns th {
    padding: 0.15rem 0.2rem !important;
    font-size: 0.6rem !important;
    white-space: nowrap;
}
