/* ===== СБРОС И БАЗОВЫЕ СТИЛИ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: #1a0e08;
    color: #3e2723;
    font-family: Georgia, 'Times New Roman', serif;
}

/* ===== КОНТЕЙНЕР ===== */
.container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* ===== КАРТА ===== */
#map {
    flex: 1;
    height: 100vh;
    width: calc(100vw - 420px);
    z-index: 1;
    background: #1a0e08;
    position: relative;
}

.sidebar.collapsed ~ #map,
.container:has(.sidebar.collapsed) #map {
    width: 100vw;
}

/* Когда sidebar свёрнут — карта на весь экран */
.container.sidebar-collapsed #map {
    width: 100vw;
}

/* Убираем стандартные контролы Leaflet */
.leaflet-control-attribution {
    display: none !important;
}

/* ===== КНОПКА СВОРАЧИВАНИЯ (всегда видна) ===== */
.toggle-btn {
    position: fixed;
    top: 15px;
    right: 435px;
    z-index: 1000;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(145deg, #a08050, #6b4c30);
    color: #f4e4bc;
    border: 2px solid #d4af37;
    font-size: 22px;
    cursor: pointer;
    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transition: all 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    transform: scale(1.1);
    box-shadow:
        0 4px 18px rgba(212, 175, 55, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Когда панель свёрнута — кнопка у правого края */
.sidebar.collapsed ~ .toggle-btn {
    right: 15px;
}

/* ===== БОКОВАЯ ПАНЕЛЬ ===== */
.sidebar {
    width: 420px;
    min-width: 420px;
    height: 100vh;
    background:
        /* Лёгкие пятна старины */
        radial-gradient(ellipse at 15% 20%, rgba(160, 120, 60, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 75%, rgba(120, 80, 30, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(100, 70, 30, 0.06) 0%, transparent 70%),
        /* Текстура волокон */
        repeating-linear-gradient(
            0deg,
            transparent 0px,
            transparent 3px,
            rgba(139, 90, 43, 0.04) 3px,
            rgba(139, 90, 43, 0.04) 4px
        ),
        /* Базовый пергамент */
        linear-gradient(170deg, #f5e6c8 0%, #eddcb3 30%, #e2cc9a 60%, #d9bf8a 100%);
    color: #3e2723;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.6);
    transition: transform 0.4s ease, margin-right 0.4s ease;
    border-left: 3px solid #8b6914;
    position: relative;
    z-index: 500;
}

/* Обводка-рамка внутри панели */
.sidebar::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid rgba(139, 105, 20, 0.2);
    pointer-events: none;
    z-index: 0;
}

.sidebar.collapsed {
    transform: translateX(420px);
}

/* ===== ЗАГОЛОВОК ПАНЕЛИ ===== */
.sidebar-header {
    padding: 22px 20px;
    background: linear-gradient(
        to bottom,
        rgba(101, 67, 33, 0.25) 0%,
        rgba(101, 67, 33, 0.08) 100%
    );
    border-bottom: 2px solid #8b6914;
    text-align: center;
    position: relative;
}

.sidebar-header::after {
    content: '— ❦ —';
    display: block;
    color: #8b6914;
    font-size: 14px;
    margin-top: 6px;
    letter-spacing: 8px;
}

.sidebar-header h2 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 26px;
    color: #3e2723;
    text-shadow: 1px 1px 0 rgba(212, 175, 55, 0.3);
    letter-spacing: 3px;
    font-weight: normal;
}

/* ===== СЕКЦИИ ПАНЕЛИ ===== */
.sidebar-section {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(139, 105, 20, 0.25);
    position: relative;
}

.sidebar-section h3 {
    font-family: Georgia, 'Times New Roman', serif;
    margin-bottom: 14px;
    color: #4a3015;
    font-size: 18px;
    font-weight: normal;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(139, 105, 20, 0.2);
    padding-bottom: 8px;
}

/* ===== ПОИСК ===== */
#search-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #a08050;
    border-radius: 3px;
    background: rgba(255, 248, 230, 0.6);
    color: #3e2723;
    font-family: Georgia, serif;
    font-size: 14px;
    box-shadow: inset 0 2px 5px rgba(101, 67, 33, 0.15);
    transition: border-color 0.2s, background 0.2s;
}

#search-input::placeholder {
    color: #9e8a6e;
    font-style: italic;
}

#search-input:focus {
    outline: none;
    border-color: #d4af37;
    background: rgba(255, 248, 230, 0.9);
    box-shadow: inset 0 2px 5px rgba(101, 67, 33, 0.15), 0 0 8px rgba(212, 175, 55, 0.3);
}

/* ===== ФИЛЬТРЫ ===== */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 7px 10px;
    border-radius: 3px;
    transition: background 0.2s;
    font-size: 14px;
    border: 1px solid transparent;
}

