/**
 * District Registry - Styles
 */

:root {
    --primary: #AFFF00;
    --primary-dark: #163300;
    --primary-mid: #2D5A00;
    --bg-dark: #0f1f00;
    --bg-card: #1a3300;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --border: rgba(175, 255, 0, 0.2);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

/* Custom select dropdown with lime green up/down chevron */
select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='16' viewBox='0 0 10 16' fill='none'%3E%3Cpath d='M5 0L9.33 6H0.67L5 0Z' fill='%23AFFF00'/%3E%3Cpath d='M5 16L0.67 10H9.33L5 16Z' fill='%23AFFF00'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-color: inherit;
    padding-right: 2.5rem !important;
}

select::-ms-expand {
    display: none;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--primary-dark);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
}

.nav {
    display: flex;
    gap: 0.5rem;
}

.nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s;
}

.nav a:hover {
    color: var(--text-primary);
    background: rgba(175, 255, 0, 0.1);
}

.nav a.active {
    color: var(--primary-dark);
    background: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-dark);
}

.btn-primary:hover {
    background: #c4ff33;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 1.25rem;
}

/* Main Content */
.main {
    padding-top: 60px;
    min-height: 100vh;
}

/* Map Container */
.map-container {
    display: flex;
    height: calc(100vh - 60px);
}

.map-sidebar {
    width: 300px;
    background: var(--bg-dark);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    color: var(--primary);
}

.filter-group {
    margin-bottom: 1rem;
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.sidebar-stats {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.sidebar-stats h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Map */
.map-main {
    flex: 1;
    position: relative;
}

.map {
    width: 100%;
    height: 100%;
}

/* Detail Panel */
.detail-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 380px;
    max-height: calc(100% - 2rem);
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.close-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.detail-content {
    padding: 1.5rem;
}

.detail-header {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.detail-content h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.detail-content .location {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.detail-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.detail-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.detail-section p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.contact-info a {
    color: var(--primary);
    text-decoration: none;
}

.date-grid,
.financial-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.date-label,
.fin-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.date-value,
.fin-value {
    font-weight: 600;
    color: var(--text-primary);
}

.fin-value {
    color: var(--primary);
}

.detail-actions {
    margin-top: 1.5rem;
}

.detail-actions .btn {
    width: 100%;
    justify-content: center;
}

/* Badges */
.type-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--primary);
    color: var(--primary-dark);
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 4px;
}

.type-badge.small {
    padding: 0.125rem 0.375rem;
    font-size: 0.625rem;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: capitalize;
}

.status-badge.small {
    padding: 0.125rem 0.375rem;
    font-size: 0.625rem;
}

.status-active {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
}

.status-expired {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.status-pending {
    background: rgba(241, 196, 15, 0.2);
    color: #f1c40f;
}

.status-dissolved {
    background: rgba(149, 165, 166, 0.2);
    color: #95a5a6;
}

.status-suspended {
    background: rgba(155, 89, 182, 0.2);
    color: #9b59b6;
}

/* List View */
.list-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.list-header h1 {
    font-size: 1.75rem;
    color: var(--primary);
}

.list-controls {
    display: flex;
    gap: 0.75rem;
}

.list-controls input,
.list-controls select {
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.list-controls input {
    width: 200px;
}

/* Table */
.districts-table {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.districts-table table {
    width: 100%;
    border-collapse: collapse;
}

.districts-table th {
    text-align: left;
    padding: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.districts-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.districts-table tr:hover {
    background: rgba(175, 255, 0, 0.05);
    cursor: pointer;
}

.districts-table td strong {
    display: block;
    color: var(--text-primary);
}

.districts-table td small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination span {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Report View */
.report-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.report-header {
    text-align: center;
    margin-bottom: 3rem;
}

.report-header h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.report-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.report-date {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.summary-card {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
}

.summary-card.highlight {
    border-color: var(--primary);
    background: rgba(175, 255, 0, 0.05);
}

.summary-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.summary-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.report-section {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

.report-section h2 {
    font-size: 1.25rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

/* Bar Chart */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bar-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bar-label {
    width: 40px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.bar-track {
    flex: 1;
    height: 24px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.bar-value {
    width: 40px;
    text-align: right;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
}

/* Type Grid */
.type-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.type-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
}

.type-code {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.type-name {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.type-count {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.report-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.report-footer a {
    color: var(--primary);
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(22, 51, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 1024px) {
    .report-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .type-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    
    .map-container {
        flex-direction: column;
    }
    
    .map-sidebar {
        width: 100%;
        max-height: 300px;
    }
    
    .detail-panel {
        width: calc(100% - 2rem);
        max-height: 50%;
        bottom: 1rem;
        top: auto;
    }
    
    .list-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .list-controls {
        flex-wrap: wrap;
    }
    
    .districts-table {
        overflow-x: auto;
    }
    
    .report-summary {
        grid-template-columns: 1fr 1fr;
    }
    
    .type-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .report-summary {
        grid-template-columns: 1fr;
    }
    
    .type-grid {
        grid-template-columns: 1fr;
    }
}

/* Leaflet Overrides */
.leaflet-container {
    background: var(--primary-dark);
    z-index: 1;
}

/* Ensure sidebar stays above map on mobile */
.leaflet-pane,
.leaflet-top,
.leaflet-bottom {
    z-index: 1 !important;
}

.leaflet-control {
    z-index: 2 !important;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-dark);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.leaflet-popup-tip {
    background: var(--bg-dark);
}

.leaflet-control-zoom a {
    background: var(--bg-dark) !important;
    color: var(--primary) !important;
    border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-card) !important;
}

.leaflet-control-attribution {
    background: rgba(22, 51, 0, 0.8) !important;
    color: var(--text-muted) !important;
}

.leaflet-control-attribution a {
    color: var(--primary) !important;
}

.leaflet-tooltip {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.leaflet-tooltip-top:before {
    border-top-color: var(--bg-dark);
}
