/* Custom Styles for Facility Maintenance System */

body {
    background-color: #f8f9fa;
}

.navbar-brand {
    font-weight: bold;
}

.content {
    margin-bottom: 2rem;
}

/* Status colors */
.status-new {
    background-color: white !important;
}

.status-assigned {
    background-color: #fff9c4 !important; /* Light yellow */
}

.status-in-progress {
    background-color: #c8e6c9 !important; /* Light green */
}

.status-completed {
    background-color: #bbdefb !important; /* Light blue */
}

.status-cancelled {
    background-color: #ffcdd2 !important; /* Light red */
}

/* Sortable column headers */
th.sortable {
    cursor: pointer;
    position: relative;
}

th.sortable:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

th.sortable::after {
    content: "↕"; /* Default indicator */
    margin-left: 5px;
    font-size: 0.8em;
    opacity: 0.5;
}

th.sortable.asc::after {
    content: "↑"; /* Ascending indicator */
    opacity: 1;
}

th.sortable.desc::after {
    content: "↓"; /* Descending indicator */
    opacity: 1;
}

/* Scrollable issue description */
.issue-cell {
    max-height: 80px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 5px;
    border-radius: 4px;
    background-color: #f9f9f9;
}

/* Priority badges */
.badge-low {
    background-color: #a5d6a7;
    color: #1b5e20;
}

.badge-medium {
    background-color: #fff59d;
    color: #f57f17;
}

.badge-high {
    background-color: #ffab91;
    color: #bf360c;
}

.badge-critical {
    background-color: #ef9a9a;
    color: #b71c1c;
}
th.sortable.active {
  background-color: rgba(0, 123, 255, 0.1);
}

th.sortable.active::after {
  content: " ↓";
  color: #0d6efd;
}
/* Attachment styling */
/* Add these styles to your styles.css file */

/* Attachment items styling */
.attachment-item {
    transition: background-color 0.2s;
    border-radius: 4px;
}

.attachment-item:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.attachment-icon {
    font-size: 1.2rem;
    margin-right: 8px;
}

.attachment-link {
    color: #0d6efd;
    text-decoration: none;
    word-break: break-word;
}

.attachment-link:hover {
    text-decoration: underline;
}

.attachment-date {
    color: #6c757d;
    font-size: 0.85rem;
}
/* Add these styles to your styles.css file */

/* Notes history styling */
.note-item {
    padding: 10px;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 8px;
}

.note-item:last-child {
    border-bottom: none;
}

.note-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.note-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 5px;
}

.note-timestamp {
    font-style: italic;
}

.note-author {
    font-weight: 500;
}

/* Status badges in notes */
.note-status {
    font-weight: 500;
}

.status-change {
    font-style: italic;
    color: #0d6efd;
}
/* Add a max height with scrolling for many attachments */
#viewAttachments {
    max-height: 250px;
    overflow-y: auto;
}

/* Add a file icon to the update attachment input */
.custom-file-upload {
    display: inline-block;
    padding: 6px 12px;
    cursor: pointer;
    background-color: #f8f9fa;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

.custom-file-upload i {
    margin-right: 5px;
}
/* Mobile optimizations */
@media (max-width: 768px) {
    /* Make table rows more readable on mobile */
    #requestsTable td, 
    #equipmentTable td, 
    #locationsTable td {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    
    /* Add some space between filter controls on mobile */
    .filter-controls .form-select,
    .filter-controls .btn {
        margin-bottom: 0.5rem;
    }
    
    /* Make the main content area use the full width */
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Style the Request ID to be more prominent in mobile view */
    #requestsTable td:first-child {
        font-weight: bold;
    }
    
    /* Make action buttons more tappable on mobile */
    .update-btn {
        padding: 0.5rem 0.75rem;
        font-size: 1rem;
    }
}

/* Animation for status transitions */
@keyframes highlight {
    0% { background-color: rgba(255, 241, 118, 0.5); }
    100% { background-color: inherit; }
}

.status-updated {
    animation: highlight 2s;
}

/* Floating action button for mobile */
.floating-action-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #0d6efd;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: none;
}
/* Locations styling */

/* Location table styles */
#locationsTable .location-name {
    font-weight: 500;
}

/* Add animation for loading states */
.spinner-border {
    animation-duration: 0.8s;
}

/* Style for location cards in details view */
.location-card {
    transition: all 0.2s ease-in-out;
    border-left: 4px solid #6c757d;
}

.location-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Style for equipment cards in location view */
#viewLocationEquipment .card-header {
    padding: 0.5rem 1rem;
}

/* Style for notes in location history */
.note-item {
    border-left: 3px solid #007bff;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background-color: #f8f9fa;
}

.note-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #6c757d;
}

/* Tab styling */
.nav-tabs .nav-link {
    color: #495057;
}

.nav-tabs .nav-link.active {
    font-weight: 500;
    color: #007bff;
}

/* Status badges in location requests */
.badge.bg-info {
    background-color: #0dcaf0 !important;
}

.badge.bg-primary {
    background-color: #0d6efd !important;
}

.badge.bg-success {
    background-color: #198754 !important;
}