.filter-group label:hover {
    background: rgba(139, 105, 20, 0.1);
    border-color: rgba(139, 105, 20, 0.2);
}

.filter-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #8b6914;
    cursor: pointer;
}

/* ===== КНОПКИ ===== */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #8b6914;
    border-radius: 3px;
    font-family: Georgia, serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.25s;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(145deg, #8b6914, #6b4c10);
    color: #f5e6c8;
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.btn-primary:hover {
    background: linear-gradient(145deg, #a07a1a, #7d5a14);
    transform: translateY(-1px);
    box-shadow:
        0 4px 12px rgba(139, 105, 20, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-secondary {
    background: rgba(255, 248, 230, 0.5);
    color: #3e2723;
    border-color: #a08050;
}

.btn-secondary:hover {
    background: rgba(255, 248, 230, 0.85);
    border-color: #d4af37;
}

/* ===== СПИСОК ЛОКАЦИЙ (лаконичный дизайн) ===== */
.locations-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}

.location-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    background: rgba(255, 248, 230, 0.4);
    border: 1px solid rgba(139, 105, 20, 0.2);
    border-left: 3px solid #8b6914;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.15s, border-left-color 0.15s;
    font-size: 13px;
}

.location-item:hover {
    background: rgba(212, 175, 55, 0.15);
    border-left-color: #d4af37;
}

.location-item.active {
    background: rgba(212, 175, 55, 0.25);
    border-left-color: #d4af37;
    border-left-width: 4px;
    font-weight: 600;
}

.location-item h4 {
    margin: 0 0 4px 0;
    font-size: 14px;
    color: #3e2723;
    font-weight: 500;
    font-family: Georgia, serif;
    letter-spacing: 0.3px;
}

.location-item .type-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 2px;
    font-size: 10px;
    background: rgba(139, 105, 20, 0.15);
    color: #6b4c30;
    border: 1px solid rgba(139, 105, 20, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Убираем анимацию трансформации */
.location-item {
    transform: none !important;
}

.location-item:hover {
    transform: none !important;
}

/* ===== ДЕТАЛИ ЛОКАЦИИ ===== */
.location-details {
    background: rgba(139, 105, 20, 0.08);
}

.location-details h3 {
    font-family: Georgia, serif;
    color: #3e2723;
    font-size: 20px;
    font-weight: normal;
}

.location-details img {
    width: 100%;
    border-radius: 3px;
    margin: 12px 0;
    border: 2px solid #8b6914;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.location-details p {
    line-height: 1.7;
    margin: 12px 0;
    font-size: 14px;
    color: #4a3015;
    text-align: justify;
    font-style: italic;
}

/* ===== РЕДАКТОР: детали локации ===== */
.editor-sidebar .location-details {
    background: rgba(212, 175, 55, 0.1);
    border-bottom: 2px solid #d4af37;
}

.editor-sidebar #detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.editor-sidebar #detail-actions .btn-secondary {
    flex: 1;
    margin-bottom: 0;
}

/* ===== СВОРАЧИВАЕМЫЕ СЕКЦИИ ===== */
.collapsible {
    padding: 0 !important;
    border-bottom: 1px solid rgba(139, 105, 20, 0.25);
}

.collapsible-header {
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(139, 105, 20, 0.08);
    transition: background 0.2s;
    user-select: none;
}

.collapsible-header:hover {
    background: rgba(139, 105, 20, 0.18);
}

.collapsible-header h3 {
    margin: 0 !important;
    border: none !important;
    padding: 0 !important;
    font-size: 16px !important;
}

.collapse-icon {
    font-size: 12px;
    color: #8b6914;
    transition: transform 0.3s;
}

.collapsible-content {
    padding: 16px 20px;
    max-height: 800px;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease, opacity 0.25s ease;
    opacity: 1;
    width: 100%;
    box-sizing: border-box;
}

.collapsible-content.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    width: 100%;
}


/* ===== МОДАЛЬНОЕ ОКНО ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 14, 8, 0.85);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background:
        radial-gradient(ellipse at 30% 20%, rgba(160, 120, 60, 0.1) 0%, transparent 50%),
        linear-gradient(170deg, #f5e6c8, #e2cc9a);
    margin: 5% auto;
    padding: 32px 36px;
    width: 90%;
    max-width: 520px;
    border-radius: 4px;
    border: 3px double #8b6914;
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.7);
    animation: slideDown 0.3s ease;
    position: relative;
}

@keyframes slideDown {
    from { transform: translateY(-40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-content::before {
    content: '❦';
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    background: #eddcb3;
    padding: 0 12px;
    color: #8b6914;
    font-size: 22px;
}

.close {
    color: #8b6914;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close:hover {
    color: #d4af37;
}

.modal-content h3 {
    font-family: Georgia, serif;
    margin-bottom: 22px;
    color: #3e2723;
    font-size: 22px;
    text-align: center;
    letter-spacing: 1px;
    font-weight: normal;
}

/* ===== ФОРМЫ ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #4a3015;
    font-size: 13px;
    letter-spacing: 0.3px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #a08050;
    border-radius: 3px;
    font-family: Georgia, serif;
    font-size: 14px;
    background: rgba(255, 248, 230, 0.6);
    color: #3e2723;
    box-shadow: inset 0 2px 4px rgba(101, 67, 33, 0.12);
    transition: border-color 0.2s, background 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #d4af37;
    background: rgba(255, 248, 230, 0.9);
    box-shadow: inset 0 2px 4px rgba(101, 67, 33, 0.12), 0 0 6px rgba(212, 175, 55, 0.25);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #8b6914;
    margin-right: 8px;
    vertical-align: middle;
}

/* ===== ЭКРАН АВТОРИЗАЦИИ ===== */
.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background:
        radial-gradient(circle at 50% 40%, rgba(101, 67, 33, 0.35) 0%, transparent 60%),
        linear-gradient(145deg, #2c1810 0%, #1a0e08 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.auth-box {
    background:
        radial-gradient(ellipse at 30% 25%, rgba(160, 120, 60, 0.1) 0%, transparent 50%),
        linear-gradient(170deg, #f5e6c8, #e2cc9a);
    padding: 45px 40px;
    border: 3px double #8b6914;
    border-radius: 4px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.7);
    width: 90%;
    max-width: 420px;
    text-align: center;
    position: relative;
}

.auth-box::before,
.auth-box::after {
    content: '❦';
    position: absolute;
    color: #8b6914;
    font-size: 24px;
}

.auth-box::before { top: 8px; left: 50%; transform: translateX(-50%); }
.auth-box::after { bottom: 8px; left: 50%; transform: translateX(-50%); }

.auth-box h1 {
    font-family: Georgia, serif;
    color: #3e2723;
    font-size: 28px;
    margin-bottom: 8px;
    letter-spacing: 2px;
    font-weight: normal;
}

.auth-subtitle {
    color: #6b4c30;
    font-style: italic;
    margin-bottom: 28px;
    font-size: 13px;
}

.auth-hint {
    margin-top: 18px;
    font-size: 12px;
    color: #8b6914;
    font-style: italic;
}

.auth-hint code {
    background: rgba(139, 105, 20, 0.15);
    padding: 2px 8px;
    border-radius: 2px;
    font-family: 'Courier New', monospace;
    color: #3e2723;
}

/* ===== ПОДСКАЗКИ ===== */
.hint-text {
    font-size: 12px;
    color: #6b4c30;
    font-style: italic;
    text-align: center;
    margin-top: 8px;
}

/* ===== МАРКЕРЫ НА КАРТЕ ===== */
.custom-marker {
    font-size: 28px;
    text-align: center;
    filter: drop-shadow(2px 3px 4px rgba(0, 0, 0, 0.8));
    transition: transform 0.2s;
    /* Убираем белый фон divIcon */
    background: none !important;
    border: none !important;
}

.custom-marker:hover {
    transform: scale(1.3);
}

/* ===== РЕЖИМ РЕДАКТИРОВАНИЯ ===== */
.editor-sidebar {
    border-left-color: #6b4c10;
}

.edit-mode-active,
.edit-mode-active .leaflet-container {
    cursor: crosshair !important;
}

/* ===== СКРОЛЛБАР ===== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(139, 105, 20, 0.08);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #a08050, #6b4c30);
    border-radius: 3px;
    border: 2px solid rgba(245, 230, 200, 0.3);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #b8943e, #7d5a14);
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        min-width: 100%;
        position: absolute;
        right: 0;
        top: 0;
    }

    .sidebar.collapsed {
        transform: translateX(100%);
    }

    .toggle-btn {
        right: 15px;
    }
}
/* Принудительное растягивание карты */
.leaflet-container {
    width: 100% !important;
    height: 100% !important;
}

.leaflet-image-layer {
    max-width: none !important;
}
/* Исправление горизонтальной прокрутки */
.sidebar-section {
    overflow-x: hidden;
    width: 100%;
}

.location-item {
    overflow-x: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.location-item h4 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
/* ===== КОМПАКТНЫЕ КАТЕГОРИИ (ЧИПСЫ) ===== */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: rgba(255, 248, 230, 0.5);
    border: 1px solid rgba(139, 105, 20, 0.25);
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    font-family: Georgia, serif;
    color: #3e2723;
}

.filter-chip:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: #d4af37;
}

