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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 0;
}

.container {
    background: white;
    padding: 30px;
    overflow-y: auto;
    border-right: 1px solid #e0e0e0;
}

/* Auth Header */
.auth-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

h1 {
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 28px;
}

.subtitle {
    color: #7f8c8d;
    margin-bottom: 0;
    font-size: 14px;
}

/* Auth Buttons */
.auth-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-loading {
    font-size: 13px;
    color: #7f8c8d;
    padding: 8px 16px;
}

.auth-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: none;
}

.auth-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.auth-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.auth-btn:not(.primary) {
    background: white;
    color: #667eea;
    border: 1px solid #667eea;
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px 6px 6px;
    background: #f8f9ff;
    border-radius: 8px;
    border: 1px solid #e0e5ff;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #667eea;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

.user-tier {
    font-size: 12px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-free {
    background: #e0e0e0;
    color: #757575;
}

.badge-premium {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #1a1a1a;
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.3);
}

/* Icon Button */
.icon-btn {
    padding: 8px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    color: #7f8c8d;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

.icon-btn:hover {
    background: #f8f9ff;
    border-color: #667eea;
    color: #667eea;
    transform: none;
}

/* User Menu */
.user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
}

.user-menu.hidden {
    display: none;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: none;
    border-radius: 0;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    cursor: pointer;
    transition: background 0.2s ease;
    box-shadow: none;
}

.menu-item:hover {
    background: #f8f9ff;
    transform: none;
}

.menu-item.premium {
    color: #667eea;
}

.menu-item svg {
    flex-shrink: 0;
}

/* Auth Error */
.auth-error {
    padding: 8px 16px;
    background: #ffebee;
    color: #d32f2f;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

/* Clear History Button */
.clear-history-btn {
    padding: 6px 10px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none;
    white-space: nowrap;
}

.clear-history-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
}

/* Info Icon and Tooltip */
.info-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background: #667eea;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    margin-left: 8px;
    position: relative;
    vertical-align: middle;
    transition: all 0.3s ease;
}

.info-icon:hover {
    background: #764ba2;
    transform: scale(1.1);
}

.info-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: normal;
    line-height: 1.5;
    white-space: normal;
    width: 320px;
    max-width: 90vw;
    text-align: left;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.info-icon::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: calc(100% + 2px);
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #2c3e50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1001;
}

.info-icon:hover::after,
.info-icon:hover::before {
    opacity: 1;
}

.info-icon:hover::after {
    transform: translateX(-50%) translateY(-5px);
}

.info-icon:hover::before {
    transform: translateX(-50%);
}

/* Progress Steps */
.steps {
    display: flex;
    align-items: center;
    margin-bottom: 40px;
    /* padding: 0 20px; */
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    flex: 0 0 100px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.step:hover {
    transform: scale(1.05);
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: all 0.3s ease;
}

.step.active .step-number {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.1);
}

.step.completed .step-number {
    background: #27ae60;
    color: white;
}

.step-label {
    font-size: 12px;
    color: #999;
    font-weight: 500;
}

.step.active .step-label {
    color: #667eea;
    font-weight: 600;
}

.step-line {
    flex: 1;
    height: 2px;
    background: #e0e0e0;
    /* margin: 0 10px; */
    align-self: center;
    margin-bottom: 30px;
}

/* Step Content */
.step-content {
    display: none;
}

.step-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.step-content h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 20px;
}