.badge.bg-danger {
    background-color: #dc3545 !important;
}

.badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000;
}

/* Button styles */
.btn-outline-primary {
    border-color: #0d6efd;
    color: #0d6efd;
}

.btn-outline-primary:hover {
    background-color: #0d6efd;
    color: #fff;
}

.btn-outline-secondary {
    border-color: #6c757d;
    color: #6c757d;
}

.btn-outline-secondary:hover {
    background-color: #6c757d;
    color: #fff;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    #locationsTable th:nth-child(1), 
    #locationsTable td:nth-child(1) {
        display: none; /* Hide ID column on mobile */
    }
    
    .action-buttons-cell {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .action-buttons-cell .btn {
        width: 100%;
        margin-bottom: 0.25rem;
    }
}
@media (max-width: 768px) {
    .floating-action-btn {
        display: flex;
    }
}

/* ============================================================
   Calendar (Schedule) view
   ============================================================ */

/* Desktop: 7 equal day columns */
/* Desktop: matrix of crew-member rows x Mon-Sat columns */
.cal-grid {
    display: grid;
    grid-template-columns: 110px repeat(6, 1fr);
    gap: 0.35rem;
}

.cal-corner {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Day headers are standalone grid cells on desktop (inside .cal-day on mobile) */
.cal-grid > .cal-day-header {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.cal-day-header.cal-today {
    background: #e7f1ff;
    color: #0d6efd;
    border-color: #0d6efd;
}

.cal-row-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    padding: 0.35rem 0.5rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.85rem;
    overflow: hidden;
}

.cal-row-name-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-row-unassigned {
    color: #6c757d;
    font-style: italic;
    font-weight: 400;
}

.cal-row-delete {
    border: none;
    background: transparent;
    color: #adb5bd;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.15rem;
    cursor: pointer;
    border-radius: 0.25rem;
}

.cal-row-delete:hover {
    color: #dc3545;
    background: #fdf3f4;
}

/* A single crew-member x day cell (drop target) */
.cal-cell {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    min-height: 64px;
    padding: 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.cal-today-cell {
    background: #f5f9ff;
    border-color: #b6d4fe;
}

.cal-add-crew-row {
    grid-column: 1 / -1;
}

.cal-add-crew-input {
    max-width: 400px;
}

.cal-add-crew-input .form-control {
    min-width: 0; /* let the input shrink instead of pushing into the buttons */
}

.cal-corner-add {
    width: 100%;
    white-space: nowrap;
}

.cal-crew-hint {
    grid-column: 1 / -1;
    padding: 0.25rem 0;
}

/* Loading spinner / error message spans the whole grid */
.cal-loading {
    grid-column: 1 / -1;
}

/* Crew-name subheadings inside mobile day cards */
.cal-crew-subhead {
    font-size: 0.72rem;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0.2rem;
}

.cal-day {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.cal-day-header {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 0.375rem 0.375rem 0 0;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.cal-day-num {
    color: #6c757d;
    font-weight: 400;
    font-size: 0.8rem;
}

.cal-day-body {
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-grow: 1;
}

/* Today highlight */
.cal-today {
    border-color: #0d6efd;
    box-shadow: 0 0 0 1px #0d6efd inset;
}

.cal-today .cal-day-header {
    background: #e7f1ff;
    color: #0d6efd;
}

/* Request chips */
.cal-chip {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-left: 4px solid #6c757d; /* priority color set inline */
    border-radius: 0.25rem;
    padding: 0.3rem 0.45rem;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.cal-chip:hover {
    background: #eef2f6;
}

.cal-chip-top {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    flex-wrap: wrap; /* let "Assigned: name" wrap instead of clipping */
}

.cal-chip-assigned {
    color: #0d6efd;
    font-weight: 600;
    font-size: 0.72rem;
    text-align: left;
}

.cal-chip-id {
    color: #6c757d;
    font-size: 0.72rem;
}

.cal-chip-loc {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-chip-desc {
    color: #343a40;
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Leadership-pinned chips */
.cal-chip-pinned {
    border: 2px solid #dc3545;
    border-left-width: 4px;
    background: #fdf3f4;
}

.cal-chip-pin {
    font-size: 0.8rem;
}

/* Drag states */
.cal-dragging {
    opacity: 0.5;
}

.cal-drop-hover {
    background-color: #e7f1ff !important;
    border-color: #0d6efd !important;
}

/* Unscheduled tray */
.cal-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 44px;
}

.cal-tray .cal-chip {
    flex: 0 1 220px;
}

/* Legend */
.cal-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 3px;
    vertical-align: baseline;
}

/* Mobile: stacked day cards */
@media (max-width: 767.98px) {
    .cal-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .cal-day {
        min-height: 0;
    }

    .cal-day-body {
        min-height: 40px;
    }

    .cal-day-header {
        font-size: 0.9rem;
    }

    .cal-chip {
        font-size: 0.85rem;
        padding: 0.45rem 0.55rem; /* bigger touch target */
    }

    .cal-tray .cal-chip {
        flex: 1 1 100%;
    }
}