.filter-chip input[type="checkbox"] {
    width: 13px;
    height: 13px;
    margin: 0;
    accent-color: #8b6914;
    cursor: pointer;
}

.filter-chip.active {
    background: rgba(212, 175, 55, 0.3);
    border-color: #d4af37;
    font-weight: 600;
}

.filter-chip .chip-icon {
    font-size: 13px;
}

.filter-chip .chip-name {
    white-space: nowrap;
}

/* ===== УПРАВЛЕНИЕ КАТЕГОРИЯМИ ===== */
.categories-manage-list {
    margin-top: 10px;
}

.category-manage-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
    background: rgba(255, 248, 230, 0.4);
    border: 1px solid rgba(139, 105, 20, 0.2);
    border-radius: 3px;
    font-size: 13px;
}

.category-manage-item .cat-icon {
    font-size: 16px;
}

.category-manage-item .cat-name {
    flex: 1;
    color: #3e2723;
}

.category-manage-item .cat-actions {
    display: flex;
    gap: 4px;
}

.category-manage-item .cat-actions button {
    background: rgba(139, 105, 20, 0.15);
    border: 1px solid rgba(139, 105, 20, 0.3);
    border-radius: 3px;
    padding: 3px 7px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s;
    color: #3e2723;
}

.category-manage-item .cat-actions button:hover {
    background: rgba(212, 175, 55, 0.3);
}

