/**
 * Civic Case Map — Frontend styles.
 */

/* App container — full-width with 5% side padding */
.ccm-app {
    /* position: fixed; */
    max-width: 100vw;
    /* left: 50%; */
    padding-left: 5%;
    padding-right: 5%;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

/* Stats panel */
.ccm-stats-panel {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.ccm-stats-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.ccm-stat-card {
    flex: 1;
    min-width: 100px;
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.ccm-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
}

.ccm-stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.ccm-stats-breakdown {
    margin-top: 12px;
    border-top: 1px solid #eee;
    padding-top: 8px;
}

.ccm-stats-breakdown summary {
    cursor: pointer;
    font-weight: 600;
    color: #444;
    padding: 4px 0;
}

.ccm-stats-breakdown ul {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ccm-stats-breakdown li {
    background: #f0f0f0;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
}

/* Filters */
.ccm-filters {
    margin-bottom: 12px;
}

.ccm-filters-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.ccm-filter-select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
    min-width: 140px;
}

.ccm-filter-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    cursor: pointer;
}

.ccm-filter-toggle input {
    margin: 0;
}

/* Map container */
.ccm-map-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

#ccm-map {
    width: 100%;
    min-height: 400px;
    z-index: 1;
    background: #f0f2f5;
}

/* Protect Leaflet images from theme/WP CSS interference */
.leaflet-container img {
    max-width: none !important;
    max-height: none !important;
}

.ccm-map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: inherit;
    color: #888;
    font-size: 16px;
}

/* Reset view button */
.ccm-reset-view {
    position: absolute;
    top: 90%;
    left: 15px;
    z-index: 1000;
    background: #fff;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 6px 8px;
    cursor: pointer;
    line-height: 1;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15);
}

.ccm-reset-view:hover {
    background: #f4f4f4;
}

.ccm-reset-view .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Buttons */
.ccm-btn-primary,
.ccm-btn-secondary {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    border: none;
    line-height: 1.5;
}

.ccm-btn-primary {
    background: #0073aa;
    color: #fff;
}

.ccm-btn-primary:hover {
    background: #005177;
    color: #fff;
}

.ccm-btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
}

.ccm-btn-secondary:hover {
    background: #e0e0e0;
}

.ccm-btn-sm {
    padding: 3px 10px;
    font-size: 12px;
}

/* Popup */
.ccm-popup {
    max-width: 300px;
}

.ccm-popup-header {
    font-size: 15px;
    margin-bottom: 4px;
}

.ccm-popup-video-icon {
    color: #c00;
    font-size: 12px;
    cursor: default;
}

.ccm-popup-id {
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
}

.ccm-popup-meta {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.ccm-popup-summary {
    font-size: 13px;
    color: #555;
    margin-bottom: 10px;
    border-top: 1px solid #eee;
    padding-top: 8px;
}

.ccm-popup-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* Status badges */
.ccm-status-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.ccm-status-reported { background: #e3f2fd; color: #1565c0; }
.ccm-status-under_investigation { background: #fff8e1; color: #f57f17; }
.ccm-status-sent_to_trial { background: #fff3e0; color: #e65100; }
.ccm-status-convicted { background: #fce4ec; color: #c62828; }
.ccm-status-acquitted { background: #e8f5e9; color: #2e7d32; }
.ccm-status-dismissed_or_closed { background: #eceff1; color: #546e7a; }

/* Detail panel — desktop: right sidebar */
.ccm-detail-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 380px;
    height: 100%;
    background: #fff;
    z-index: 1001;
    overflow-y: auto;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease;
    transform: translateX(100%);
}

.ccm-detail-panel.ccm-detail-open {
    transform: translateX(0);
}

.ccm-detail-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    z-index: 2;
    padding: 4px 8px;
    line-height: 1;
}

.ccm-detail-close:hover {
    color: #000;
}

.ccm-detail {
    padding: 20px;
}

.ccm-detail h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

.ccm-detail-id {
    margin-bottom: 16px;
}

.ccm-detail-id code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.ccm-detail-fields {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    margin-bottom: 16px;
}

.ccm-detail-fields dt {
    font-weight: 600;
    color: #555;
    font-size: 13px;
}

.ccm-detail-fields dd {
    margin: 0;
    font-size: 13px;
}

.ccm-detail-description {
    border-top: 1px solid #eee;
    padding-top: 12px;
    margin-bottom: 16px;
}

.ccm-detail-description p {
    margin: 0;
    color: #444;
    line-height: 1.6;
}

.ccm-detail-actions {
    margin-top: 16px;
}

/* Cluster list panel */
.ccm-cluster-list {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 1001;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    max-width: 350px;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
}

.ccm-cluster-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
}

.ccm-cluster-list h3 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #555;
}

.ccm-cluster-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ccm-cluster-item {
    padding: 8px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 13px;
}

.ccm-cluster-item:hover {
    background: #f5f5f5;
}

.ccm-cluster-item:last-child {
    border-bottom: none;
}

/* Aggregated cluster icons */
.ccm-agg-cluster {
    background: none !important;
    border: none !important;
}

.ccm-cluster-icon {
    width: 40px;
    height: 40px;
    background: rgba(0, 115, 170, 0.85);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Empty state */
.ccm-empty-state {
    text-align: center;
    padding: 30px;
    color: #666;
}

.ccm-empty-state p {
    font-size: 16px;
    margin-bottom: 12px;
}

/* Hidden */
.ccm-hidden {
    display: none !important;
}

/* Loading */
.ccm-stats-loading {
    text-align: center;
    padding: 20px;
    color: #888;
}

/* Mobile responsive */
@media (max-width: 767px) {
    .ccm-stats-grid {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .ccm-stat-card {
        min-width: 80px;
        flex: 1 1 30%;
    }

    .ccm-stat-value {
        font-size: 18px;
    }

    .ccm-filters-row {
        flex-direction: column;
    }

    .ccm-filter-select {
        width: 100%;
    }

    /* Detail panel: bottom sheet on mobile */
    .ccm-detail-panel {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }

    .ccm-detail-panel.ccm-detail-open {
        transform: translateY(0);
    }

    .ccm-cluster-list {
        left: 5px;
        right: 5px;
        max-width: none;
        bottom: 5px;
    }

    /* Stats panel collapsible on mobile */
    .ccm-stats-panel {
        padding: 10px;
    }

    .ccm-stats-breakdown {
        margin-top: 8px;
    }
}
