/* Основные стили */
body, html { 
    margin: 0; 
    padding: 0; 
    height: 100%; 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

#map { 
    width: 100%; 
    height: 100vh; 
    position: relative; 
}

/* Слой для наших маркеров поверх карты */
#custom-markers-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Контейнер маркера */
.marker-container {
    position: absolute;
    transform: translate(-50%, -100%);
    pointer-events: auto;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1000;
}

/* Точка маркера */
.marker-dot {
    width: 20px;
    height: 20px;
    background-color: #ff4444;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

.marker-container:hover .marker-dot {
    transform: scale(1.2);
}

/* Свой маркер (синий) */
.marker-container.own-marker .marker-dot {
    background-color: #4285f4;
}

/* Никнейм на маркере */
.marker-username {
    background: rgba(0,0,0,0.7);
    color: #ffd700;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 2px;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    z-index: 1001;
}

/* Заголовок маркера (всегда виден) */
.marker-title {
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    margin-bottom: 4px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 1001;
}

/* Попап с подробной информацией */
.marker-popup {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.3);
    width: 280px;
    display: none;
    margin-bottom: 15px;
    pointer-events: auto;
    z-index: 2147483647 !important;
    overflow: hidden;
}

.marker-popup.active {
    display: block;
    z-index: 2147483647 !important;
}

.marker-popup:after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -8px;
    border-width: 8px;
    border-style: solid;
    border-color: white transparent transparent transparent;
}

.popup-header {
    background: #f8f9fa;
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
}

.popup-username {
    color: #4285f4;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 4px;
}

.popup-title {
    color: #333;
    font-size: 16px;
    font-weight: bold;
    word-wrap: break-word;
}

.popup-content {
    padding: 12px;
    max-height: 150px;
    overflow-y: auto;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f8f9fa;
}

.popup-content::-webkit-scrollbar {
    width: 6px;
}

.popup-content::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.popup-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.popup-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.popup-actions {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.popup-actions button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s;
}

.popup-actions button:hover {
    opacity: 0.9;
}

.edit-btn {
    background: #ffc107;
    color: #333;
}

.delete-btn {
    background: #dc3545;
    color: white;
}

/* Оверлей для неавторизованных */
#auth-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    backdrop-filter: blur(5px);
    pointer-events: none;
}

#auth-overlay span {
    font-size: 18px;
    display: block;
    margin-top: 10px;
    color: #ffd700;
}

/* Панель авторизации */
.auth-panel {
    position: absolute;
    top: 20px;
    right: 50px;
    z-index: 10001;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    min-width: 300px;
}

.auth-panel h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    border-bottom: 2px solid #4285f4;
    padding-bottom: 10px;
}

.auth-panel input {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 14px;
}

.auth-panel input:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 2px rgba(66,133,244,0.2);
}

.auth-panel button {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    background: #4285f4;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.auth-panel button:hover {
    background: #3367d6;
}

.auth-panel .logout-btn {
    background: #dc3545;
}

.auth-panel .logout-btn:hover {
    background: #c82333;
}

.auth-panel .switch-btn {
    background: transparent;
    color: #4285f4;
    border: 2px solid #4285f4;
}

.auth-panel .switch-btn:hover {
    background: #e8f0fe;
}

/* Панель добавления маркера */
.marker-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10001;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    width: 350px;
    display: none;
}

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

.marker-panel h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    border-bottom: 2px solid #4285f4;
    padding-bottom: 10px;
}

/* Поле ввода с счетчиком */
.input-with-counter {
    position: relative;
    margin-bottom: 10px;
}

.input-with-counter input,
.input-with-counter textarea {
    width: 100%;
    padding: 10px;
    margin: 8px 0 2px 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 14px;
}

.input-with-counter textarea {
    min-height: 100px;
    resize: vertical;
}

/* Счетчики символов */
.char-counter {
    font-size: 11px;
    color: #999;
    text-align: right;
    margin-top: 2px;
    padding-right: 5px;
}

.char-counter.warning {
    color: #ffc107;
}

.char-counter.danger {
    color: #dc3545;
    font-weight: bold;
}

