/* Modern Map Interface Styles */

/* CSS Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Variables */
:root {
    /* Colors */
    --primary-blue: #2563eb;
    --primary-dark: #1e40af;
    --democrat-blue: #2563eb;
    --republican-red: #dc2626;
    --independent-purple: #7c3aed;
    --vacant-gray: #6b7280;
    
    /* UI Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-tertiary: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #d1d5db;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --toolbar-height: 60px;
    --sidebar-width: 400px;
}

/* Base Styles */
html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Toolbar */
.toolbar {
    height: var(--toolbar-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 24px;
    box-shadow: var(--shadow-sm);
    z-index: 1000;
}

.toolbar-left {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-blue);
}

.back-to-home {
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s;
}

.back-to-home:hover {
    color: var(--primary-blue);
    border-color: var(--primary-blue);
    background: var(--bg-secondary);
}

.toolbar-center {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.search-container {
    display: flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    max-width: 400px;
    flex: 1;
}

.address-input {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
}

.search-btn {
    padding: 8px 16px;
    background: var(--primary-blue);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

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

.state-selector,
.map-style-selector {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    cursor: pointer;
    outline: none;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.toggle-group {
    display: flex;
    gap: 16px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}

.toggle input[type="checkbox"] {
    cursor: pointer;
}

.toolbar-buttons {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-blue);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
}

.sidebar.hidden {
    transform: translateX(100%);
}

.close-sidebar {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    z-index: 10;
}

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

/* Panels */
.panel {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.district-content {
    font-size: 14px;
    line-height: 1.6;
}

.district-dropdown {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    cursor: pointer;
    outline: none;
}

/* Validation Panel */
.validation-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 12px;
    outline: none;
}

.validate-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

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

.validation-results {
    margin-top: 16px;
}

/* Legends */
.map-legends {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 500;
}

.legend {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: var(--shadow-md);
    margin-bottom: 12px;
}

.legend h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.legend-color.democrat {
    background: var(--democrat-blue);
}

.legend-color.republican {
    background: var(--republican-red);
}

.legend-color.independent {
    background: var(--independent-purple);
}

.legend-color.vacant {
    background: var(--vacant-gray);
}

.gradient-bar {
    display: block;
    width: 100%;
    height: 20px;
    background: linear-gradient(to right, #dbeafe, #1e40af);
    border-radius: 4px;
    margin: 8px 0;
}

.gradient-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.config-section {
    margin-bottom: 24px;
}

.config-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.config-section input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 8px;
    outline: none;
}

.config-section button {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.save-config,
.refresh-data {
    width: 100%;
    padding: 12px 16px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 16px;
    margin-top: 16px;
}

.save-config:hover,
.refresh-data:hover {
    background: var(--primary-dark);
}

/* Member Info Styles */
.district-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.district-header h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.district-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.member-info {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.member-photo {
    width: 100px;
    height: 100px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.member-details {
    flex: 1;
}

.member-details h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.member-details .party {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.member-details .party.democrat {
    color: var(--democrat-blue);
}

.member-details .party.republican {
    color: var(--republican-red);
}

.member-details .party.independent {
    color: var(--independent-purple);
}

.member-details .office,
.member-details .phone {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.member-details a {
    color: var(--primary-blue);
    text-decoration: none;
    font-size: 14px;
}

.member-details a:hover {
    text-decoration: underline;
}

.committees {
    margin-top: 20px;
}

.committees h5 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.committees ul {
    list-style: none;
    padding: 0;
}

.committees li {
    padding: 6px 0;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
}

.committees li:last-child {
    border-bottom: none;
}

.vacant-notice {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 40px 20px;
}

/* District Facts Styles */
.district-facts-view {
    padding: 0;
}

.member-info-compact {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.member-info-compact h4 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.member-info-compact .phone,
.member-info-compact .office {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 4px 0;
}

.district-facts {
    margin-top: 24px;
}

.district-facts h5 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--primary-blue);
}

.facts-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fact-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid var(--primary-blue);
}

.fact-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.fact-content {
    flex: 1;
}

.fact-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.fact-source {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

.no-facts {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 32px 16px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* District Styles for Map */
.district-boundary {
    fill-opacity: 0.2;
    stroke-width: 2;
    cursor: pointer;
    transition: all 0.2s;
}

.district-boundary:hover {
    fill-opacity: 0.4;
    stroke-width: 3;
}

.district-boundary.selected {
    fill-opacity: 0.5;
    stroke-width: 4;
}

.district-boundary.democrat {
    fill: var(--democrat-blue);
    stroke: var(--democrat-blue);
}

.district-boundary.republican {
    fill: var(--republican-red);
    stroke: var(--republican-red);
}

.district-boundary.independent {
    fill: var(--independent-purple);
    stroke: var(--independent-purple);
}

.district-boundary.vacant {
    fill: var(--vacant-gray);
    stroke: var(--vacant-gray);
}

/* Responsive Design */
@media (max-width: 768px) {
    .toolbar {
        flex-wrap: wrap;
        height: auto;
        padding: 12px;
    }
    
    .toolbar-center {
        order: 3;
        width: 100%;
        margin-top: 12px;
    }
    
    .search-container {
        max-width: none;
    }
    
    .toggle-group {
        display: none;
    }
    
    .sidebar {
        width: 100%;
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    }
    
    .map-legends {
        bottom: 10px;
        left: 10px;
    }
}