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

html, body {
    width: 100%;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
}

/* Pages */
.page {
    width: 100%;
    height: 100%;
    display: none;
}

.page.active {
    display: flex;
}

/* Homepage */
#homepage {
    background: #ADD8E6;
    justify-content: center;
    align-items: center;
}

.home-content {
    text-align: center;
}

.home-header {
    margin-bottom: 3rem;
}

.home-header h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
    font-family: 'Times New Roman', Times, serif;
    color: black;
}

.home-header p {
    font-size: 1.2rem;
    opacity: 0.8;
    color: black;
}

.enter-btn {
    padding: 14px 40px;
    font-size: 1.1rem;
    background: black;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.enter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.enter-btn:active {
    transform: translateY(0);
}

/* Browser Page */
#browserPage {
    display: flex;
}

.container {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 0;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.back-home-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-bottom: 10px;
    transition: background 0.2s;
    font-weight: 500;
}

.back-home-btn:hover {
    background: #764ba2;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.nav-tree {
    display: flex;
    flex-direction: column;
}

.nav-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
    background: #3498db;
    border-left-color: #e74c3c;
    font-weight: 600;
}

.nav-item-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.view {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    background: #fff;
}

.view.active {
    display: flex;
}

/* Gallery View */
#galleryView {
    background: #fafafa;
}

.gallery-header {
    padding: 20px;
    background: white;
    border-bottom: 1px solid #eee;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.gallery-header h2 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin: 0;
}

.gallery {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    align-content: start;
}

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #999;
    font-size: 1.1rem;
}

.image-card {
    aspect-ratio: 1;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.image-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
    border-color: #3498db;
}

.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.folder-item {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    text-align: center;
}

.folder-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 24px rgba(102, 126, 234, 0.5);
}

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

.folder-name {
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    word-wrap: break-word;
}

/* Image Viewer */
#imageView {
    background: #1a1a1a;
}

.image-controls {
    padding: 16px 20px;
    background: #2c3e50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.control-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.control-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn.close {
    background: #e74c3c;
}

.control-btn.close:hover {
    background: #c0392b;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

#zoomLevel {
    color: white;
    min-width: 50px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #1a1a1a;
}

.image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
}

.image-wrapper.dragging {
    cursor: grabbing;
}

#viewerImage {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    user-select: none;
    transition: transform 0.1s;
}

/* Scrollbars */
.sidebar-nav::-webkit-scrollbar,
.gallery::-webkit-scrollbar {
    width: 8px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.gallery::-webkit-scrollbar-track {
    background: transparent;
}

.gallery::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

.gallery::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* Password Modal */
#passwordModal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#passwordModal.hidden {
    display: none;
}

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

.password-modal-content h2 {
    font-size: 1.8rem;
    color: black;
    margin-bottom: 10px;
    font-family: 'Times New Roman', Times, serif;
    font-weight: 700;
}

.password-modal-content p {
    color: #666;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.password-input {
    width: 100%;
    padding: 12px;
    font-size: 1.2rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    text-align: center;
    letter-spacing: 4px;
    margin-bottom: 15px;
    transition: border-color 0.2s;
}

.password-input:focus {
    outline: none;
    border-color: black;
}

.password-submit {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    background: black;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.password-submit:hover {
    background: #333;
}

.password-error {
    color: #e74c3c;
    font-size: 0.9rem;
    margin-top: 10px;
    display: none;
}

.password-error.show {
    display: block;
}

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

    .sidebar {
        width: 100%;
        max-height: 150px;
        flex-direction: row;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    .sidebar-nav {
        flex: 1;
        overflow-x: auto;
        padding: 0;
    }

    .nav-tree {
        flex-direction: row;
    }

    .nav-item {
        padding: 12px 12px;
        white-space: nowrap;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}
