/* Equipment Status Colors */
.equipment-status-operational {
    background-color: #d1fae5;
    color: #065f46;
}

.equipment-status-needs-maintenance {
    background-color: #fef3c7;
    color: #92400e;
}

.equipment-status-under-maintenance {
    background-color: #dbeafe;
    color: #1e40af;
}

.equipment-status-out-of-service {
    background-color: #fee2e2;
    color: #991b1b;
}

.equipment-status-retired {
    background-color: #e5e7eb;
    color: #4b5563;
}

/* Maintenance Status Colors */
.maintenance-status-scheduled {
    background-color: #dbeafe;
    color: #1e40af;
}

.maintenance-status-in-progress {
    background-color: #fef3c7;
    color: #92400e;
}

.maintenance-status-completed {
    background-color: #d1fae5;
    color: #065f46;
}

.maintenance-status-overdue {
    background-color: #fee2e2;
    color: #991b1b;
}

.maintenance-status-cancelled {
    background-color: #e5e7eb;
    color: #4b5563;
}

/* Maintenance Priority Colors */
.maintenance-priority-low {
    background-color: #e5e7eb;
    color: #4b5563;
}

.maintenance-priority-normal {
    background-color: #dbeafe;
    color: #1e40af;
}

.maintenance-priority-high {
    background-color: #fef3c7;
    color: #92400e;
}

.maintenance-priority-critical {
    background-color: #fee2e2;
    color: #991b1b;
}

/* File Upload Styles */
.file-upload-zone {
    border: 2px dashed var(--bs-border-color);
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.file-upload-zone:hover {
    border-color: #4f46e5;
    background-color: var(--bs-tertiary-bg);
}

.file-upload-zone.dragover {
    border-color: #4f46e5;
    background-color: var(--bs-primary-bg-subtle);
}

/* Timeline Styles */
.timeline {
    position: relative;
    padding-left: 0;
}

.timeline-item {
    position: relative;
    padding-left: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 17px;
    top: 40px;
    bottom: -20px;
    width: 2px;
    background-color: var(--bs-border-color);
}

.timeline-item:last-child::before {
    display: none;
}

/* Alert Permanent */
.alert-permanent {
    /* Prevents auto-dismiss */
}

/* Custom Badge Styles */
.badge {
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
}

/* Loading State */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* Responsive Table */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Custom Form Styles */
.form-control,
.form-select {
    border: 1.5px solid #9ca3af;
}

.form-control:focus,
.form-select:focus {
    border-color: #4f46e5;
    border-width: 1.5px;
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.25);
}

/* Equipment Card Styles */
.equipment-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.equipment-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Maintenance Badge Glow */
.badge-glow-critical {
    animation: glow-critical 2s infinite;
}

@keyframes glow-critical {
    0%, 100% {
        box-shadow: 0 0 5px rgba(220, 38, 38, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(220, 38, 38, 0.8);
    }
}


/* Sortable Column Styles */
th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    background-color: var(--bs-tertiary-bg);
}

th.sortable a {
    display: block;
    padding: 0.5rem;
    margin: -0.5rem;
}

th.sortable a:hover {
    text-decoration: none !important;
}

th.sortable i {
    font-size: 0.875rem;
    opacity: 0.6;
}

th.sortable:hover i {
    opacity: 1;
}

/* Pagination Styles */
.pagination {
    margin-bottom: 0;
}

.pagination .page-link {
    color: var(--bs-body-color);
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color);
}

.pagination .page-item.active .page-link {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: var(--bs-secondary-color);
    pointer-events: none;
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color);
}

