/* Machinery Maintenance Management - CSS */
:root {
    --primary-color: #1e40af;
    --secondary-color: #3b82f6;
    --accent-color: #f59e0b;
    --success-color: #059669;
    --danger-color: #dc2626;
    --dark-color: #1f2937;
    --light-gray: #f8fafc;
    --border-color: #e2e8f0;
}

body {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    font-family: 'Inter', sans-serif;
    color: var(--dark-color);
    min-height: 100vh;
}

/* Header Section */
.header-section {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.company-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.company-info h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.company-info p {
    font-size: 0.9rem;
    color: #64748b;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Main Container */
.main-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin: 2rem auto;
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Action Bar */
.action-bar {
    background: var(--light-gray);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-left: 4px solid var(--primary-color);
}

/* Search Section */
.search-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

/* Custom Buttons */
.btn-custom {
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-weight: 500;
    border: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary-custom {
    background: var(--primary-color);
    color: white;
}

.btn-primary-custom:hover {
    background: #1d4ed8;
    color: white;
    transform: translateY(-1px);
}

.btn-success-custom {
    background: var(--success-color);
    color: white;
}

.btn-success-custom:hover {
    background: #047857;
    color: white;
    transform: translateY(-1px);
}

.btn-danger-custom {
    background: var(--danger-color);
    color: white;
}

.btn-danger-custom:hover {
    background: #b91c1c;
    color: white;
    transform: translateY(-1px);
}

.btn-warning-custom {
    background: var(--accent-color);
    color: white;
}

.btn-warning-custom:hover {
    background: #d97706;
    color: white;
    transform: translateY(-1px);
}

/* Data Table */
.data-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.table {
    margin: 0;
}

.table th {
    background: var(--light-gray);
    color: var(--dark-color);
    font-weight: 600;
    border: none;
    padding: 1rem 0.75rem;
    white-space: nowrap;
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-color: var(--border-color);
}

.table tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.05);
}

/* Modal Styling */
.modal-header {
    background: var(--light-gray);
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    color: var(--dark-color);
    font-weight: 600;
}

/* Form Elements */
.form-label {
    font-weight: 500;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

/* Select2 Styling */
.select2-container--default .select2-selection--single {
    height: 38px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 26px;
    padding: 0;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

/* Alerts */
.alert {
    border-radius: 6px;
    border: none;
}

/* Badges */
.badge {
    font-weight: 500;
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    transition: border-color 0.2s ease;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: var(--secondary-color);
}

.file-upload-area.dragover {
    border-color: var(--secondary-color);
    background-color: rgba(59, 130, 246, 0.05);
}

/* Bill Preview */
.bill-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.bill-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.bill-link:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* Statistics Cards */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
    color: white;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: #64748b;
}

/* Pagination */
.pagination {
    margin-top: 1rem;
}

.pagination .page-link {
    border-radius: 6px;
    margin: 0 2px;
    border: 1px solid var(--border-color);
    color: var(--dark-color);
    transition: all 0.2s ease;
}

.pagination .page-link:hover {
    background-color: var(--light-gray);
    border-color: var(--secondary-color);
    transform: translateY(-1px);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .company-header {
        text-align: center;
        flex-direction: column;
        gap: 1rem;
    }
    
    .main-container {
        margin: 1rem;
        padding: 1rem;
    }
    
    .page-title {
        font-size: 1.5rem;
        text-align: center;
    }
    
    .stats-cards {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .action-bar {
        padding: 1rem;
    }
    
    .search-section {
        padding: 1rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-custom {
        width: 100%;
        justify-content: center;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
}

@media (max-width: 576px) {
    .stats-cards {
        grid-template-columns: 1fr 1fr;
    }
    
    .page-title {
        font-size: 1.25rem;
        flex-direction: column;
        text-align: center;
        gap: 0.25rem;
    }
    
    .company-info h1 {
        font-size: 1.25rem;
    }
    
    .table th, .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
}

/* Animation Enhancements */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-container {
    animation: fadeIn 0.3s ease-out;
}

.stat-card {
    animation: fadeIn 0.4s ease-out;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

/* Accessibility Improvements */
.btn-custom:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .header-section,
    .action-bar,
    .search-section,
    .pagination,
    .modal,
    .btn-custom {
        display: none !important;
    }
    
    .main-container {
        box-shadow: none;
        margin: 0;
        padding: 1rem;
    }
    
    body {
        background: white;
    }
    
    .table {
        font-size: 12px;
    }
    
    .page-title {
        border-bottom: 2px solid var(--primary-color);
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
    }
}

/* Additional CSS for Dynamic Statistics in maintenance_styles.css */

/* Filtered statistics indicator */
.stat-card.filtered-stats {
    border-left: 4px solid var(--accent-color);
    background: linear-gradient(135deg, #fff 0%, #fefbf3 100%);
    position: relative;
}

.stat-card.filtered-stats::before {
    content: "FILTERED";
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--accent-color);
    color: white;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

/* Animation for statistics updates */
.stat-value {
    transition: all 0.3s ease;
}

.stat-card:hover.filtered-stats {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.15);
}

/* Filter summary styling */
#filterSummary {
    border-left: 4px solid var(--accent-color);
    background: linear-gradient(135deg, #fefbf3 0%, #fff 100%);
    border-color: var(--accent-color);
}

#filterSummary .badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
}

/* Loading state for statistics */
.stat-value .spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Enhanced statistics cards layout */
.stats-cards {
    margin-bottom: 1.5rem;
    position: relative;
}

/* Statistics comparison tooltip */
.stat-card[title] {
    cursor: help;
}

/* Mobile responsive updates for filtered stats */
@media (max-width: 768px) {
    .stat-card.filtered-stats::before {
        font-size: 0.5rem;
        padding: 1px 4px;
        top: 6px;
        right: 6px;
    }
    
    #filterSummary .badge {
        font-size: 0.7rem;
        margin-bottom: 0.25rem;
    }
}

/* Enhanced visual feedback for statistics changes */
@keyframes statUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); background-color: var(--success-color); color: white; }
    100% { transform: scale(1); }
}