.category-manage-item .cat-actions .btn-delete-cat {
    color: #8b2020;
}

.category-manage-item .cat-actions .btn-delete-cat:hover {
    background: rgba(139, 32, 32, 0.15);
}

/* ===== СПИСОК ЛОКАЦИЙ БЕЗ ВНУТРЕННЕГО СКРОЛЛА ===== */
.locations-list {
    max-height: none;
    overflow-y: visible;
    padding: 0;
}
/* ===== ПОДБОРКА ЭМОДЗИ ДЛЯ КАТЕГОРИЙ ===== */
.emoji-picker {
    margin-bottom: 15px;
    padding: 12px;
    background: rgba(139, 105, 20, 0.06);
    border: 1px solid rgba(139, 105, 20, 0.2);
    border-radius: 4px;
    max-height: 280px;
    overflow-y: auto;
}

.emoji-picker-label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: #6b4c30;
    font-style: italic;
}

.emoji-group {
    margin-bottom: 10px;
}

.emoji-group:last-child {
    margin-bottom: 0;
}

.emoji-group-title {
    font-size: 11px;
    color: #8b6914;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.emoji-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.emoji-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 248, 230, 0.6);
    border: 1px solid rgba(139, 105, 20, 0.2);
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.15s;
    padding: 0;
    line-height: 1;
}

.emoji-btn:hover {
    background: rgba(212, 175, 55, 0.3);
    border-color: #d4af37;
    transform: scale(1.15);
}

.emoji-btn.selected {
    background: rgba(212, 175, 55, 0.4);
    border-color: #d4af37;
    border-width: 2px;
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.4);
}