body {
    background-color: #f8f9fa;
}

.content-section {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.navbar-brand img {
    max-height: 40px;
    width: auto;
}

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.15s ease-in-out;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.dashboard-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.2);
}

.table th {
    border-top: none;
    background-color: #f8f9fa;
    font-weight: 600;
}

.btn {
    border-radius: 0.375rem;
}

.modal-content {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-active {
    background-color: #d1ecf1;
    color: #0c5460;
}

.status-complete {
    background-color: #d4edda;
    color: #155724;
}

.job-polygon {
    stroke-width: 3;
    stroke-opacity: 0.8;
    fill-opacity: 0.5;
}

.job-polygon.pending {
    stroke: #6c757d;
    fill: white;
}

.job-polygon.active {
    stroke: #dc3545;
    fill: #dc3545;
}

.job-polygon.complete {
    stroke: #28a745;
    fill: #28a745;
}

#mapContainer, #jobMapContainer, #dashboardMapContainer, #updateLocationMapContainer {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.custom-cone-icon {
    background: transparent !important;
    border: none !important;
}

.custom-search-icon {
    background: transparent !important;
    border: none !important;
}

.alert {
    border: none;
    border-radius: 0.375rem;
}

.form-control:focus, .form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.dropdown-menu {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.navbar-toggler {
    border: none;
}

.navbar-toggler:focus {
    box-shadow: none;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Low Inventory Warning Styles */
.low-inventory-card {
    border-left: 4px solid #ffc107;
}

.low-inventory-critical {
    border-left-color: #dc3545;
}

.low-inventory-warning {
    border-left-color: #ffc107;
}

/* Arrow Board Styles */
.border-left-orange {
    border-left: 4px solid #fd7e14 !important;
}

#arrowBoardMapContainer {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.custom-div-icon {
    background: transparent !important;
    border: none !important;
}

.low-inventory-table tbody tr.text-danger {
    background-color: rgba(220, 53, 69, 0.1);
}

.low-inventory-table tbody tr.text-warning {
    background-color: rgba(255, 193, 7, 0.1);
}

/* Owner and Type Grouping Containers */
.owner-container {
    margin-bottom: 1.5rem;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.owner-header {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    padding: 0.75rem 1rem;
    margin: 0;
    font-weight: 600;
    font-size: 1.1rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}


.type-container {
    margin: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.type-header {
    background: linear-gradient(135deg, #e9ecef 0%, #f8f9fa 100%);
    color: #495057;
    padding: 0.5rem 0.75rem;
    margin: 0;
    font-weight: 500;
    font-size: 1rem;
    border-bottom: 1px solid #dee2e6;
}


.signs-list {
    padding: 0.75rem;
}

.sign-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid #e9ecef;
    border-radius: 0.25rem;
    background: #fefefe;
    transition: all 0.2s ease;
}

.sign-item:hover {
    background: #f8f9fa;
    border-color: #dee2e6;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sign-item:last-child {
    margin-bottom: 0;
}

/* Owner-specific color schemes */
.owner-container.owner-mes .owner-header {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
}

.owner-container.owner-spartan .owner-header {
    background: linear-gradient(135deg, #198754 0%, #157347 100%);
}

.owner-container.owner-geb .owner-header {
    background: linear-gradient(135deg, #fd7e14 0%, #e8630a 100%);
}

.owner-container.owner-herc .owner-header {
    background: linear-gradient(135deg, #dc3545 0%, #bb2d3b 100%);
}

/* Type-specific styling */

/* Recovery form styling */
.recovery-form-container {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
}

/* Prevent horizontal scrollbar and make containers more compact */
.owner-container, .type-container {
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
}

.type-container {
    margin: 0.75rem;
    margin-bottom: 1rem;
}

.owner-header {
    padding: 0.5rem 1rem;
}

.type-header {
    padding: 0.375rem 0.5rem;
}

.signs-list {
    padding: 0.5rem;
}

.recovery-form-container::-webkit-scrollbar {
    width: 6px;
}

.recovery-form-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.recovery-form-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.recovery-form-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Quantity input field width reduction */
#createJobQuantity,
#assignQuantity,
.recovery-form-container input[type="number"] {
    width: 50% !important;
    max-width: 100px;
}

/* Auto-sizing quantity inputs */
.qty-auto-size {
    width: 3ch !important; /* Default to 2 digits plus some padding */
    min-width: 3ch !important;
    max-width: 8ch !important; /* Reasonable max width */
    text-align: center;
    padding: 0.375rem 0.25rem;
    box-sizing: content-box;
    transition: width 0.1s ease;
}

/* For job details modal quantity inputs */
input[id^="qty_"] {
    width: 3ch !important;
    min-width: 3ch !important;
    max-width: 8ch !important;
    text-align: center;
    padding: 0.375rem 0.25rem;
    box-sizing: content-box;
    transition: width 0.1s ease;
}

/* For recovery modal quantity inputs */
.recovery-form-container input[type="number"] {
    width: 3ch !important;
    min-width: 3ch !important;
    max-width: 8ch !important;
    text-align: center;
    padding: 0.375rem 0.25rem;
    box-sizing: content-box;
    transition: width 0.1s ease;
}

/* Job Details Modal - Prevent horizontal scrollbars */
.modal-body {
    overflow-x: hidden;
    overflow-y: auto;
}

#jobDetailsModal .modal-body,
#partialRecoveryModal .modal-body {
    overflow-x: hidden !important;
    overflow-y: auto;
}

/* Ensure all sign containers handle overflow properly */
.owner-container,
.type-container,
.signs-list {
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Fix input groups that might cause horizontal overflow */
.input-group {
    max-width: 100%;
    min-width: 0;
    flex-wrap: wrap;
}

.input-group .form-control,
.input-group .form-select {
    min-width: 0;
    flex: 1 1 auto;
}

/* Improve text breaking for long content */
.sign-item,
.card-body {
    word-break: break-word;
    hyphens: auto;
}

/* Responsive table handling in modals */
.modal .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.modal .table {
    word-break: break-word;
}

.modal .table td,
.modal .table th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* Better modal width handling */
.modal-xl {
    max-width: calc(100vw - 2rem);
}

@media (min-width: 1200px) {
    .modal-xl {
        max-width: 1140px;
    }
}

/* Job details modal specific fixes */
#jobDetailsModal .modal-body {
    overflow-x: hidden;
}

#jobDetailsModal .row {
    margin-left: 0;
    margin-right: 0;
    overflow-x: hidden;
}

#jobDetailsModal .col-md-1,
#jobDetailsModal .col-md-2,
#jobDetailsModal .col-md-3,
#jobDetailsModal .col-md-6 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Ensure input groups don't exceed their container */
#jobDetailsModal .input-group {
    flex-wrap: nowrap;
    max-width: 100%;
}

#jobDetailsModal .input-group .form-control {
    min-width: 0;
    flex: 1 1 auto;
}

#jobDetailsModal .input-group-text {
    white-space: nowrap;
    font-size: 0.75rem;
}

/* Responsive table improvements */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Prevent long text from causing horizontal scroll */
.owner-container,
.type-container,
.signs-list {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Sign code/description text wrapping */
.sign-item strong,
.owner-container strong {
    word-break: break-word;
    hyphens: auto;
}

/* History content wrapping */
.deployment-history,
.recovery-history {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.deployment-history .small,
.recovery-history .small {
    word-break: break-word;
}

/* Compact buttons for narrow containers */
#jobDetailsModal .btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.375rem;
}

/* Ensure modal doesn't exceed viewport width */
.modal-xl {
    max-width: calc(100vw - 2rem);
    margin: 1rem auto;
}

@media (max-width: 1200px) {
    .modal-xl {
        max-width: calc(100vw - 1rem);
        margin: 0.5rem auto;
    }
}

/* Fix column layouts that might overflow */
@media (max-width: 768px) {
    #jobDetailsModal .col-md-1,
    #jobDetailsModal .col-md-2,
    #jobDetailsModal .col-md-3,
    #jobDetailsModal .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 0.5rem;
    }
    
    #jobDetailsModal .input-group-text {
        display: none;
    }
}

