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

html {
    direction: rtl;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
}

.container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 320px;
    background-color: white;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: margin-left 0.3s ease;
}

.sidebar.minimized {
    margin-left: -320px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    background-color: #2196F3;
}

.sidebar h1 {
    padding: 20px;
    color: white;
    font-size: 24px;
    flex: 1;
    margin: 0;
}

.minimize-btn {
    padding: 15px 12px;
    background-color: transparent;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.2s;
    transform: scaleX(-1);
}

@media (max-width: 768px) {
.minimize-btn {
    rotate: 90deg; 
}
}

.minimize-btn:hover {
    background-color: rgba(0, 0, 0, 0.2);
}

.expand-btn {
    position: fixed;
    right: 0;
    top: 20px;
    padding: 10px 8px;
    background-color: #2196F3;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    border-radius: 0 4px 4px 0;
    z-index: 500;
    transition: all 0.3s ease;
    transform: scaleX(-1);
}

.expand-btn:hover {
    background-color: #1976D2;
}

.sidebar h3 {
    padding: 0;
    color: #333;
    font-size: 16px;
    margin: 0;
}

.filter-section {
    padding: 0;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    max-height: 50%;
    overflow-y: auto;
}

.mobile-tabs {
    display: none;
    border-bottom: 2px solid #e0e0e0;
    background-color: #f5f5f5;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    background-color: transparent;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: #2196F3;
    border-bottom-color: #2196F3;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    border-bottom: 1px solid #eee;
}

.section-header:hover {
    background-color: #f9f9f9;
}

.section-header h3 {
    flex: 1;
}

.toggle-icon {
    display: inline-block;
    font-size: 12px;
    rotate: 180deg;
    transition: transform 0.3s ease;
    color: #666;
}

.section-header.collapsed .toggle-icon {
    transform: rotate(180deg);
}

.section-content {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    overflow: hidden;
    animation: slideDown 0.3s ease;
}

.section-content.collapsed {
    max-height: 0;
    padding: 0;
    border-bottom: none;
    animation: slideUp 0.3s ease;
}

@keyframes slideDown {
    from {
        max-height: 0;
        opacity: 0;
    }
    to {
        max-height: 500px;
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        max-height: 500px;
        opacity: 1;
    }
    to {
        max-height: 0;
        opacity: 0;
    }
}

.range-slider {
    position: relative;
    margin-bottom: 10px;
    height: 30px;
}

.range-slider input[type="range"] {
    position: absolute;
    width: 100%;
    height: 6px;
    top: 12px;
    margin: 0;
    padding: 0;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    z-index: 5;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
}

.range-slider input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
}

.range-slider input[type="range"]::-webkit-slider-runnable-track {
    background: transparent;
    border: none;
}

.range-slider input[type="range"]::-moz-range-track {
    background: transparent;
    border: none;
}

.range-slider-track {
    position: absolute;
    width: 100%;
    height: 6px;
    top: 12px;
    background: #e0e0e0;
    border-radius: 3px;
    pointer-events: none;
    z-index: 1;
}

.range-slider #lengthMin {
    z-index: 5;
}

.range-slider #lengthMax {
    z-index: 4;
}

.length-display {
    font-size: 12px;
    color: #666;
    padding-top: 5px;
}

.tag-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.tag-checkbox:hover {
    background-color: #e0e0e0;
}

.tag-checkbox input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
}

.tag-checkbox input[type="checkbox"]:checked + span {
    font-weight: bold;
}

.tag-checkbox.active {
    background-color: #2196F3;
    color: white;
    border-color: #2196F3;
}

