/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background-color: #f0f2f6;
    color: #262730;
    line-height: 1.6;
}

/* Container layout */
.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 500px;
    background-color: white;
    border-right: 1px solid #e6e9ef;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-header {
    margin-bottom: 1.5rem;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #262730;
}

.sidebar-header p {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Album selector */
.album-selector {
    margin-bottom: 1.5rem;
}

.album-selector h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #262730;
}

#albumSelect {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    background-color: white;
}

/* Mobile header */
.mobile-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: white;
    border-bottom: 1px solid #e6e9ef;
}

.mobile-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #262730;
    margin: 0;
}

.sidebar-toggle-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.sidebar-toggle-btn:hover {
    background-color: #f0f2f6;
}

.toggle-icon {
    font-size: 1.2rem;
    color: #6c757d;
    transition: transform 0.3s ease;
}

/* Map container */
.map-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.map-container h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #262730;
}

#map {
    flex: 1;
    min-height: 400px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* Main content */
.main-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background-color: #f0f2f6;
}

.gallery-header {
    margin-bottom: 1rem;
}

.gallery-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #262730;
    margin-bottom: 0.5rem;
}

#photoCount {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Gallery */
.gallery {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.no-photos {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
    font-size: 1.1rem;
}

.photo-item {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s ease;
}

.photo-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.photo-item img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.photo-item img:hover {
    transform: scale(1.02);
}

.photo-caption {
    margin-top: 0.5rem;
    font-weight: 600;
    color: #262730;
}

.photo-coordinates {
    margin-top: 0.25rem;
    color: #6c757d;
    font-size: 0.9rem;
}

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

.modal-content {
    position: relative;
    margin: auto;
    padding: 20px;
    width: 90%;
    max-width: 1200px;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
}

.modal-content img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 8px;
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.close:hover,
.close:focus {
    color: #bbb;
}

#modalCaption {
    color: white;
    margin-top: 1rem;
    font-size: 1.1rem;
}

/* Loading spinner */
.loading-spinner {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255,255,255,0.8);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ff6b6b;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Responsive design */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: 100vh;
    }
    
    /* Show mobile header */
    .mobile-header {
        display: flex;
        order: -1;
    }
    
    /* Show toggle button on mobile */
    .sidebar-toggle-btn {
        display: block;
    }
    
    /* Hide desktop sidebar header on mobile */
    .sidebar .sidebar-header {
        display: none;
    }
    
    /* Sidebar mobile styles */
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 60vh;
        overflow-y: auto;
        transition: max-height 0.3s ease, opacity 0.3s ease;
        order: 0;
    }
    
    .sidebar.collapsed {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        padding: 0;
        border-bottom: none;
    }
    
    .sidebar.collapsed .toggle-icon {
        transform: rotate(180deg);
    }
    
    /* Main content mobile styles */
    .main-content {
        flex: 1;
        min-height: 40vh;
        order: 1;
    }
    
    /* Adjust main content when sidebar is collapsed */
    .container.sidebar-collapsed .main-content {
        min-height: calc(100vh - 60px); /* Account for mobile header */
    }
    
    /* Map adjustments for mobile */
    .map-container {
        flex: none;
    }
    
    #map {
        min-height: 200px;
        max-height: 250px;
    }
}

/* Leaflet popup customization */
.leaflet-popup-content {
    margin: 8px 12px;
    line-height: 1.4;
}

.popup-image {
    width: 200px;
    height: auto;
    border-radius: 4px;
    cursor: pointer;
}

.popup-filename {
    margin-top: 0.5rem;
    font-weight: 600;
    color: #262730;
    text-align: center;
}

/* Authentication styles */
.auth-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.auth-content {
    background: white;
    padding: 3rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.auth-content h2 {
    margin-bottom: 1rem;
    color: #262730;
    font-size: 1.5rem;
}

.auth-content p {
    margin-bottom: 2rem;
    color: #6c757d;
    font-size: 1rem;
}

#loginForm {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

#passwordInput {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
}

#passwordInput:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.auth-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.auth-btn:hover {
    background-color: #0056b3;
}

.auth-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.error-message {
    color: #dc3545;
    font-size: 0.9rem;
    text-align: center;
    padding: 0.5rem;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

.logout-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-top: 1rem;
}

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

/* Lazy loading styles */
.lazy-image {
    transition: opacity 0.3s ease;
}

.lazy-image.loading {
    opacity: 0.6;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

.lazy-image.loaded {
    opacity: 1;
}

@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Placeholder for lazy images */
.lazy-image[src*="data:image/svg+xml"] {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
}
