/* Visit History Table Fix - Ensure table fits within container */

/* Fix table container */
.visit-history-card {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    margin: 0 0 2rem 0;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.visit-history-body {
    padding: 0;
    width: 100%;
    overflow: hidden;
}

/* Fix responsive wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0;
    padding: 0;
}

/* Fix the table itself */
#visit-history {
    width: 100% !important;
    table-layout: fixed !important;
    margin: 0;
    border: none;
}

/* Adjust column widths for better fit */
#visit-history thead th {
    padding: 1rem 0.75rem;
    font-size: 0.7rem;
    white-space: normal;
    word-wrap: break-word;
}

/* Set specific column widths */
#visit-history thead th:nth-child(1), /* Check-in */
#visit-history thead th:nth-child(2) { /* Check-out */
    width: 15%;
    min-width: 100px;
}

#visit-history thead th:nth-child(3), /* Building */
#visit-history thead th:nth-child(4) { /* Location */
    width: 15%;
    min-width: 80px;
}

#visit-history thead th:nth-child(5) { /* Reason */
    width: 25%;
    min-width: 120px;
}

#visit-history thead th:nth-child(6) { /* Notes/Case */
    width: 15%;
    min-width: 100px;
}

/* Adjust cell padding and content */
#visit-history tbody td {
    padding: 0.75rem 0.75rem;
    font-size: 0.813rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Fix date/time display */
.checkin-time,
.checkout-time {
    display: block;
    font-size: 0.875rem;
    line-height: 1.4;
}

.checkin-time i,
.checkout-time i {
    display: inline-block;
    margin-right: 0.25rem;
    font-size: 0.75rem;
}

.checkin-time span,
.checkout-time span {
    display: inline;
    font-size: 0.875rem;
}

/* Compact badge styles */
.location-badge,
.building-badge {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.75rem !important;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Ensure reason text wraps properly */
.reason-text {
    max-width: 200px;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
}

/* Notes column */
.notes-content {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notes-content:hover {
    white-space: normal;
    overflow: visible;
}

/* DataTables wrapper fixes */
.dataTables_wrapper {
    padding: 1rem;
}

.dataTables_length,
.dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_length select {
    min-width: 60px;
    padding: 0.25rem;
}

.dataTables_filter input {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Pagination alignment */
.dataTables_paginate {
    margin-top: 1rem;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    #visit-history {
        font-size: 0.75rem;
    }
    
    #visit-history thead th {
        padding: 0.5rem;
        font-size: 0.65rem;
    }
    
    #visit-history tbody td {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Hide less important columns on mobile */
    #visit-history thead th:nth-child(3),
    #visit-history tbody td:nth-child(3) {
        display: none;
    }
    
    /* Make remaining columns fit better */
    #visit-history thead th:nth-child(1),
    #visit-history thead th:nth-child(2) {
        width: 25%;
    }
    
    #visit-history thead th:nth-child(4) {
        width: 20%;
    }
    
    #visit-history thead th:nth-child(5) {
        width: 30%;
    }
}

/* Fix for DataTables sorting icons */
.sorting,
.sorting_asc,
.sorting_desc {
    padding-right: 1.5rem !important;
    background-position: center right 0.5rem !important;
}

/* Ensure proper alignment */
#visit-history_wrapper {
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Fix any overflow issues */
.visit-history-card * {
    max-width: 100%;
}

/* Better hover effect that doesn't break layout */
#visit-history tbody tr:hover {
    background-color: #f9fafb;
    transform: none;
    box-shadow: inset 3px 0 0 #60a5fa;
}

/* PROPER FIX: Adjust collapsible section padding */
/* Only target the visit history collapsible section */
.collapsible-section .collapsible-content {
    padding: 1.5rem 0.75rem; /* Reduce horizontal padding */
}

/* Make analytics section consistent */
.visitor-analytics-section {
    margin: 1rem 0;
}

/* Ensure consistent alignment with form fields above */
.collapsible-header {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-top: 1px solid #e5e7eb;
    cursor: pointer;
}

/* Table should use available width */
.visit-history-card {
    width: 100%;
}

/* Remove extra margins that might cause misalignment */
.collapsible-section {
    margin: 0;
    width: 100%;
}