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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    overflow: hidden;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    position: relative;
    overflow: visible;
}

.header h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
    font-weight: 600;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

.header-search {
    display: flex;
    justify-content: center;
    margin-top: 15px;
    position: relative;
    z-index: 10000;
}

.geocoder-header {
    width: 100%;
    max-width: 400px;
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
}

/* Override Mapbox Geocoder styles for header placement */
.geocoder-header .mapboxgl-ctrl-geocoder {
    width: 100% !important;
    max-width: none !important;
    font-size: 16px !important;
    border-radius: 8px !important;
    position: relative !important;
}

.geocoder-header .mapboxgl-ctrl-geocoder input {
    height: 44px !important;
    padding: 0 44px 0 44px !important;
    font-size: 16px !important;
    color: #333 !important;
    border-radius: 8px !important;
    border: none !important;
    outline: none !important;
}

.geocoder-header .mapboxgl-ctrl-geocoder input::placeholder {
    color: #999 !important;
    font-size: 15px !important;
}

.geocoder-header .mapboxgl-ctrl-geocoder .mapboxgl-ctrl-geocoder--icon {
    top: 12px !important;
    left: 12px !important;
    right: auto !important;
}

/* Fix clear button vertical alignment and show when there's input */
.geocoder-header .mapboxgl-ctrl-geocoder .mapboxgl-ctrl-geocoder--button {
    top: 50% !important;
    transform: translateY(-50%) !important;
    right: 8px !important;
    width: 28px !important;
    height: 28px !important;
    display: none !important; /* Hidden by default */
    align-items: center !important;
    justify-content: center !important;
}

.geocoder-header .mapboxgl-ctrl-geocoder .mapboxgl-ctrl-geocoder--icon {
    top: 12px !important;
    left: 12px !important;
    right: auto !important;
}

/* Show clear button when there's input - try different selectors */
.geocoder-header .mapboxgl-ctrl-geocoder .mapboxgl-ctrl-geocoder--button {
    top: 50% !important;
    transform: translateY(-50%) !important;
    right: 8px !important;
    width: 28px !important;
    height: 28px !important;
    display: none !important; /* Hidden by default */
    align-items: center !important;
    justify-content: center !important;
}

/* Show clear button when input has content */
.geocoder-header .mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder--input .mapboxgl-ctrl-geocoder--button,
.geocoder-header .mapboxgl-ctrl-geocoder input:not([value=""]) + .mapboxgl-ctrl-geocoder--button,
.geocoder-header .mapboxgl-ctrl-geocoder:not(.mapboxgl-ctrl-geocoder--collapsed) .mapboxgl-ctrl-geocoder--button {
    display: flex !important;
}

/* Prevent loading spinner in the search icon */
.geocoder-header .mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder--loading .mapboxgl-ctrl-geocoder--icon {
    animation: none !important;
}

/* Show loading spinner in dropdown instead */
.geocoder-header .mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder--loading .suggestions::before {
    content: '' !important;
    display: block !important;
    width: 16px !important;
    height: 16px !important;
    border: 2px solid #f3f3f3 !important;
    border-top: 2px solid #667eea !important;
    border-radius: 50% !important;
    animation: spin 1s linear infinite !important;
    margin: 10px auto !important;
}

.geocoder-header .mapboxgl-ctrl-geocoder .suggestions {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: white !important;
    border-radius: 0 0 8px 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    max-height: 200px !important;
    overflow-y: auto !important;
    z-index: 9999 !important;
    margin: 0 !important;
    border: 1px solid #e0e0e0 !important;
    border-top: none !important;
}

.geocoder-header .mapboxgl-ctrl-geocoder .suggestions > li {
    padding: 12px 16px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    cursor: pointer !important;
    color: #333 !important;
    font-size: 14px !important;
}

.geocoder-header .mapboxgl-ctrl-geocoder .suggestions > li:hover,
.geocoder-header .mapboxgl-ctrl-geocoder .suggestions > li.active {
    background-color: #f8f9fa !important;
}

.geocoder-header .mapboxgl-ctrl-geocoder .suggestions > li:last-child {
    border-bottom: none !important;
    border-radius: 0 0 8px 8px !important;
}

.geocoder-header .mapboxgl-ctrl-geocoder .suggestions > li > .mapboxgl-ctrl-geocoder--suggestion-title {
    color: #333 !important;
    font-weight: 500 !important;
}