.stat-value.updating {
    animation: statUpdate 0.6s ease-in-out;
}

/* Filter summary badges hover effect */
#filterSummary .badge:hover {
    transform: scale(1.05);
    cursor: pointer;
}

/* Clear filters button in summary */
#filterSummary .btn-close {
    background-size: 0.75em;
}

#filterSummary .btn-close:hover {
    background-color: var(--danger-color);
    opacity: 1;
}

/* Additional CSS for Blank Field Filter in maintenance_styles.css */

/* Enhanced search section styling */
.search-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Blank field filter specific styling */
#filterBlankField {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

#filterBlankField:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.2rem rgba(245, 158, 11, 0.25);
    background: white;
}

/* Quick filter buttons styling */
.search-section .btn-outline-info:hover {
    background-color: #0ea5e9;
    border-color: #0ea5e9;
    color: white;
    transform: translateY(-1px);
}

.search-section .btn-outline-success:hover {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: white;
    transform: translateY(-1px);
}

.search-section .btn-outline-warning:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    transform: translateY(-1px);
}

.search-section .btn-outline-secondary:hover {
    background-color: #6b7280;
    border-color: #6b7280;
    color: white;
    transform: translateY(-1px);
}

/* Active filter indication for blank field filter */
#filterBlankField:not([value=""]) {
    background: linear-gradient(135deg, #fef3c7 0%, #fbbf24 100%);
    border-color: var(--accent-color);
    font-weight: 600;
    color: #92400e;
}

/* Enhanced filter summary for blank field */
#filterSummary .badge {
    transition: all 0.2s ease;
}

#filterSummary .badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Special styling for blank field filter badge */
#filterSummary .badge:contains("Exclude Blank") {
    background-color: var(--accent-color) !important;
    color: white;
}

/* Advanced filters section */
.search-section .row:nth-child(2) {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: 1rem;
}

/* Quick filter buttons container */
.search-section .d-flex.gap-2.flex-wrap {
    min-height: 38px;
    align-items: center;
}

/* Filter actions section */
.search-section .row:last-child {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: 1rem;
    background: var(--light-gray);
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    margin-bottom: -1.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    padding-bottom: 1rem;
    border-radius: 0 0 8px 8px;
}

/* Save/Load filter buttons */
.btn-outline-info.btn-sm,
.btn-outline-secondary.btn-sm {
    font-size: 0.8rem;
    padding: 0.375rem 0.75rem;
    transition: all 0.2s ease;
}

.btn-outline-info.btn-sm:hover {
    background-color: #0ea5e9;
    border-color: #0ea5e9;
    transform: translateY(-1px);
}

/* Tooltip styling for filter elements */
.tooltip {
    font-size: 0.8rem;
}