/* Partial recovery modal fixes */
#partialRecoveryModal .modal-body {
    overflow-x: hidden;
}

#partialRecoveryModal .row {
    margin-left: 0;
    margin-right: 0;
    overflow-x: hidden;
}

#partialRecoveryModal .input-group {
    flex-wrap: nowrap;
    max-width: 100%;
}

#partialRecoveryModal .form-control {
    min-width: 0;
}

/* General fixes for all modals with sign cards */
.modal-body .owner-container,
.modal-body .type-container,
.modal-body .signs-list {
    overflow-x: hidden;
    word-wrap: break-word;
}

.modal-body .sign-item {
    overflow-x: hidden;
    word-wrap: break-word;
}

/* Zero quantity sign option styling */
.sign-option-unavailable {
    color: #6c757d !important;
    background-color: #f8f9fa !important;
    opacity: 0.6;
    font-style: italic;
}

/* Modal Z-Index Fixes for Stage Modals Only */
/* Only apply z-index fixes to specific stage modals when they are stacked */
#addStageModal.modal-stacked {
    z-index: 1060 !important;
}

#addSignsToStageModal.modal-stacked {
    z-index: 1060 !important;
}

#stagePartialRecoveryModal.modal-stacked {
    z-index: 1060 !important;
}

#stageRecoveryOptionsModal.modal-stacked {
    z-index: 1060 !important;
}

#deployStageModal.modal-stacked {
    z-index: 1060 !important;
}

#addBillableItemsToStageModal.modal-stacked {
    z-index: 1060 !important;
}

/* Ensure billable items modal always appears above other modals */
#addBillableItemsToStageModal {
    z-index: 1055 !important;
}

#addBillableItemsToStageModal .modal-backdrop {
    z-index: 1054 !important;
}

/* Only apply backdrop z-index when modals are stacked */
.modal-backdrop.backdrop-stacked {
    z-index: 1059 !important;
}

/* Alert Z-Index Fixes - Ensure alerts appear above all modal content */
.alert {
    z-index: 1070 !important;
    position: relative;
}

/* Ensure alert container is positioned to allow z-index to work */
.container-fluid > .alert {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: 500px;
    z-index: 1070 !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
