/* 
 * Player Map Styles
 * Modern CSS for player map visualization
 */

:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --secondary: #10b981;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --text-on-primary: #ffffff;
    --border: #e2e8f0;
    --error: #ef4444;
    --warning: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius-sm: 0.25rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #3b82f6;
        --primary-light: #60a5fa;
        --primary-dark: #2563eb;
        --secondary: #10b981;
        --surface: #0f172a;
        --surface-2: #1e293b;
        --surface-3: #334155;
        --text: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-light: #94a3b8;
        --text-on-primary: #ffffff;
        --border: #334155;
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
        --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    }
}

/* Base Styles */
.map-page-content {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    max-width: 100%;
    overflow-x: hidden;
}

/* Header Styles */
.map-header {
    padding: 1.5rem 0;
    text-align: center;
    position: relative;
}

.map-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    background: #453030;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: inline-block;
}

.map-subtitle {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin: 0.5rem 0 0;
}

/* Controls Section */
.map-controls {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    margin: 1.5rem 0;
    align-items: center;
    position: relative;
    z-index: 9999 !important;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .map-controls {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .map-title {
        font-size: 1.75rem;
    }
}

/* Map Card Styles */
.map-card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: relative;
    transition: all var(--transition);
    height: 70vh;
    min-height: 500px;
    margin-bottom: 1.5rem;
}

.map-card:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

#map {
    height: 100%;
    width: 100%;
    border-radius: var(--radius-lg);
}

/* Input and Button Styles */
.input-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.input-group .select2-container {
    flex: 1;
    min-width: 250px;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-on-primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background-color: var(--surface-3);
    color: var(--text);
}

.btn-secondary:hover {
    background-color: var(--border);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-icon {
    padding: 0.625rem;
    border-radius: var(--radius-full);
}

/* Loading State Styles */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(var(--surface), 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    border-radius: var(--radius-lg);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--surface-3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 1rem;
    font-weight: 500;
    color: var(--text);
}

/* Stats Container Styles */
.stats-container {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    z-index: 400;
    border: 1px solid var(--border);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    color: var(--text);
}

/* Filter Container Styles */
.filters-container {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background-color: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.75rem;
    font-size: 0.875rem;
    z-index: 400;
    max-width: 250px;
    border: 1px solid var(--border);
}

.filters-title {
    font-weight: 600;
    margin: 0 0 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.filter-row {
    margin-bottom: 0.5rem;
}

.filter-row:last-child {
    margin-bottom: 0;
}

/* Popup Styling */
.custom-popup .leaflet-popup-content-wrapper {
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.custom-popup .leaflet-popup-content {
    margin: 0;
    width: 270px !important;
}

.custom-popup .leaflet-popup-tip {
    background-color: var(--surface);
}

.player-popup {
    overflow: hidden;
}

.city-header {
    background: #06051a;
    color: white;
    padding: 1rem;
    position: relative;
}

.city-name {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    color: white;
}

.city-stats {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

.player-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
    background-color: var(--surface);
}

.player-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    margin-bottom: 0.5rem;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
}

.player-item:last-child {
    margin-bottom: 0;
}

.player-item:hover {
    background-color: var(--surface-3);
    transform: translateY(-1px);
}

.player-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    object-fit: cover;
    margin-right: 0.75rem;
    background-color: var(--surface-3);
    border: 2px solid var(--border);
}

.player-info {
    flex: 1;
}

.player-name {
    font-weight: 600;
    margin: 0;
    color: var(--text);
    display: block;
    font-size: 0.95rem;
}

.player-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
}

.player-detail {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.player-detail .material-icons-round {
    font-size: 0.9rem;
}

/* Material Icons Styling */
.material-icons-round {
    font-size: 1.25rem;
    line-height: 1;
}

/* Select2 Customization */
.select2-container--classic .select2-selection--single {
    height: 42px;
    border-color: var(--border);
    border-radius: var(--radius);
    background-color: var(--surface);
}

.select2-container--classic .select2-selection--single .select2-selection__rendered {
    line-height: 42px;
    padding-left: 1rem;
    color: var(--text);
}

.select2-container--classic .select2-selection--single .select2-selection__arrow {
    height: 40px;
    background-color: var(--surface-2);
    border-left-color: var(--border);
}

.select2-container--classic .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary);
}

.select2-container--classic .select2-search--dropdown .select2-search__field {
    border-color: var(--border);
    outline-color: var(--primary);
}

.select2-container--open {
    z-index: 9999 !important; /* чтобы список селекта точно был поверх карты */
}

/* Marker Cluster Customization */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: rgba(59, 130, 246, 0.2);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: var(--primary);
    color: white;
}

/* Leaflet Controls Styling */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
    background-color: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
    width: 36px;
    height: 36px;
    line-height: 36px;
    font-size: 1.25rem;
}

.leaflet-control-zoom a:hover {
    background-color: var(--surface-2) !important;
}

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

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Map Tools */
.map-card-wrapper {
    position: relative;
}

.map-tools {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 400;
}

.map-tool-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background-color: var(--surface);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.map-tool-btn:hover {
    background-color: var(--surface-2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Tooltips */
.tooltip {
    position: relative;
}

.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--surface-3);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    white-space: nowrap;
    box-shadow: var(--shadow);
    z-index: 100;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast-notification {
    background-color: var(--primary);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 300px;
    animation: fadeIn 0.3s ease-out;
}

.toast-error {
    background-color: var(--error);
}

/* User Location Marker */
.user-location-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .filters-container, 
    .stats-container {
        position: static;
        max-width: none;
        margin-bottom: 1rem;
    }
    
    .map-card {
        min-height: 400px;
    }
}

/* Mobile Optimization */
@media (max-width: 480px) {
    .map-title {
        font-size: 1.5rem;
    }
    
    .player-thumb {
        width: 40px;
        height: 40px;
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
    }
    
    .map-card {
        min-height: 350px;
    }
}

/* Print Styles */
@media print {
    .map-controls,
    .map-tools,
    .btn,
    .leaflet-control-zoom {
        display: none !important;
    }
    
    .map-card {
        box-shadow: none;
        border: 1px solid #ddd;
        height: 100vh;
    }
    
    .map-title {
        color: #000;
        background: none;
        -webkit-text-fill-color: #000;
    }
    
    .map-subtitle {
        color: #333;
    }
}