/* Custom DVIRs Table Styling - Similar to DVIR Defects table */
.dvirs-responsive-table {
    min-width: 1200px;
    font-size: 1rem;
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    background: white;
}

.dvirs-responsive-table th {
    background-color: #2c3e50;
    color: white;
    padding: 8px 18px 8px 4px;
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    transition: background-color 0.2s;
    text-align: left;
}

.dvirs-responsive-table th:hover {
    background-color: #34495e;
}

.dvirs-responsive-table td {
    padding: 5px 3px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.78rem;
    white-space: nowrap;
    text-align: left;
    vertical-align: top;
}

.dvirs-responsive-table tbody tr:hover {
    background-color: #f5f5f5;
}

.dvirs-responsive-table a {
    color: #0066cc;
    text-decoration: none;
}

.dvirs-responsive-table a:hover {
    text-decoration: underline;
}

/* Desktop column widths for DVIRs table */
@media (min-width: 769px) {
    .dvirs-responsive-table {
        min-width: 1200px;
    }

    .dvirs-responsive-table th:nth-child(1),
    .dvirs-responsive-table td:nth-child(1) { width: 5%; min-width: 40px; }  /* Truck */
    .dvirs-responsive-table th:nth-child(2),
    .dvirs-responsive-table td:nth-child(2) { width: 10%; min-width: 80px; }  /* SITE */
    .dvirs-responsive-table th:nth-child(3),
    .dvirs-responsive-table td:nth-child(3) { width: 10%; min-width: 80px; }  /* Driver */
    .dvirs-responsive-table th:nth-child(4),
    .dvirs-responsive-table td:nth-child(4) { width: 6%; min-width: 30px; }  /* Status */
    .dvirs-responsive-table th:nth-child(5),
    .dvirs-responsive-table td:nth-child(5) { width: 4%; min-width: 20px; }    /* Failures - SMALL! */
    .dvirs-responsive-table th:nth-child(6),
    .dvirs-responsive-table td:nth-child(6) { width: 8%; min-width: 80px; }  /* Submitted */
    .dvirs-responsive-table th:nth-child(7),
    .dvirs-responsive-table td:nth-child(7) { width: 5%; min-width: 50px; }   /* Duration */
    .dvirs-responsive-table th:nth-child(8),
    .dvirs-responsive-table td:nth-child(8) { width: 12%; min-width: 70px; }    /* Action column */
}

/* Tablet layout for DVIRs table */
@media (max-width: 768px) and (min-width: 481px) {
    .dvirs-responsive-table {
        min-width: 900px;
        font-size: 0.85rem;
    }

    .dvirs-responsive-table th,
    .dvirs-responsive-table td {
        padding: 0.6rem 0.4rem;
    }

    .dvirs-responsive-table th:nth-child(1),
    .dvirs-responsive-table td:nth-child(1) { width: 15%; min-width: 80px; }   /* Truck */
    .dvirs-responsive-table th:nth-child(2),
    .dvirs-responsive-table td:nth-child(2) { width: 25%; min-width: 150px; }  /* SITE */
    .dvirs-responsive-table th:nth-child(3),
    .dvirs-responsive-table td:nth-child(3) { width: 20%; min-width: 120px; }  /* Driver */
    .dvirs-responsive-table th:nth-child(4),
    .dvirs-responsive-table td:nth-child(4) { width: 12%; min-width: 80px; }   /* Status */
    .dvirs-responsive-table th:nth-child(5),
    .dvirs-responsive-table td:nth-child(5) { width: 8%; min-width: 50px; }    /* Failures - SMALL! */
    .dvirs-responsive-table th:nth-child(6),
    .dvirs-responsive-table td:nth-child(6) { width: 12%; min-width: 90px; }   /* Submitted */
    .dvirs-responsive-table th:nth-child(7),
    .dvirs-responsive-table td:nth-child(7) { width: 8%; min-width: 60px; }    /* Duration */
    .dvirs-responsive-table th:nth-child(8),
    .dvirs-responsive-table td:nth-child(8) { width: 0; display: none; }       /* Action column - hidden on tablet */
}

/* Mobile card layout for DVIRs table */
@media (max-width: 480px) {
    .table-container {
        overflow: visible;
    }

    .dvirs-responsive-table {
        display: block;
        width: 100%;
        border: none;
        background: transparent;
    }

    .dvirs-responsive-table thead {
        display: none;
    }

    .dvirs-responsive-table tbody {
        display: block;
        width: 100%;
    }

    .dvirs-responsive-table tr {
        display: block;
        border: 1px solid #ddd;
        border-radius: 8px;
        background: white;
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .dvirs-responsive-table td {
        display: block;
        border: none;
        padding: 0.5rem 0;
        text-align: left;
        position: relative;
        padding-left: 35%;
        min-height: 40px;
        word-wrap: break-word;
        overflow-wrap: anywhere;
    }

    .dvirs-responsive-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        top: 0.5rem;
        width: 30%;
        font-weight: bold;
        color: #666;
        font-size: 0.85rem;
        line-height: 1.4;
    }

    /* Mobile card labels */
    .dvirs-responsive-table td:nth-child(1):before { content: "Truck: "; }
    .dvirs-responsive-table td:nth-child(2):before { content: "Site: "; }
    .dvirs-responsive-table td:nth-child(3):before { content: "Driver: "; }
    .dvirs-responsive-table td:nth-child(4):before { content: "Status: "; }
    .dvirs-responsive-table td:nth-child(5):before { content: "Failures: "; }
    .dvirs-responsive-table td:nth-child(6):before { content: "Submitted: "; }
    .dvirs-responsive-table td:nth-child(7):before { content: "Duration: "; }
    .dvirs-responsive-table td:nth-child(8):before { content: "Action: "; }

    .dvirs-responsive-table td:last-child {
        border-bottom: none;
        padding-top: 1rem;
        padding-left: 0;
        text-align: center;
    }

    .dvirs-responsive-table td:last-child:before {
        display: none;
    }
}

/* Smaller action buttons */
.action-btn-small {
    display: block;
    width: 100%;
    padding: 4px 12px;
    font-size: 0.75rem;
    background-color: #0066cc;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.action-btn-small:hover {
    background-color: #0052a3;
}

.action-btn-small:active {
    background-color: #004085;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #888;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 16px 20px;
    background-color: #474747;
    color: white;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover,
.modal-close:focus {
    color: #ccc;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.form-group input[readonly] {
    background-color: #f5f5f5;
    color: #666;
    cursor: not-allowed;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.modal-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-footer .action-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    min-width: 80px;
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }

    .modal-header h2 {
        font-size: 1.2rem;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .action-btn {
        width: 100%;
    }
}

/* Search controls - pointer cursor by default */
.search-controls-container input[type="text"],
.search-controls-container .filter-select {
    cursor: pointer;
}

.search-controls-container input[type="text"]:focus,
.search-controls-container .filter-select:focus {
    cursor: text;
}