.pagination .page-link:hover {
    background-color: var(--bs-tertiary-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

.form-select-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Mobile Responsiveness - Stats Cards (deprecated - now using compact card) */

/* Mobile Touch Optimization */
@media (max-width: 768px) {
    /* Touch Target Sizes - Minimum 44px */
    .btn, .btn-sm {
        min-height: 44px;
        padding: 0.625rem 1rem;
        font-size: 0.9375rem;
    }

    .btn-group .btn {
        min-width: 44px;
        padding: 0.625rem;
    }

    .form-control, .form-select {
        min-height: 44px;
        font-size: 1rem;
    }

    .pagination .page-link {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Modal Optimization */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-title {
        font-size: 1.125rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
        min-width: 120px;
    }

    /* Form Layout Optimization */
    .row.g-3 > [class*="col-md-"] {
        width: 100%;
        max-width: 100%;
    }

    .row.g-3 > .col-6 {
        width: 50%;
        max-width: 50%;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header {
        padding: 0.75rem 1rem;
    }
}

/* Mobile Tab Selector for Settings Pages */
#mobileTabSelector {
    font-size: 1rem;
    font-weight: 500;
    border: 2px solid var(--bs-border-color);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    cursor: pointer;
}

#mobileTabSelector:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

@media (max-width: 767px) {
    /* Ensure tab content has proper spacing on mobile */
    .tab-content {
        margin-top: 0 !important;
    }

    .tab-content .card {
        margin-top: 0 !important;
    }
}

/* Validation - Hide empty validation summary */
.validation-summary-valid {
    display: none !important;
}

/* ===== Dark Mode Overrides ===== */

/* Equipment status badges */
[data-bs-theme="dark"] .equipment-status-operational {
    background-color: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

[data-bs-theme="dark"] .equipment-status-needs-maintenance {
    background-color: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

[data-bs-theme="dark"] .equipment-status-under-maintenance {
    background-color: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}

[data-bs-theme="dark"] .equipment-status-out-of-service {
    background-color: rgba(248, 113, 113, 0.2);
    color: #f87171;
}

[data-bs-theme="dark"] .equipment-status-retired {
    background-color: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
}

/* Maintenance status badges */
[data-bs-theme="dark"] .maintenance-status-scheduled {
    background-color: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}

[data-bs-theme="dark"] .maintenance-status-in-progress {
    background-color: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

[data-bs-theme="dark"] .maintenance-status-completed {
    background-color: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

[data-bs-theme="dark"] .maintenance-status-overdue {
    background-color: rgba(248, 113, 113, 0.2);
    color: #f87171;
}

[data-bs-theme="dark"] .maintenance-status-cancelled {
    background-color: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
}

/* Maintenance priority badges */
[data-bs-theme="dark"] .maintenance-priority-low {
    background-color: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
}

[data-bs-theme="dark"] .maintenance-priority-normal {
    background-color: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}

[data-bs-theme="dark"] .maintenance-priority-high {
    background-color: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

[data-bs-theme="dark"] .maintenance-priority-critical {
    background-color: rgba(248, 113, 113, 0.2);
    color: #f87171;
}

/* bg-warning text-dark and bg-info text-dark badges:
   In dark mode Bootstrap changes --bs-dark to a light gray,
   which gives poor contrast on yellow/cyan backgrounds.
   Force dark text so contrast is maintained. */
[data-bs-theme="dark"] .bg-warning {
    color: #000 !important;
}

[data-bs-theme="dark"] .bg-info {
    color: #000 !important;
}

/* ============================================================
   Tom Select — dark mode fixes
   Tom Select's Bootstrap 5 theme hardcodes color:#343a40 which
   is near-invisible on Bootstrap's dark body background. Using
   html prefix for maximum specificity; all colours hard-coded to
   avoid CSS variable resolution issues.
   ============================================================ */

/* Control box */
html[data-bs-theme="dark"] .ts-control {
    color: #dee2e6 !important;
    background-color: #212529 !important;
    border-color: #495057 !important;
}
html[data-bs-theme="dark"] .ts-control input {
    color: #dee2e6 !important;
}
html[data-bs-theme="dark"] .ts-control input::placeholder {
    color: #6c757d !important;
}

/* Selected item text */
html[data-bs-theme="dark"] .ts-control .item {
    color: #dee2e6 !important;
}

/* Dropdown panel */
html[data-bs-theme="dark"] .ts-dropdown {
    color: #dee2e6 !important;
    background-color: #2b3035 !important;
    border-color: #495057 !important;
}

/* Every option row — override cascaded #343a40 from Tom Select theme */
html[data-bs-theme="dark"] .ts-dropdown .option,
html[data-bs-theme="dark"] .ts-dropdown .no-results,
html[data-bs-theme="dark"] .ts-dropdown .optgroup-header,
html[data-bs-theme="dark"] .ts-dropdown .create {
    color: #dee2e6 !important;
    background-color: #2b3035 !important;
}

/* Highlighted (hover/keyboard) option */
html[data-bs-theme="dark"] .ts-dropdown .option.active,
html[data-bs-theme="dark"] .ts-dropdown .active {
    background-color: #0d6efd !important;
    color: #fff !important;
}

/* Multi-select chips */
html[data-bs-theme="dark"] .ts-wrapper.multi .ts-control > div {
    background: #343a40 !important;
    color: #dee2e6 !important;
    border-color: #495057 !important;
}

/* Dropdown caret arrow — swap dark SVG for a light one */
html[data-bs-theme="dark"] .ts-wrapper:not(.form-control, .form-select).single .ts-control {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23dee2e6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
    background-position: right .75rem center;
    background-repeat: no-repeat;
    background-size: 16px 12px;
}

/* Search field inside open dropdown */
html[data-bs-theme="dark"] .ts-dropdown .dropdown-input {
    color: #dee2e6 !important;
    background: #212529 !important;
    border-color: #495057 !important;
}

/* ============================================================
   Item wizard (Quotes/Create, Jobs/Create, Jobs/Edit) — dark mode
   The inline styles in these views hardcode #fff/#fafafa/#dee2e6.
   ============================================================ */
[data-bs-theme="dark"] .item-type-card {
    background: var(--bs-secondary-bg) !important;
    border-color: var(--bs-border-color) !important;
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .item-type-card:hover {
    border-color: #86b7fe !important;
    background: rgba(13, 110, 253, 0.15) !important;
}

[data-bs-theme="dark"] .item-type-card.selected {
    border-color: #0d6efd !important;
    background: rgba(13, 110, 253, 0.2) !important;
}

[data-bs-theme="dark"] .quote-item-card {
    background: var(--bs-secondary-bg) !important;
    border-color: var(--bs-border-color) !important;
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .coat-row {
    border-color: var(--bs-border-color) !important;
    background: var(--bs-body-bg);
}

[data-bs-theme="dark"] .wizard-step-dot {
    background: var(--bs-secondary-bg) !important;
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .wizard-step-line {
    background: var(--bs-border-color) !important;
}

/* ============================================================
   Tag chip input widget
   ============================================================ */

/* Chips area sits below the input — input height never changes */
.tag-chips-area {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

/* Remove × inside each chip */
.tag-chip .tag-remove {
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    vertical-align: middle;
}
.tag-chip .tag-remove:hover {
    opacity: 1;
}

/* Clickable tag links in Index grids — hover darkens slightly */
a.tag-index-badge:hover {
    filter: brightness(0.88);
    text-decoration: none;
}