.btn-reset {
    width: calc(100% - 40px);
    margin: 15px 20px;
    padding: 10px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-reset:hover {
    background-color: #d32f2f;
}

.hikes-list {
    flex: 1;
    overflow-y: auto;
    border-top: 1px solid #eee;
}

.hikes-list h3 {
    padding: 15px 20px 10px;
    color: #333;
    font-size: 16px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background-color: white;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background-color: #f9f9f9;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 45px;
}

.sort-controls label {
    font-size: 13px;
    font-weight: 500;
    color: #666;
}

.sort-controls select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.sort-controls select:hover {
    border-color: #2196F3;
}

.sort-controls select:focus {
    outline: none;
    border-color: #2196F3;
}

.hikes-list ul {
    list-style: none;
}

.hikes-list li {
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.hikes-list li:hover {
    background-color: #f9f9f9;
}

.hikes-list li.active {
    background-color: #E3F2FD;
    border-right: 4px solid #2196F3;
}

.hike-item-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.hike-item-info {
    font-size: 12px;
    color: #666;
}

.map-container {
    flex: 1;
    flex-direction: row-reverse;
    position: relative;
    transition: margin-left 0.3s ease;
}

#map {
    width: 100%;
    height: 100%;
}

.popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background-color: white;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.popup.show {
    display: block;
}

.popup-content {
    padding: 25px;
    position: relative;
}

.popup-close {
    position: absolute;
    top: 10px;
    left: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}

.popup-close:hover {
    color: #333;
}

.popup h3 {
    margin-bottom: 15px;
    color: #333;
    padding-right: 20px;
}

.popup p {
    margin-bottom: 10px;
    font-size: 14px;
    color: #555;
}

.popup p strong {
    color: #333;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 50vh;
        display: flex;
        flex-direction: column;
        transition: max-height 0.3s ease;
    }

    .sidebar.minimized {
        margin-left: 0;
        max-height: 50px;
        overflow: hidden;
    }

    .sidebar-header {
        flex-shrink: 0;
    }

    .sidebar h1 {
        font-size: 18px;
        padding: 15px 20px;
    }

    .mobile-tabs {
        display: flex;
        border-bottom: 2px solid #e0e0e0;
        background-color: #f5f5f5;
        flex-shrink: 0;
    }

    .tab-btn {
        flex: 1;
        padding: 12px 16px;
        background-color: transparent;
        border: none;
        font-size: 14px;
        font-weight: 500;
        color: #666;
        cursor: pointer;
        border-bottom: 3px solid transparent;
        transition: all 0.3s ease;
    }

    .tab-btn.active {
        color: #2196F3;
        border-bottom-color: #2196F3;
    }

    .filter-section {
        padding: 0;
        border-bottom: none;
        flex-shrink: 0;
        max-height: 100%;
        overflow-y: auto;
        display: none;
    }

    .filter-section.active {
        display: block;
    }

    .hikes-list {
        flex: 1;
        overflow-y: auto;
        border-top: none;
        display: none;
    }

    .hikes-list.active {
        display: flex;
        flex-direction: column;
    }

    .hikes-list h3 {
        padding: 15px 20px 10px;
        position: sticky;
        top: 0;
        flex-shrink: 0;
        background-color: white;
        border-bottom: 1px solid #eee;
    }

    .hikes-list ul {
        flex: 1;
        overflow-y: auto;
    }

    .map-container {
        height: calc(100vh - 50vh);
        flex-shrink: 0;
    }

    .minimize-btn {
        display: block;
        padding: 12px;
        font-size: 16px;
        transition: transform 0.3s ease;
    }

    .sidebar.minimized .minimize-btn {
        transform: rotate(180deg);
    }

    .expand-btn {
        display: none !important;
    }

    .section-header {
        padding: 12px 15px;
    }

    .section-header h3 {
        font-size: 14px;
    }

    .section-content {
        padding: 12px 15px;
    }

    .btn-reset {
        margin: 10px 15px;
        width: calc(100% - 30px);
        padding: 8px;
        font-size: 13px;
    }

    .tag-checkbox {
        font-size: 11px;
        padding: 5px 10px;
    }

    .hikes-list li {
        padding: 10px 15px;
    }

    .hike-item-title {
        font-size: 14px;
    }

    .hike-item-info {
        font-size: 11px;
    }
}

/* Loading animation */
.loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2196F3;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 10px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.leaflet-popup-content-wrapper {
    text-align: right;
}