/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow: hidden;
}

/* Widget Container */
.widget-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f5f7fa;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Header */
.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, #2c3e50 0%, #1a2530 100%);
    color: white;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 24px;
    color: #4CAF50;
}

.logo h1 {
    font-size: 20px;
    font-weight: 600;
}

.data-status {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#dataSource {
    font-size: 14px;
    color: #90a4ae;
}

.last-update {
    font-size: 12px;
    color: #78909c;
}

.header-right {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 380px;
    background: white;
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
}

.section-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-card h3 i {
    color: #667eea;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #546e7a;
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #90a4ae;
}

.input-with-icon .form-control {
    padding-left: 44px;
}

.coordinate-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.range-separator {
    color: #90a4ae;
    font-weight: 500;
}

.range-slider {
    margin-top: 8px;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: #78909c;
}

.checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #546e7a;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

/* Buttons */
.btn-primary, .btn-secondary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f5f7fa;
    color: #546e7a;
    border: 2px solid #e0e0e0;
}

.btn-secondary:hover {
    background: #e8eaf6;
    border-color: #667eea;
}

.actions-section {
    padding-top: 16px;
    padding-bottom: 16px;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #78909c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Contacts Section */
.contacts-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sort-control select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 12px;
    background: white;
    color: #546e7a;
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    cursor: pointer;
    transition: all 0.3s ease;
}

.contact-item:hover {
    background: #e8eaf6;
    border-color: #667eea;
    transform: translateX(4px);
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    margin-right: 12px;
    flex-shrink: 0;
}

.contact-info {
    flex: 1;
}

.contact-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 2px;
}

.contact-details {
    font-size: 12px;
    color: #78909c;
}

.contact-distance {
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
    padding-left: 12px;
    border-left: 2px solid #e0e0e0;
}

/* Map Container */
.map-container {
    flex: 1;
    position: relative;
    background: #e0e0e0;
}

#map {
    width: 100%;
    height: 100%;
}

.map-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-control-btn {
    padding: 10px 16px;
    background: white;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #2c3e50;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.map-control-btn:hover {
    background: #f5f7fa;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.legend-title {
    font-size: 12px;
    font-weight: 600;
    color: #546e7a;
    margin-bottom: 8px;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #78909c;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-color.lead { background: #4CAF50; }
.legend-color.customer { background: #2196F3; }
.legend-color.prospect { background: #FF9800; }
.legend-color.inactive { background: #9E9E9E; }

/* Footer */
.widget-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: white;
    border-top: 1px solid #e0e0e0;
    font-size: 12px;
    color: #78909c;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.divider {
    color: #e0e0e0;
}

#mapInfo {
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Info Window */
.info-window-content {
    min-width: 280px;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.info-header h4 {
    margin: 0;
    font-size: 16px;
    color: #2c3e50;
}

.contact-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.contact-badge.Lead { background: #E8F5E9; color: #2E7D32; }
.contact-badge.Customer { background: #E3F2FD; color: #1565C0; }
.contact-badge.Prospect { background: #FFF3E0; color: #EF6C00; }
.contact-badge.Inactive { background: #F5F5F5; color: #616161; }

.info-body p {
    margin: 8px 0;
    font-size: 13px;
    color: #546e7a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.info-stat {
    text-align: center;
}

.info-stat .label {
    display: block;
    font-size: 11px;
    color: #78909c;
    margin-bottom: 2px;
}

.info-stat .value {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

.info-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.info-action-btn {
    width: 100%;
    padding: 8px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.info-action-btn:hover {
    background: #5a6fd8;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .sidebar {
        width: 340px;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 300px;
    }
    
    .checkbox-group {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 50vh;
    }
    
    .map-container {
        height: 50vh;
    }
    
    .map-controls {
        top: 10px;
        right: 10px;
    }
    
    .map-legend {
        bottom: 10px;
        left: 10px;
    }
}