/* Additional fixes for suggestions dropdown */
.header-search .mapboxgl-ctrl-geocoder .suggestions {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: white !important;
    border-radius: 0 0 8px 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    max-height: 200px !important;
    overflow-y: auto !important;
    z-index: 99999 !important;
    margin: 0 !important;
    border: 1px solid #e0e0e0 !important;
    border-top: none !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.header-search .mapboxgl-ctrl-geocoder .suggestions li {
    display: block !important;
    padding: 12px 16px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    cursor: pointer !important;
    color: #333 !important;
    font-size: 14px !important;
    list-style: none !important;
}

/* No results message styling */
.geocoder-header .mapboxgl-ctrl-geocoder .suggestions .no-results-message,
.header-search .mapboxgl-ctrl-geocoder .suggestions .no-results-message {
    padding: 16px !important;
    color: #666 !important;
    font-style: italic !important;
    cursor: default !important;
    background-color: #f8f9fa !important;
    border-bottom: none !important;
    text-align: center !important;
}

/* Loading spinner styles */
.loading-message {
    text-align: center;
    padding: 40px 20px;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-top: 15px;
}

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

/* Data source attribution */
.data-source {
    font-size: 0.8rem;
    color: #666;
    margin-top: 10px;
    text-align: center;
    font-style: italic;
}

/* No data available message styling */
.no-data-message {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    margin: 10px 0;
}

.no-data-message p:first-child {
    color: #6c757d;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.no-data-message ul {
    text-align: left;
    max-width: 300px;
    margin: 10px auto;
}

/* Hide powered by Mapbox attribution in geocoder */
.geocoder-header .mapboxgl-ctrl-geocoder .suggestions::after,
.geocoder-header .mapboxgl-ctrl-geocoder .suggestions .mapboxgl-ctrl-geocoder--powered-by,
.header-search .mapboxgl-ctrl-geocoder .suggestions::after,
.header-search .mapboxgl-ctrl-geocoder .suggestions .mapboxgl-ctrl-geocoder--powered-by {
    display: none !important;
}

/* Hide empty suggestions container */
.geocoder-header .mapboxgl-ctrl-geocoder .suggestions:empty,
.header-search .mapboxgl-ctrl-geocoder .suggestions:empty {
    display: none !important;
}

/* Hide suggestions when they only contain powered by text */
.geocoder-header .mapboxgl-ctrl-geocoder .suggestions:not(:has(li)),
.header-search .mapboxgl-ctrl-geocoder .suggestions:not(:has(li)) {
    display: none !important;
}

/* Fullscreen Map */
.map-fullscreen {
    flex: 1;
    width: 100%;
    position: relative;
}

.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.zoom-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: white;
    color: #333;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background-color: #f8f9fa;
}

.zoom-btn:first-child {
    border-bottom: 1px solid #e9ecef;
}

.zoom-btn:active {
    background-color: #e9ecef;
}

/* Floating Data Panel */
.floating-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 380px;
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
}

.floating-panel.visible {
    transform: translateX(0);
}

.floating-panel.hidden {
    display: none;
}

.panel-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    cursor: move;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.panel-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    margin-left: 10px;
    flex-shrink: 0;
}

