/* CSS Custom Properties */
:root {
    --primary-color: #27536f;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(39, 83, 111, 0.15);
    --primary-shadow: rgba(39, 83, 111, 0.2);
    --primary-shadow-hover: rgba(39, 83, 111, 0.3);
    --secondary-bg: #f8f9fa;
    --text-primary: #2c3e50;
    --text-secondary: #64748b;
    --border-color: #e1e8ed;
    --border-light: #dee2e6;
    --success-color: #4CAF50;
    --success-hover: #388E3C;
    --danger-color: #f44336;
    --danger-hover: #d32f2f;
    --warning-color: #ff9800;
    --info-color: #2196f3;
    --gray-400: #9ca3af;
    --gray-500: #6c757d;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --white: #ffffff;
    --black: #000000;
}

/* Base Styles */
body, html {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--secondary-bg);
    color: var(--text-primary);
}

/* Header Bar */
#header-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--primary-color);
    border-bottom: 1px solid var(--primary-color);
    box-shadow: 0 2px 10px var(--primary-light);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 30px;
    gap: 30px;
}

.header-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-section h6 {
    margin: 0;
    color: var(--white);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.02em;
}

.header-search {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    max-width: 450px;
}

.header-search input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 400;
    transition: all 0.2s ease;
    background: var(--secondary-bg);
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary-hover);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.header-search button {
    padding: 10px 20px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px var(--primary-shadow);
}

.header-search button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--primary-shadow-hover);
}

.header-search button:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.tool-button {
    padding: 10px 12px;
    background: var(--secondary-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    color: var(--gray-700);
    transition: all 0.2s ease;
    font-weight: 500;
}

.tool-button:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(29, 78, 216, 0.2);
}

.tool-button i {
    margin-right: 6px;
}

/* Health Status Indicator */
.health-indicator {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.3);
    transition: background-color 0.3s ease;
}

/* Map Container */
#map {
    height: calc(100vh - 70px);
    width: 100%;
    position: relative;
    top: 70px;
}

/* Sidebar Container */
#sidebar-container {
    position: fixed;
    top: 80px;
    left: 20px;
    width: 320px;
    height: calc(100vh - 100px);
    overflow-y: auto;
    z-index: 1000;
}

/* Main Sidebar */
#sidebar {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin-bottom: 15px;
    overflow-y: auto;
    max-height: 65vh;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, margin-left 0.3s ease;
}

#sidebar.collapsed {
    transform: translateX(-100%);
    margin-left: -540px;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--primary-color);
    color: var(--white);
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h5 {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.sidebar-collapse-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.sidebar-collapse-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

.sidebar-content {
    padding: 20px 24px;
}

.layer-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 4px;
}

.layer-item:hover {
    background: rgba(29, 78, 216, 0.05);
    padding-left: 8px;
    margin-left: -8px;
    margin-right: -8px;
    padding-right: 8px;
}

.layer-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.layer-toggle {
    display: inline-block;
    margin-right: 12px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.layer-info {
    flex: 1;
}

.layer-name {
    font-weight: 500;
    margin-bottom: 4px;
    color: #1a365d;
    font-size: 14px;
}

.layer-description {
    font-size: 0.85em;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* API Panel */
#api-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 2px solid var(--border-light);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    max-height: 70vh;
    overflow: hidden;
}

#api-panel.open {
    transform: translateY(0);
}

.api-header {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    background: var(--primary-color);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.api-close-btn {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
    transition: all 0.2s;
}

.api-close-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.api-content {
    display: flex;
    max-height: 60vh;
    overflow: hidden;
}

.api-list {
    flex: 0 0 400px;
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
    max-height: 60vh;
    position: relative;
    z-index: 1;
}

.api-details-panel {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    max-height: 60vh;
    background: var(--secondary-bg);
}

.api-details-panel:empty::before {
    content: "Click on an API call to view details";
    display: block;
    text-align: center;
    color: var(--gray-500);
    font-style: italic;
    padding: 40px;
}

/* API Toggle Button */
.api-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    box-shadow: 0 4px 8px var(--primary-shadow);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.api-toggle-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.api-toggle-btn.hidden {
    display: none;
}

.api-call {
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer !important;
    transition: all 0.2s;
    position: relative;
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: var(--white);
    border: 1px solid transparent;
    text-align: left;
    min-height: 40px;
    line-height: 1.4;
}

.api-call:hover {
    background-color: rgba(0, 123, 255, 0.1) !important;
    transform: translateX(2px);
}

.api-call.selected {
    background-color: #e3f2fd;
    border-left: 3px solid var(--info-color);
}

.api-call::after {
    content: "▶";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
    font-size: 0.8em;
    transition: transform 0.2s;
    pointer-events: none;
    z-index: 1;
}

.api-call.selected::after {
    transform: translateY(-50%) rotate(90deg);
}

.api-method {
    font-weight: bold;
    margin-right: 8px;
}

.api-url {
    font-family: monospace;
    font-size: 0.85em;
    color: #666;
    word-break: break-all;
}

.api-details {
    background: var(--secondary-bg);
    padding: 10px;
    margin-top: 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8em;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

.api-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-light);
}

.copy-btn {
    background: var(--gray-500);
    color: var(--white);
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75em;
    transition: background-color 0.2s;
}

.copy-btn:hover {
    background: #5a6268;
}

.copy-btn.copied {
    background: #28a745;
}