.step-content p {
    color: #7f8c8d;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* History Section - Minimal */
.history-section-minimal {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 12px;
    color: #95a5a6;
}

.history-section-minimal.visible {
    display: flex;
}

.history-section-minimal label {
    font-weight: 400;
    white-space: nowrap;
}

.history-section-minimal select {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.history-section-minimal select:focus {
    outline: none;
    border-color: #667eea;
}

/* Settings Group */
.settings-group {
    background: #f8f9ff;
    border: 1px solid #e0e5ff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.settings-group label {
    display: block;
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.settings-group input[type="number"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #667eea;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.settings-group input[type="number"]:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.help-text {
    color: #7f8c8d;
    font-size: 12px;
    margin-top: 8px;
    line-height: 1.5;
}

/* Upload Area */
.upload-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

/* Format Selector */
.format-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: #f8f9ff;
    border-radius: 8px;
    border: 1px solid #e0e5ff;
}

.format-selector > label:first-child {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    margin-right: 5px;
}

.format-selector label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #34495e;
    transition: color 0.2s ease;
}

.format-selector label:hover {
    color: #667eea;
}

.format-selector input[type="radio"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #667eea;
}

/* Distance Setting - Minimal Style */
.distance-setting {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 13px;
    color: #7f8c8d;
}

.distance-setting label {
    font-weight: 500;
    white-space: nowrap;
}

.distance-setting input[type="number"] {
    width: 85px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}

.distance-setting input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

.distance-hint {
    font-size: 11px;
    color: #95a5a6;
    font-style: italic;
}

/* Join Mode Setting */
.join-mode-setting {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: #f8f9ff;
    border-radius: 8px;
    border: 1px solid #e0e5ff;
    margin: 8px 0;
}

.join-mode-setting > label:first-child {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    margin-right: 5px;
}

.join-mode-setting label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #34495e;
    transition: color 0.2s ease;
}

.join-mode-setting label:hover {
    color: #667eea;
}

.join-mode-setting input[type="radio"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #667eea;
}

input[type="file"] {
    padding: 15px;
    border: 2px dashed #667eea;
    border-radius: 8px;
    cursor: pointer;
    background: #f8f9ff;
    transition: all 0.3s ease;
}

input[type="file"]:hover {
    border-color: #764ba2;
    background: #f0f1ff;
}

button {
    padding: 14px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

button.secondary {
    background: #95a5a6;
    box-shadow: 0 4px 15px rgba(149, 165, 166, 0.4);
}

button.secondary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(149, 165, 166, 0.6);
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Info Box */
.info-box {
    background: #e8f5e9;
    border: 1px solid #81c784;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
    font-size: 14px;
    line-height: 1.0;
    margin-bottom: 10px;
}

.info-box strong {
    color: #2e7d32;
}

/* Status Messages */
.status {
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    font-weight: 500;
    text-align: center;
    display: none;
}

.status:not(:empty) {
    display: block;
}

.status.processing {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #90caf9;
}

.status.success {
    background: #e8f5e9;
    color: #388e3c;
    border: 1px solid #81c784;
}

.status.error {
    background: #ffebee;
    color: #d32f2f;
    border: 1px solid #ef5350;
}

/* Progress Bar */
.progress-container {
    display: none;
    margin-top: 15px;
}

.progress-container.active {
    display: block;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text {
    font-size: 12px;
    color: #7f8c8d;
    text-align: center;
}

/* Map Container */
.map-container {
    position: relative;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#map {
    flex: 1;
    width: 100%;
    position: relative;
    min-height: 0;
}

/* Attribute Table */
.attribute-table-container {
    height: 0;
    background: white;
    border-top: 2px solid #e0e0e0;
    display: none;
    flex-direction: column;
    flex-shrink: 0;
}

.attribute-table-container.visible {
    display: flex;
    height: 40vh;
}

.table-header {
    padding: 10px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.table-tabs {
    display: flex;
    gap: 5px;
}

.table-tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #7f8c8d;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none;
}

.table-tab:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
    transform: none;
}

.table-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.table-tab.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.table-tab.disabled:hover {
    color: #7f8c8d;
    background: transparent;
}

.record-count {
    font-size: 13px;
    color: #7f8c8d;
}

.table-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    display: none;
}

.table-scroll.active {
    display: block;
}

#shapefile-table,
#csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#shapefile-table thead,
#csv-table thead {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

#shapefile-table th,
#csv-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #667eea;
    background: white;
    white-space: nowrap;
}

#shapefile-table td,
#csv-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #e0e0e0;
    color: #34495e;
}

