* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background: #201e43;
    color: #e5d9f2;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Prevent container overflow */
}

/* Sidebar Navigation - Desktop */
.nav-sidebar {
    width: 80px;
    background: #201e43;
    height: 100vh;
    padding: 1.5rem 1rem;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    transition: width 0.3s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-sidebar:hover {
    width: 240px;
}

.nav-logo {
    font-size: 1.5rem;
    color: #e5d9f2;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.5rem;
    white-space: nowrap;
    overflow: hidden;
}

.nav-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    margin-right: -4px; /* Adjust spacing when sidebar is collapsed */
}

.nav-logo span {
    font-size: 1.2rem;
    font-weight: 600;
    color: #e5d9f2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-sidebar:hover .nav-logo span {
    opacity: 1;
}

.nav-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.nav-button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}

.nav-button i {
    font-size: 1.4rem;
    min-width: 24px;
    text-align: center;
}

.nav-button span {
    font-size: 1rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-sidebar:hover .nav-button span {
    opacity: 1;
}

.nav-button:hover {
    color: #e5d9f2;
    background: rgba(229, 217, 242, 0.1);
}

.nav-button.active {
    color: #e5d9f2;
    background: rgba(255, 255, 255, 0.15);
    position: relative;
}

.nav-button.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: #ffffff;
    border-radius: 0 2px 2px 0;
}

/* Logout button styling */
.logout-button {
    margin-top: auto !important; /* Push to bottom of nav */
    background: rgba(220, 53, 69, 0.1) !important;
    border: 1px solid rgba(220, 53, 69, 0.3) !important;
}

.logout-button:hover {
    background: rgba(220, 53, 69, 0.2) !important;
    color: #dc3545 !important;
}

.logout-button i {
    color: #dc3545;
}

/* Mobile logout button */
@media (max-width: 768px) {
    .logout-button {
        margin-top: 0 !important;
        order: 4;
        background: rgba(220, 53, 69, 0.1) !important;
        border: 1px solid rgba(220, 53, 69, 0.2) !important;
        margin: 0 !important; /* Remove all margins */
    }

    .logout-button:hover {
        background: rgba(220, 53, 69, 0.2) !important;
    }

    .logout-button i {
        color: #dc3545;
    }
}

/* Main Content Area */
.main-content {
    flex: 1;
    position: relative;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.view-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.view-section.active {
    opacity: 1;
    visibility: visible;
}

/* Map View */
#map-view {
    background: #1a1b1e;
    height: 100%;
}

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

/* City Legend Styling */
.city-legend-control {
    margin: 1rem !important;
}

.city-legend {
    background: #2c2d31;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    min-width: 200px;
    backdrop-filter: blur(10px);
}

.city-legend-header {
    color: #e5d9f2;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.city-button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: #363940;
    border: none;
    color: #e5d9f2;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95em;
    position: relative;
    overflow: hidden;
}

.city-button:hover {
    background: #404249;
    transform: translateY(-1px);
}

.city-button .city-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Custom marker styling */
.marker-pin {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #2c2d31;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);    border: 2px solid #e5d9f2;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.2em;
}

.custom-div-icon {
    background: transparent;
    border: none;
}

.marker-pin:hover {
    transform: scale(1.15);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

/* Map Popups */
.leaflet-popup-content-wrapper {
    background: #201e43;
    color: #e5d9f2;
    border-radius: 12px;
}

.leaflet-popup-tip {
    background: #201e43;
}

.leaflet-container a {
    color: #e5d9f2;
}

/* Style for location type tags */
.location-type {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(229, 217, 242, 0.15);
    color: #e5d9f2;
    font-size: 0.8em;
    margin-bottom: 8px;
}

/* Style for location tips */
.location-tip {
    margin-top: 8px;
    padding: 8px;
    background: rgba(229, 217, 242, 0.1);
    border-radius: 4px;
    font-size: 0.9em;
}

/* Map controls styling */
.leaflet-control-zoom a {
    background: #201e43 !important;
    color: #e5d9f2 !important;
    border-color: rgba(229, 217, 242, 0.2) !important;
}

.leaflet-control-zoom a:hover {
    background: #2a2858 !important;
}

.back-button {
    background: #201e43 !important;
    color: #e5d9f2 !important;
    border-color: rgba(229, 217, 242, 0.2) !important;
}

/* Gallery View */
.gallery-container {
    padding: 2rem;
    padding-bottom: calc(2rem + 60px); /* Add extra padding to account for the nav bar */
    max-width: 1400px;
    margin: 0 auto;
    color: #e5d9f2;
    min-height: 100%;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal overflow */
}

.gallery-container h2 {
    color: #e5d9f2;
    font-size: 2rem;
    margin-bottom: 2rem;
}

.gallery-cities {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    width: 100%;
    overflow: hidden; /* Ensure content doesn't overflow */
}

.gallery-city {
    background: rgba(229, 217, 242, 0.05);
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    overflow: hidden; /* Prevent city card overflow */
}

.gallery-city-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 1rem;
}

