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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #e9ecef;
    background: #0f0f0f;
    min-height: 100vh;
}

.container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    gap: 20px;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #1a1a1a;
    border-radius: 12px;
    padding: 16px;
    height: fit-content;
    border: 1px solid #2a2a2a;
    position: sticky;
    top: 20px;
}

.sidebar-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #2a2a2a;
}

.sidebar-header h3 {
    color: #e9ecef;
    font-size: 1.1rem;
    font-weight: 600;
}

.folder-tree {
    max-height: 70vh;
    overflow-y: auto;
}

.folder-tree-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 4px 8px;
    margin: 1px 0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #b0b0b0;
    font-size: 0.7rem;
    font-weight: normal;
    min-height: 22px;
}

.folder-tree-item:hover {
    background: #2a2a2a;
    color: #e9ecef;
}

.folder-tree-item.active {
    background: #007bff;
    color: white;
}

.folder-tree-item .tree-lines {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 15px;
    pointer-events: none;
}

.folder-tree-item .tree-line {
    position: absolute;
    background: #666;
    height: 1px;
}

.folder-tree-item .tree-line.horizontal {
    top: 50%;
    right: 0;
    width: 10px;
    transform: translateY(-50%);
}

.folder-tree-item .tree-line.vertical {
    top: 0;
    right: 10px;
    width: 1px;
    height: 50%;
}

.folder-tree-item .tree-line.vertical-bottom {
    top: 50%;
    right: 10px;
    width: 1px;
    height: 50%;
}

/* Root level items don't need tree lines */
.folder-tree-item.root-level .tree-lines {
    display: none;
}

.folder-tree-item .folder-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    font-weight: normal !important;
}

/* Removed expand icon and children styles since we use flat list */

/* Main content area */
main {
    flex: 1;
    min-width: 0;
}

/* Header - Hidden */
header {
    display: none;
}

/* Auth Section */
.auth-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.auth-card {
    background: #2d2d2d;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 100%;
    border: 1px solid #404040;
}

.auth-card h2 {
    color: #e9ecef;
    margin-bottom: 16px;
    font-size: 1.8rem;
}

.auth-card p {
    color: #adb5bd;
    margin-bottom: 30px;
    line-height: 1.5;
}

.auth-button {
    background: #0078d4;
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.3);
}

.auth-button:hover {
    background: #106ebe;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 120, 212, 0.4);
}

.auth-button:active {
    transform: translateY(0);
}

/* Gallery Section */
.gallery-section {
    background: #1a1a1a;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid #2a2a2a;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #404040;
}

.breadcrumb {
    flex: 1;
    margin-right: 20px;
}

.breadcrumb span {
    color: #e9ecef;
    font-size: 1.2rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.gallery-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.gallery-header h2 {
    color: #e9ecef;
    font-size: 1.8rem;
}

.back-button {
    background: #6c757d;
    border: 2px solid #6c757d;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.back-button:hover {
    background: #5a6268;
    border-color: #5a6268;
}

.share-current-button {
    background: #007bff;
    border: 2px solid #007bff;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.share-current-button:hover {
    background: #0056b3;
    border-color: #0056b3;
    transform: translateY(-2px);
}

.refresh-button {
    background: #404040;
    border: 2px solid #555;
    color: #e9ecef;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.refresh-button:hover {
    background: #555;
    border-color: #666;
}

.logout-button {
    background: #dc3545;
    border: 2px solid #dc3545;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.logout-button:hover {
    background: #c82333;
    border-color: #bd2130;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #555;
    border-top: 4px solid #0078d4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading p {
    color: #adb5bd;
    font-size: 1.1rem;
}

/* Error State */
.error {
    text-align: center;
    padding: 40px 20px;
    color: #ff6b6b;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.error p {
    font-size: 1.1rem;
}

/* Gallery Grid - Masonry-style layout */
.gallery {
    column-count: 4;
    column-gap: 20px;
    margin-top: 20px;
}

/* When gallery contains folders, use grid layout instead of masonry */
.gallery:has(.folder-item) {
    column-count: unset;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 300px));
    gap: 20px;
    justify-content: center;
}

@media (max-width: 1200px) {
    .gallery {
        column-count: 3;
    }
    
    .gallery:has(.folder-item) {
        grid-template-columns: repeat(auto-fit, minmax(250px, 280px));
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: static;
        order: -1;
        padding: 12px;
    }
    
    .folder-tree {
        max-height: 200px;
    }
    
    .folder-tree-item {
        padding: 6px 8px;
        font-size: 0.75rem;
        min-height: 26px;
    }
    
    .gallery {
        column-count: 2;
        column-gap: 15px;
    }
    
    .gallery:has(.folder-item) {
        grid-template-columns: repeat(auto-fit, minmax(220px, 250px));
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .gallery {
        column-count: 1;
    }
    
    .gallery:has(.folder-item) {
        grid-template-columns: 1fr;
        max-width: 300px;
        margin: 20px auto 0;
    }
}

.photo-item {
    background: #2a2a2a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    cursor: pointer;
    break-inside: avoid;
    margin-bottom: 20px;
    display: inline-block;
    width: 100%;
    border: 1px solid #3a3a3a;
}

.photo-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border-color: #666;
}

.folder-item {
    background: #2a2a2a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    cursor: pointer;
    break-inside: avoid;
    margin-bottom: 20px;
    display: inline-block;
    width: 100%;
    max-width: 300px;
    height: 300px;
    border: 1px solid #3a3a3a;
    padding: 0 0 20px 0;
    text-align: center;
    box-sizing: border-box;
    position: relative;
}

.folder-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border-color: #666;
}

.folder-preview {
    margin-bottom: 10px;
    height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.folder-preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4px;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    padding: 4px;
}

.folder-preview-slot {
    background: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.folder-preview-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 2px;
    background: #666;
}

.folder-icon {
    font-size: 3rem;
    color: #ffd700;
}

.folder-name {
    color: #e9ecef;
    font-weight: 600;
    font-size: 1rem;
    word-break: break-word;
    margin-bottom: 10px;
}

.share-button {
    background: #007bff;
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    position: absolute;
    top: 10px;
    right: 10px;
    opacity: 0;
    transform: scale(0.8);
}

.folder-item:hover .share-button {
    opacity: 1;
    transform: scale(1);
}

.share-button:hover {
    background: #0056b3;
    transform: scale(1.05);
}

.share-button:active {
    transform: scale(0.95);
}

.photo-thumbnail {
    width: 100%;
    height: auto;
    display: block;
    background: #555;
    transition: opacity 0.3s ease;
    border-radius: 8px;
}

.photo-thumbnail.loading {
    opacity: 0.7;
}


/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: transparent;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.modal-image {
    max-width: 100%;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.modal-loading {
    text-align: center;
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 40px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.modal-loading .spinner {
    border-top-color: white;
}

.modal-loading p {
    color: white;
    margin-top: 20px;
}

.modal-error {
    text-align: center;
    color: #ff6b6b;
    background: rgba(0, 0, 0, 0.7);
    padding: 40px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.modal-error .error-icon {
    color: #ff6b6b;
}

.modal-error p {
    color: white;
    margin-top: 20px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .auth-card {
        padding: 30px 20px;
    }
    
    .gallery-section {
        padding: 20px;
    }
    
    .gallery-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .gallery-actions {
        justify-content: center;
    }
    
    .modal-content {
        max-width: 98vw;
        max-height: 98vh;
    }
}
