/**
 * Building Safety Inspections - Styles
 * Version: 1.2.0
 */

.bsi-wrapper {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* View Toggle Buttons */
.bsi-view-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.bsi-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #1d2327;
    background-color: #f0f0f1;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bsi-toggle-btn:hover {
    background-color: #e5e5e5;
    border-color: #c3c4c7;
}

.bsi-toggle-btn.active {
    background-color: #4472C4;
    color: #fff;
    border-color: #4472C4;
}

.bsi-toggle-btn.active:hover {
    background-color: #3a62a8;
    border-color: #3a62a8;
}

.bsi-toggle-btn svg {
    flex-shrink: 0;
}

.bsi-title {
    color: #1d2327;
    margin-bottom: 20px;
}

/* Search */
.bsi-search-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.bsi-search-input {
    padding: 10px 15px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 300px;
    max-width: 100%;
}

.bsi-search-input:focus {
    outline: none;
    border-color: #4472C4;
    box-shadow: 0 0 0 2px rgba(68, 114, 196, 0.2);
}

.bsi-search-count {
    color: #666;
    font-size: 13px;
}

.bsi-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.bsi-table th,
.bsi-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.bsi-table th {
    background-color: #4472C4;
    color: #fff;
    font-weight: 600;
    vertical-align: middle;
    line-height: 1.3;
}

/* Sortable headers */
.bsi-table th.bsi-sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 25px;
}

.bsi-table th.bsi-sortable:hover {
    background-color: #3a62a8;
}

.bsi-sort-icon {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    opacity: 0.4;
    border-bottom: 6px solid #fff;
}

.bsi-table th.bsi-sort-asc .bsi-sort-icon {
    opacity: 1;
    border-bottom: 6px solid #fff;
    border-top: none;
}

.bsi-table th.bsi-sort-desc .bsi-sort-icon {
    opacity: 1;
    border-top: 6px solid #fff;
    border-bottom: none;
}

.bsi-table tbody tr:hover {
    background-color: #f5f5f5;
}

.bsi-table tbody tr:last-child td {
    border-bottom: none;
}

/* Loading indicator */
.bsi-loading-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.bsi-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e0;
    border-top-color: #4472C4;
    border-radius: 50%;
    animation: bsi-spin 1s linear infinite;
}

@keyframes bsi-spin {
    to {
        transform: rotate(360deg);
    }
}

.bsi-loading-text {
    color: #666;
    font-size: 14px;
}

/* Skeleton loader */
.bsi-skeleton-row td {
    padding: 12px 15px;
}

.bsi-skeleton-cell {
    height: 16px;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: bsi-shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes bsi-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Hidden state */
.bsi-hidden {
    display: none;
}

/* Error message */
.bsi-error {
    color: #d63638;
    padding: 16px 20px;
    background-color: #fcf0f1;
    border: 1px solid #d63638;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* Map link */
.bsi-map-link {
    color: #2271b1;
    text-decoration: none;
}

.bsi-map-link:hover {
    color: #135e96;
    text-decoration: underline;
}

/* No data message */
.bsi-no-data {
    padding: 20px;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    text-align: center;
    color: #666;
}

/* Map Container */
#bsi-map-container {
    position: relative;
}

.bsi-map {
    width: 100%;
    height: 500px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.bsi-map-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
}

.bsi-map-loading span {
    color: #666;
    font-size: 14px;
}

/* Map Popup Styles */
.bsi-popup .leaflet-popup-content-wrapper {
    border-radius: 6px;
    padding: 0;
}

.bsi-popup .leaflet-popup-content {
    margin: 0;
    min-width: 250px;
}

.bsi-popup-content {
    padding: 12px 15px;
}

.bsi-popup-address {
    font-weight: 600;
    font-size: 14px;
    color: #1d2327;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #4472C4;
}

.bsi-popup-divider {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 10px 0;
}

.bsi-popup-inspection {
    padding: 4px 0;
}

.bsi-popup-permit {
    font-size: 13px;
    color: #1d2327;
    margin-bottom: 2px;
}

.bsi-popup-type {
    font-size: 12px;
    color: #4472C4;
    margin-bottom: 4px;
}

.bsi-popup-details {
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
}

.bsi-popup-time {
    font-size: 11px;
    color: #888;
}

.bsi-popup-actions {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.bsi-popup-link {
    display: inline-block;
    font-size: 12px;
    color: #4472C4;
    text-decoration: none;
}

.bsi-popup-link:hover {
    text-decoration: underline;
}

/* Responsive table */
@media screen and (max-width: 782px) {
    .bsi-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .bsi-table th,
    .bsi-table td {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Responsive map */
    .bsi-map {
        height: 400px;
    }

    .bsi-view-toggle {
        flex-wrap: wrap;
    }

    .bsi-toggle-btn {
        flex: 1;
        justify-content: center;
        min-width: 100px;
    }
}