.gallery-city-header h3 {
    color: #e5d9f2;
    font-size: 1.5rem;
    flex: 1;
    min-width: 0; /* Allow text to shrink */
}

.view-map-button {
    background: #201e43;
    border: 1px solid rgba(229, 217, 242, 0.2);
    color: #e5d9f2;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    white-space: nowrap; /* Prevent button text wrapping */
}

.view-map-button:hover {
    background: rgba(229, 217, 242, 0.1);
    transform: translateY(-1px);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    width: 100%;
    overflow: hidden;
}

.gallery-item {
    background: #201e43;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease;
    max-width: 100%;
}

.gallery-item:hover {
    transform: translateY(-4px);
}

.gallery-item img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.gallery-item-info {
    padding: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.gallery-item-title {
    color: #e5d9f2;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    word-wrap: break-word;
}

.gallery-item-location {
    color: rgba(229, 217, 242, 0.7);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    word-wrap: break-word;
}

.gallery-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.gallery-tag {
    background: rgba(229, 217, 242, 0.1);
    color: #e5d9f2;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    word-break: break-word;
}

/* Admin Panel Styles */
.admin-container {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    color: #e5d9f2;
}

.admin-container h2 {
    color: #e5d9f2;
    font-size: 2rem;
    margin-bottom: 2rem;
}

.admin-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.admin-section {
    background: rgba(229, 217, 242, 0.05);
    border: 1px solid rgba(229, 217, 242, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
}

.admin-section h3 {
    color: #e5d9f2;
    font-size: 1.3rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.upload-form input[type="file"] {
    background: #201e43;
    border: 2px dashed rgba(229, 217, 242, 0.3);
    border-radius: 8px;
    padding: 1rem;
    color: #e5d9f2;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.upload-form input[type="file"]:hover {
    border-color: rgba(229, 217, 242, 0.5);
}

.admin-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.admin-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.admin-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.admin-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.admin-btn.danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.admin-btn.danger:hover {
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

/* Show admin elements only for admin users */
.admin-only {
    display: none !important;
}

.admin-only.show {
    display: flex !important;
}

/* Gallery Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    z-index: 1001;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.modal-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    padding: 2rem;
}

.modal-image {
    max-width: 70%;
    max-height: 80%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-info {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    right: 2rem;
    background: rgba(32, 30, 67, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(229, 217, 242, 0.2);
}

.modal-title {
    color: #e5d9f2;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.modal-location {
    color: rgba(229, 217, 242, 0.8);
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.modal-tag {
    background: rgba(229, 217, 242, 0.2);
    color: #e5d9f2;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
    border: 1px solid rgba(229, 217, 242, 0.3);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 2rem;
    pointer-events: none;
}

.modal-nav-button {
    background: rgba(32, 30, 67, 0.8);
    border: 1px solid rgba(229, 217, 242, 0.3);
    color: #e5d9f2;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    pointer-events: auto;
    backdrop-filter: blur(10px);
}

.modal-nav-button:hover {
    background: rgba(229, 217, 242, 0.2);
    border-color: rgba(229, 217, 242, 0.5);
    transform: scale(1.1);
}

.modal-nav-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile responsive modal */
@media (max-width: 768px) {
    .modal-image {
        max-width: 90%;
        max-height: 60%;
    }
    
    .modal-info {
        position: static;
        margin-top: 1rem;
        margin-left: 1rem;
        margin-right: 1rem;
    }
    
    .modal-content {
        flex-direction: column;
        padding: 1rem;
    }
    
    .modal-nav {
        position: static;
        transform: none;
        margin-top: 1rem;
        padding: 0 1rem;
        justify-content: space-around;
    }
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    /* Navigation - Mobile */
    .nav-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: 65px;
        padding: 0.5rem 1rem;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        z-index: 1001;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        gap: 0.5rem;
        background: rgba(32, 30, 67, 0.95);
        backdrop-filter: blur(10px);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    }

    .nav-sidebar:hover {
        width: 100vw;
    }

    .nav-logo {
        display: none;
    }

    .nav-buttons {
        display: flex;
        flex-direction: row;
        gap: 0.25rem;
        width: 100%;
        justify-content: space-evenly;
        align-items: center;
    }

    .nav-button {
        flex-direction: column;
        padding: 0.5rem 0.75rem;
        gap: 0.25rem;
        min-width: auto;
        border-radius: 10px;
        flex: 1;
        max-width: 80px;
        font-size: 0.75rem;
        text-align: center;
        transition: all 0.2s ease;
    }

    .nav-button i {
        font-size: 1.2rem;
        margin-bottom: 0.1rem;
    }

    .nav-button span {
        font-size: 0.65rem;
        opacity: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.1;
        font-weight: 500;
    }

    .nav-button.active {
        background: rgba(255, 255, 255, 0.15);
        transform: translateY(-1px);
    }

    .nav-button:hover {
        background: rgba(229, 217, 242, 0.1);
    }

    .logout-button {
        margin-top: 0 !important;
        order: 4;
        background: rgba(220, 53, 69, 0.1) !important;
        border: 1px solid rgba(220, 53, 69, 0.2) !important;
        margin: 0 !important; /* Remove all margins */
    }

    .logout-button:hover {
        background: rgba(220, 53, 69, 0.2) !important;
    }

    .logout-button i {
        color: #dc3545;
    }

    /* Main content - adjust for bottom nav */
    .main-content {
        padding-bottom: 65px;
    }

    .view-section {
        height: calc(100vh - 65px);
    }

    /* Map view mobile */
    #map-view {
        height: calc(100vh - 65px);
    }

    #map {
        height: 100%;
    }

    /* City legend mobile - adjust position for new nav height */
    .city-legend-control {
        position: fixed;
        bottom: 75px;
        left: 0.5rem;
        right: 0.5rem;
        margin: 0 !important;
        z-index: 1000;
    }

    .city-legend {
        max-height: calc(100vh - 150px); /* Increase available space */
        overflow: hidden;
        padding: 0;
        border-radius: 12px;
        backdrop-filter: blur(15px);
        background: rgba(44, 45, 49, 0.95);
        transition: max-height 0.3s ease;
    }

    .city-legend.collapsed {
        max-height: 50px;
    }

    .city-legend-header {
        font-size: 0.9rem;
        padding: 0.75rem;
        margin: 0;
        background: rgba(229, 217, 242, 0.1);
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid rgba(229, 217, 242, 0.1);
    }

    .city-legend-toggle {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        color: rgba(229, 217, 242, 0.7);
        font-size: 0.8rem;
    }

    .city-legend-toggle i {
        transition: transform 0.3s ease;
        font-size: 0.8rem;
    }

    .city-legend.collapsed .city-legend-toggle i {
        transform: rotate(180deg);
    }

    .city-legend-content {
        padding: 0.75rem;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 0.4rem;
        max-height: calc(100vh - 225px); /* Give more room for content */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    .city-legend.collapsed .city-legend-content {
        display: none;
    }

    .city-button {
        padding: 0.4rem 0.3rem;
        font-size: 0.65rem;
        margin: 0;
        border-radius: 6px;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.15rem;
        min-height: 45px;
        border: 1px solid rgba(229, 217, 242, 0.2);
        background: rgba(229, 217, 242, 0.05);
        transition: all 0.2s ease;
    }

    .city-button:hover {
        background: rgba(229, 217, 242, 0.1);
        transform: translateY(-1px);
    }

    .city-button .city-dot {
        width: 6px;
        height: 6px;
        margin: 0;
        flex-shrink: 0;
        border-radius: 50%;
    }

    .city-button span {
        line-height: 1;
        font-weight: 500;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Leaflet controls mobile - adjust position */
    .leaflet-control-zoom {
        margin-top: 0.5rem !important;
        margin-right: 0.5rem !important;
    }

    .leaflet-control-zoom a {
        width: 35px !important;
        height: 35px !important;
        line-height: 35px !important;
        font-size: 16px !important;
    }

    .back-control {
        margin-top: 0.5rem !important;
        margin-left: 0.5rem !important;
    }

    .back-button {
        width: 35px !important;
        height: 35px !important;
        line-height: 35px !important;
        font-size: 14px !important;
    }

    .gallery-city-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .gallery-city-content.expanded {
        max-height: none; /* Adjust as needed */
    }
    
    .gallery-city-toggle {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .gallery-city-toggle i {
        transition: transform 0.3s ease;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .nav-button span {
        font-size: 0.6rem;
    }

    .nav-button {
        padding: 0.3rem 0.15rem;
        max-width: 65px;
    }

    .nav-button i {
        font-size: 1rem;
    }

    /* Single column on very small screens */
    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .gallery-city-header h3 {
        font-size: 1rem;
    }

    .gallery-city-toggle {
        font-size: 0.8rem;
    }

    .city-legend {
        padding: 0.6rem;
    }

    .city-button {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }

    .modal-nav-button {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }

    .leaflet-control-zoom {
        margin-top: 160px !important;
    }

    .back-control {
        margin-top: 160px !important;
    }
}