.tooltip-inner {
    background-color: var(--dark-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

/* Animation for filter application */
@keyframes filterApplied {
    0% { background-color: transparent; }
    50% { background-color: rgba(245, 158, 11, 0.2); }
    100% { background-color: transparent; }
}

.search-section.filter-applied {
    animation: filterApplied 0.6s ease-in-out;
}

/* Responsive design for advanced filters */
@media (max-width: 768px) {
    .search-section .row.g-3 > div {
        margin-bottom: 1rem;
    }
    
    .search-section .d-flex.gap-2.flex-wrap {
        flex-direction: column;
        gap: 0.5rem !important;
    }
    
    .search-section .d-flex.gap-2.flex-wrap .btn {
        width: 100%;
        justify-content: center;
    }
    
    .search-section .d-flex.gap-2.justify-content-between {
        flex-direction: column;
        gap: 1rem !important;
    }
    
    .search-section .d-flex.gap-2.justify-content-between > div {
        width: 100%;
    }
    
    .search-section .d-flex.gap-2.justify-content-between .d-flex {
        justify-content: center;
    }
}

/* Enhanced form control styling for consistency */
.search-section .form-control,
.search-section .form-select {
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.search-section .form-control:focus,
.search-section .form-select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15);
}

/* Label styling consistency */
.search-section .form-label {
    font-weight: 500;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.search-section .form-label i {
    color: var(--secondary-color);
}

/* Small text styling */
.search-section small {
    font-size: 0.8rem;
    line-height: 1.3;
}

.search-section small i {
    opacity: 0.7;
}

/* Button group spacing in actions column */
.search-section .d-flex.gap-1 .btn {
    min-width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Focus indicators for accessibility */
.search-section .btn:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

.search-section .form-control:focus,
.search-section .form-select:focus {
    outline: none;
}

/* Loading state for search section */
.search-section.loading {
    opacity: 0.7;
    pointer-events: none;
}

.search-section.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

/* Add this CSS to maintenance_styles.css or add as a <style> block in index.html */

/* Enhanced table column widths with wider machine column */
.data-table .table th,
.data-table .table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Specific column width adjustments */
.data-table .table th:nth-child(1), /* Date */
.data-table .table td:nth-child(1) {
    width: 100px;
    min-width: 100px;
}

.data-table .table th:nth-child(2), /* Site */
.data-table .table td:nth-child(2) {
    width: 100px;
    min-width: 100px;
}

.data-table .table th:nth-child(3), /* Machine - INCREASED WIDTH */
.data-table .table td:nth-child(3) {
    width: 200px;
    min-width: 200px;
}

.data-table .table th:nth-child(4), /* Type */
.data-table .table td:nth-child(4) {
    width: 120px;
    min-width: 120px;
}

.data-table .table th:nth-child(5), /* Maintenance Type */
.data-table .table td:nth-child(5) {
    width: 140px;
    min-width: 140px;
}

.data-table .table th:nth-child(6), /* Particulars */
.data-table .table td:nth-child(6) {
    width: 250px;
    min-width: 200px;
    white-space: normal;
    word-wrap: break-word;
}

.data-table .table th:nth-child(7), /* Qty */
.data-table .table td:nth-child(7) {
    width: 80px;
    min-width: 80px;
    text-align: center;
}

.data-table .table th:nth-child(8), /* Amount */
.data-table .table td:nth-child(8) {
    width: 120px;
    min-width: 120px;
    text-align: right;
}

.data-table .table th:nth-child(9), /* Required By */
.data-table .table td:nth-child(9) {
    width: 140px;
    min-width: 140px;
}

.data-table .table th:nth-child(10), /* Bill */
.data-table .table td:nth-child(10) {
    width: 80px;
    min-width: 80px;
    text-align: center;
}

.data-table .table th:nth-child(11), /* Actions */
.data-table .table td:nth-child(11) {
    width: 100px;
    min-width: 100px;
    text-align: center;
}

/* Machine column specific styling */
.data-table .table td:nth-child(3) {
    white-space: normal;
    line-height: 1.3;
}

.data-table .table td:nth-child(3) .fw-bold {
    font-size: 0.95rem;
    margin-bottom: 2px;
    display: block;
}

.data-table .table td:nth-child(3) .text-muted {
    font-size: 0.85rem;
    line-height: 1.2;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .data-table .table th:nth-child(3),
    .data-table .table td:nth-child(3) {
        width: 150px;
        min-width: 150px;
    }
    
    .data-table .table td:nth-child(3) .fw-bold {
        font-size: 0.9rem;
    }
    
    .data-table .table td:nth-child(3) .text-muted {
        font-size: 0.8rem;
    }
}

@media (max-width: 576px) {
    .data-table .table th:nth-child(3),
    .data-table .table td:nth-child(3) {
        width: 120px;
        min-width: 120px;
    }
    
    .data-table .table td:nth-child(3) .fw-bold {
        font-size: 0.85rem;
    }
    
    .data-table .table td:nth-child(3) .text-muted {
        font-size: 0.75rem;
    }
}