.panel-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.panel-close-btn:active {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Resize handles */
.resize-handle {
    position: absolute;
    z-index: 10;
}

.resize-n {
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    cursor: n-resize;
    z-index: 11;
}

.resize-s {
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    cursor: s-resize;
    z-index: 11;
}

.resize-e {
    top: 0;
    right: 0;
    bottom: 0;
    width: 5px;
    cursor: e-resize;
    z-index: 11;
}

.resize-w {
    top: 0;
    left: 0;
    bottom: 0;
    width: 5px;
    cursor: w-resize;
    z-index: 11;
}

.resize-ne {
    top: 0;
    right: 0;
    width: 10px;
    height: 10px;
    cursor: ne-resize;
    z-index: 12;
}

.resize-nw {
    top: 0;
    left: 0;
    width: 10px;
    height: 10px;
    cursor: nw-resize;
    z-index: 12;
}

.resize-se {
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    cursor: se-resize;
    z-index: 12;
}

.resize-sw {
    bottom: 0;
    left: 0;
    width: 10px;
    height: 10px;
    cursor: sw-resize;
    z-index: 12;
}

.panel-content {
    padding: 20px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

/* Panel Content Styles */
.zip-info {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.info-section {
    margin-bottom: 25px;
}

.info-section h3 {
    color: #2c3e50;
    font-size: 1.2rem;
    margin-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.info-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.info-item .label {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 5px;
}

.info-item .value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
}

/* AI Summary Styles */
.ai-summary {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    margin-top: 15px;
    border-left: 4px solid #667eea;
}

.ai-summary-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.ai-summary-label::before {
    content: "✨";
    margin-right: 6px;
    font-size: 1rem;
}

.ai-summary-text {
    color: #6c757d;
    font-size: 0.9rem;
    line-height: 1.4;
    text-align: left;
}

.demographics-chart {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

.demographic-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
}

.demographic-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.demographic-label {
    font-weight: 500;
    color: #495057;
}

.demographic-bar {
    flex: 1;
    margin: 0 15px;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.demographic-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.demographic-percentage {
    font-weight: 600;
    color: #2c3e50;
    min-width: 40px;
    text-align: right;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .header {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .header p {
        font-size: 0.8rem;
        margin-bottom: 15px;
    }
    
    .geocoder-header {
        max-width: 350px;
    }
    
    .geocoder-header .mapboxgl-ctrl-geocoder input {
        height: 40px !important;
        font-size: 15px !important;
        padding: 0 40px 0 40px !important;
    }
    
    .zoom-controls {
        bottom: 15px;
        right: 15px;
    }
    
    .floating-panel {
        top: 15px;
        right: 15px;
        left: 15px;
        width: auto;
        max-height: calc(100vh - 30px);
    }
    
    .floating-panel.visible {
        transform: translateX(0);
    }
    
    .floating-panel.hidden {
        display: none;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .panel-header {
        padding: 15px;
    }
    
    .panel-content {
        padding: 15px;
        max-height: calc(100vh - 100px);
    }
}

@media (max-width: 480px) {
    .header {
        padding: 12px;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .header p {
        font-size: 0.75rem;
        margin-bottom: 12px;
    }
    
    .geocoder-header {
        max-width: 280px;
    }
    
    .geocoder-header .mapboxgl-ctrl-geocoder input {
        height: 38px !important;
        font-size: 14px !important;
        padding: 0 38px 0 38px !important;
    }
    
    .zoom-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .zoom-controls {
        bottom: 10px;
        right: 10px;
    }
}

/* Tabs Styles */
.tabs-container {
    margin-top: 20px;
}

.tab-buttons {
    display: flex;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    border: 1px solid #dee2e6;
    border-bottom: none;
    overflow: hidden;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease;
    border-right: 1px solid #dee2e6;
}

.tab-btn:last-child {
    border-right: none;
}

/* Only apply hover effects on non-touch devices */
@media (hover: hover) and (pointer: fine) {
    .tab-btn:hover {
        background: #e9ecef;
        color: #495057;
    }
}

.tab-btn.active {
    background: white;
    color: #667eea;
    font-weight: 600;
    position: relative;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: #667eea;
}

.tab-content {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0 0 8px 8px;
    padding: 20px;
    min-height: 200px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Demographics Tab Styles */
.demographics-section {
    margin-bottom: 25px;
}

.demographics-section:last-of-type {
    margin-bottom: 15px;
}

.demographics-section h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    color: #495057;
    font-weight: 600;
}

.demo-value-display {
    font-size: 1rem;
    font-weight: 500;
    color: #495057;
    margin-bottom: 5px;
}

.data-source {
    font-size: 0.8rem;
    color: #666;
    margin-top: 15px;
    text-align: center;
    padding-top: 10px;
    border-top: 1px solid #f1f3f4;
}

.no-data-message {
    text-align: center;
    color: #6c757d;
    padding: 40px 20px;
    font-style: italic;
}

/* Schools Section Styles */
.school-type-toggles {
    display: flex;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 15px;
}

.school-type-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-right: 1px solid #dee2e6;
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6c757d;
    font-weight: 500;
}

.school-type-btn:last-child {
    border-right: none;
}

/* Only apply hover effects on non-touch devices */
@media (hover: hover) and (pointer: fine) {
    .school-type-btn:hover {
        background: #e9ecef;
        color: #495057;
    }
}

.school-type-btn.active {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.schools-list {
    max-height: 400px;
    overflow-y: auto;
}

.school-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

/* Only apply hover effects on non-touch devices */
@media (hover: hover) and (pointer: fine) {
    .school-item:hover {
        background: #e9ecef;
        border-color: #dee2e6;
    }
}

.school-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 10px;
}

.school-name {
    font-weight: 600;
    color: #495057;
    line-height: 1.3;
    flex: 1;
}

.school-name-link {
    font-weight: 600;
    color: #667eea;
    text-decoration: none;
    line-height: 1.3;
    flex: 1;
    transition: color 0.2s ease;
}

.school-name-btn {
    font-weight: 600;
    color: #667eea;
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
    font-family: inherit;
    line-height: 1.3;
    flex: 1;
    text-align: left;
    cursor: pointer;
    transition: color 0.2s ease;
}

/* Only apply hover effects on non-touch devices */
@media (hover: hover) and (pointer: fine) {
    .school-name-link:hover {
        color: #5a6fd8;
        text-decoration: underline;
    }
    
    .school-name-btn:hover {
        color: #5a6fd8;
        text-decoration: underline;
    }
}

.school-rating {
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    min-width: 40px;
    text-align: center;
}

.school-rating.no-rating {
    background: #6c757d;
}

.school-address {
    color: #6c757d;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-top: 5px;
}

.show-more-btn {
    width: 100%;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-top: 5px;
}

/* Only apply hover effects on non-touch devices */
@media (hover: hover) and (pointer: fine) {
    .show-more-btn:hover {
        background: #5a6fd8;
    }
}

.no-schools-message {
    text-align: center;
    color: #6c757d;
    padding: 20px;
    font-style: italic;
}

.error-message {
    text-align: center;
    color: #dc3545;
    padding: 20px;
    background: #fff5f5;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
}

/* Loading message styles for schools */
#schools-list .loading-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #6c757d;
}

/* Mobile responsive adjustments for schools */
@media (max-width: 768px) {
    .tab-buttons {
        flex-direction: row;
    }
    
    .tab-btn {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    .tab-content {
        padding: 15px;
        min-height: 150px;
    }
    
    .school-type-toggles {
        margin-bottom: 12px;
    }
    
    .school-type-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .school-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .school-rating {
        align-self: flex-start;
    }
}