#shapefile-table tbody tr:hover,
#csv-table tbody tr:hover {
    background: #f8f9ff;
    cursor: pointer;
}

#shapefile-table tbody tr.highlighted,
#csv-table tbody tr.highlighted {
    background: #e8f5e9;
}

/* MapLibre GL controls */
.maplibregl-ctrl-group,
.mapboxgl-ctrl-group {
    border-radius: 6px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}

.maplibregl-ctrl-group button,
.mapboxgl-ctrl-group button {
    width: 36px !important;
    height: 36px !important;
    border-radius: 6px !important;
}

.maplibregl-ctrl-group button:hover,
.mapboxgl-ctrl-group button:hover {
    background: #f0f0f0 !important;
}

/* Improve popup styling */
.maplibregl-popup-content,
.mapboxgl-popup-content {
    border-radius: 8px !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2) !important;
    padding: 12px !important;
    font-size: 13px !important;
    line-height: 1.6 !important;
}

.maplibregl-popup-tip,
.mapboxgl-popup-tip {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
}

/* Custom scrollbar for popups */
.maplibregl-popup-content div::-webkit-scrollbar,
.mapboxgl-popup-content div::-webkit-scrollbar {
    width: 6px;
}

.maplibregl-popup-content div::-webkit-scrollbar-track,
.mapboxgl-popup-content div::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.maplibregl-popup-content div::-webkit-scrollbar-thumb,
.mapboxgl-popup-content div::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.maplibregl-popup-content div::-webkit-scrollbar-thumb:hover,
.mapboxgl-popup-content div::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Popup close button styling */
.maplibregl-popup-close-button,
.mapboxgl-popup-close-button {
    font-size: 20px !important;
    padding: 0 6px !important;
    color: #7f8c8d !important;
}

.maplibregl-popup-close-button:hover,
.mapboxgl-popup-close-button:hover {
    background: rgba(231, 76, 60, 0.1) !important;
    color: #e74c3c !important;
}

/* Smooth map interactions */
#map {
    cursor: grab;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

#map.maplibregl-canvas-container,
#map.mapboxgl-canvas-container {
    cursor: grab !important;
}

/* Cluster styling for MapLibre */
.cluster-marker {
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* Custom Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideUp 0.3s ease;
    text-align: center;
}

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

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 28px;
    color: #95a5a6;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s ease;
    box-shadow: none;
}

.modal-close:hover {
    color: #e74c3c;
    transform: none;
}

.modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.modal-icon.success {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

.modal-icon.success::after {
    content: '✓';
}

.modal-icon.error {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.modal-icon.error::after {
    content: '✕';
}

.modal-icon.warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.modal-icon.warning::after {
    content: '⚠';
}

.modal-icon.info {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.modal-icon.info::after {
    content: 'i';
    font-weight: bold;
    font-style: italic;
}

.modal-icon.premium {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #1a1a1a;
}

.modal-icon.premium::after {
    content: '★';
}

.modal-title {
    font-size: 24px;
    color: #2c3e50;
    margin-bottom: 12px;
    font-weight: 700;
}

.modal-message {
    font-size: 15px;
    color: #7f8c8d;
    line-height: 1.6;
    margin-bottom: 24px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-buttons button {
    min-width: 120px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
}

.modal-buttons button.secondary {
    background: #95a5a6;
}

.modal-buttons button.danger {
    background: #e74c3c;
}

.modal-buttons button.success {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

/* Responsive */
@media (max-width: 1024px) {
    body {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .container {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        /* max-height: 50vh; */
        overflow-y: auto;
    }

    .map-container {
        height: 50vh;
    }

    #map {
        height: 100%;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 24px;
    }

    .step {
        flex: 0 0 80px;
    }

    .step-label {
        font-size: 11px;
    }

    .maplibregl-ctrl-group,
    .mapboxgl-ctrl-group {
        margin-top: 10px !important;
        margin-right: 10px !important;
    }

    .maplibregl-ctrl-group button,
    .mapboxgl-ctrl-group button {
        width: 32px !important;
        height: 32px !important;
    }
}