.clear-api {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: 5px;
}

.clear-api:hover {
    color: #495057;
}

.response-textarea {
    width: 100%;
    min-height: 100px;
    max-height: 200px;
    font-family: monospace;
    font-size: 0.8em;
    resize: vertical;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    padding: 5px;
    background: var(--white);
}

.response-textarea:focus {
    outline: 2px solid #007bff;
    border-color: #007bff;
}

/* Geocoding Panel */
#geocoding-panel {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.geocoding-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    background: var(--secondary-bg);
    border-radius: 8px 8px 0 0;
}

.geocoding-content {
    padding: 15px;
}

/* County Sections */
.county-section {
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.county-section:last-child {
    margin-bottom: 0;
}

.county-header {
    font-weight: 600;
    color: #1a365d;
    margin: 0;
    padding: 16px 20px;
    background: var(--secondary-bg);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: all 0.2s ease;
    font-size: 15px;
}

.county-header:hover {
    background: var(--primary-color);
    color: var(--white);
}

.county-toggle-icon {
    transition: transform 0.2s ease;
    font-size: 0.9em;
    opacity: 0.7;
}

.county-header:hover .county-toggle-icon {
    opacity: 1;
}

.county-section.collapsed .county-toggle-icon {
    transform: rotate(-90deg);
}

.county-layers {
    padding: 16px 20px;
    background: var(--white);
    transition: all 0.3s ease;
}

.county-section.collapsed .county-layers {
    display: none;
}

/* Expand Sidebar Button */
.expand-sidebar-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 10000;
    font-size: 14px;
    color: var(--gray-500);
    transition: all 0.2s;
}

.expand-sidebar-btn:hover {
    background: var(--secondary-bg);
    color: #495057;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Leaflet Overrides */
.leaflet-control-container .leaflet-routing-container-hide {
    display: none;
}

/* Button Styles */
.fusion-button {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    cursor: pointer;
}

.fusion-button-default {
    background: #1e4159;
    color: var(--white);
    border-color: #1e4159;
}

.fusion-button-default:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--white);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--primary-shadow-hover);
}

.btn-contact {
    margin: 0 8px;
}

/* Bootstrap Overrides */
.btn.fusion-button {
    border-radius: 4px;
}

/* File Upload Styles */
.file-upload-area {
    border: 2px dashed var(--border-light);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    background: var(--secondary-bg);
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 12px 0;
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background: #e3f2fd;
}

.file-upload-area.dragover {
    border-color: var(--success-color);
    background: #c8e6c9;
}

.file-input {
    display: none;
}

.url-input-group {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.url-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 14px;
}

.url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(39, 83, 111, 0.1);
}

.load-url-btn {
    padding: 8px 16px;
    background: var(--success-color);
    color: var(--white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.load-url-btn:hover {
    background: var(--success-hover);
}

.load-url-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Loading Spinner Animation */
.fa-spinner {
    animation: fa-spin 1s infinite linear;
}

@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Uploaded Layers */
.uploaded-layers-section {
    margin-top: 16px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.uploaded-layer-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
}

.uploaded-layer-item:hover {
    background: rgba(29, 78, 216, 0.05);
    padding-left: 4px;
    margin-left: -4px;
    margin-right: -4px;
    padding-right: 4px;
}

.uploaded-layer-item:last-child {
    border-bottom: none;
}

.uploaded-layer-toggle {
    margin-right: 8px;
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.uploaded-layer-info {
    flex: 1;
}

.uploaded-layer-name {
    font-weight: 500;
    font-size: 13px;
    color: #1a365d;
    margin-bottom: 2px;
}

.uploaded-layer-meta {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.uploaded-layer-controls {
    display: flex;
    gap: 4px;
}

.uploaded-layer-btn {
    padding: 4px 8px;
    font-size: 11px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-zoom-uploaded {
    background: var(--success-color);
    color: var(--white);
}

.btn-zoom-uploaded:hover {
    background: var(--success-hover);
}

.btn-remove-uploaded {
    background: var(--danger-color);
    color: var(--white);
}

.btn-remove-uploaded:hover {
    background: var(--danger-hover);
}

/* Management Buttons */
.management-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.management-btn {
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid var(--border-light);
    background: var(--white);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: #495057;
}

.management-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.management-btn.primary {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.management-btn.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.management-btn.danger {
    background: #dc3545;
    color: var(--white);
    border-color: #dc3545;
}

.management-btn.danger:hover {
    background: #c82333;
    border-color: #c82333;
}

/* Stored Layer Controls */
.stored-layer-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
}

.stored-layer-item:hover {
    background: rgba(29, 78, 216, 0.05);
    padding-left: 4px;
    margin-left: -4px;
    margin-right: -4px;
    padding-right: 4px;
}

.stored-layer-item:last-child {
    border-bottom: none;
}

.stored-layer-info {
    flex: 1;
}

.stored-layer-name {
    font-weight: 500;
    font-size: 13px;
    color: #1a365d;
    margin-bottom: 2px;
}

.stored-layer-meta {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.stored-layer-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.stored-layer-btn {
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid var(--border-light);
    background: var(--white);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    color: #495057;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stored-layer-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.stored-layer-color-picker-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    cursor: pointer;
    background: var(--white);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #666;
}

.stored-layer-color-picker-btn:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(39, 83, 111, 0.1);
}

.stored-layer-color-picker {
    display: none;
}