.marker-panel button {
    padding: 10px 20px;
    margin: 8px 5px 0 0;
    background: #4285f4;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.marker-panel .cancel-btn {
    background: #6c757d;
}

.marker-panel .delete-btn {
    background: #dc3545;
}

.marker-panel .hint {
    font-size: 12px;
    color: #666;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

/* Информация о пользователе */
.user-info {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #4285f4;
}

/* Сообщения об ошибках */
.error {
    color: #dc3545;
    font-size: 13px;
    margin-top: 5px;
    padding: 5px;
    background: #f8d7da;
    border-radius: 4px;
}

.success {
    color: #28a745;
    font-size: 13px;
    margin-top: 5px;
    padding: 5px;
    background: #d4edda;
    border-radius: 4px;
}

/* Кнопка администрирования */
.admin-btn {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    background: #6f42c1;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.admin-btn:hover {
    background: #5a32a3;
}

/* Панель администрирования */
.admin-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    max-width: 1300px;
    height: 90vh;
    max-height: 800px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 20000;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #6f42c1;
    flex-shrink: 0;
}

.admin-header h3 {
    margin: 0;
    color: #333;
}

.close-admin-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    padding: 5px 10px;
}

.close-admin-btn:hover {
    color: #333;
}

.admin-search {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.admin-search input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.admin-search button {
    padding: 10px 20px;
    background: #4285f4;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.admin-search button:hover {
    background: #3367d6;
}

.admin-stats {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 14px;
    color: #666;
    flex-shrink: 0;
}

.admin-stats span {
    font-weight: bold;
    color: #6f42c1;
}

.users-table-container {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    min-height: 200px;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.users-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 10;
}

.users-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    color: #555;
}

.users-table tr:hover {
    background: #f8f9fa;
}

.users-table .loading {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

/* Статусы пользователей */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-blocked {
    background: #f8d7da;
    color: #721c24;
}

.role-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    background: #e2e3e5;
    color: #383d41;
}

.role-admin {
    background: #cce5ff;
    color: #004085;
}

.role-moderator {
    background: #d4edda;
    color: #155724;
}

/* Кнопки действий */
.action-btn {
    padding: 6px 12px;
    margin: 2px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    min-width: 60px;
}

.action-btn:hover {
    opacity: 0.8;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.action-btn.edit {
    background: #6f42c1;
    color: white;
}

.action-btn.block {
    background: #ffc107;
    color: #333;
}

.action-btn.activate {
    background: #28a745;
    color: white;
}

.action-btn.delete {
    background: #dc3545;
    color: white;
}

.action-btn.password {
    background: #17a2b8;
    color: white;
}

/* Пагинация */
.admin-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 10px 0;
    flex-shrink: 0;
}

.page-btn {
    padding: 8px 16px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: #e9ecef;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#pageInfo {
    font-size: 14px;
    color: #666;
}

/* Модальные окна */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 21000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

.modal-content h4 {
    margin: 0 0 20px 0;
    color: #333;
    padding-right: 20px;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    position: sticky;
    bottom: 0;
    background: white;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.modal-actions button:first-child {
    background: #6f42c1;
    color: white;
}

.modal-actions button:first-child:hover {
    background: #5a32a3;
}

.modal-actions button:last-child {
    background: #6c757d;
    color: white;
}

.modal-actions button:last-child:hover {
    background: #5a6268;
}

/* Модальное окно редактирования пользователя */
.edit-user-modal {
    max-width: 550px !important;
}

.edit-form {
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-size: 13px;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #6f42c1;
    box-shadow: 0 0 0 3px rgba(111, 66, 193, 0.1);
}

.form-group select {
    height: 42px;
    background-color: white;
    cursor: pointer;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.status-display {
    padding: 8px 0;
}

.role-select option[value="admin"] {
    color: #6f42c1;
    font-weight: bold;
}

.role-select option[value="moderator"] {
    color: #28a745;
}

/* Заголовок таблицы */
.users-table th:nth-child(7) {
    min-width: 280px;
}

/* Анимации */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}