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

:root {
    --bg-primary: #0f0f17;
    --bg-secondary: #1a1a28;
    --bg-tertiary: #252538;
    --bg-card: #1e1e2e;
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b8;
    --text-muted: #6c6c80;
    --accent: #7c3aed;
    --accent-hover: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    --border: #2a2a3e;
    --input-bg: #12121a;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1920px;
    margin: 0 auto;
    gap: 16px;
    flex-wrap: wrap;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

header h1 {
    font-size: 1.25rem;
    color: var(--accent);
    font-weight: 700;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.server-config {
    display: flex;
    align-items: center;
    gap: 8px;
}

.server-config input {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    width: 320px;
}

.server-config input:focus {
    outline: none;
    border-color: var(--accent);
}

#btnConnect {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
}

#btnConnect:hover {
    background: var(--accent-hover);
}

.status-badge {
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.status-badge.connected {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status-badge.disconnected {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

/* Auth Bar */
.auth-bar {
    background: var(--bg-tertiary);
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
}

.auth-bar-content {
    max-width: 1920px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.auth-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.auth-bar input {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    width: 180px;
}

.btn-login {
    background: var(--success);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 5px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.78rem;
}

.auth-status {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.auth-status.authenticated {
    color: var(--success);
}

/* Main Layout */
main {
    display: flex;
    max-width: 1920px;
    margin: 0 auto;
    min-height: calc(100vh - 100px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 16px;
    overflow-y: auto;
    max-height: calc(100vh - 100px);
}

.sidebar-section {
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.section-header h3 {
    flex: 1;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 26px;
    height: 26px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Folder Tree */
.folder-tree {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.85rem;
}

.folder-item:hover {
    background: var(--bg-tertiary);
}

.folder-item.active {
    background: var(--accent);
    color: white;
}

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

.folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-count {
    font-size: 0.7rem;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 10px;
}

.folder-item.active .folder-count {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Content Area */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 20px;
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.breadcrumb-item {
    color: var(--text-secondary);
    cursor: pointer;
}

.breadcrumb-item:hover {
    color: var(--accent);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 600;
}

.breadcrumb-separator {
    color: var(--text-muted);
}

.search-box {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 600px;
}

.search-box input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 0.82rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-box button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
}

.search-box .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.view-options {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.view-options select {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 0.8rem;
}

.view-options label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* Photo Grid */
.photo-grid-container {
    flex: 1;
    position: relative;
    overflow-y: auto;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding-bottom: 20px;
}

.photo-card {
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    background: var(--bg-card);
}

.photo-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.photo-thumb {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    position: relative;
}

.photo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    padding: 30px 12px 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.photo-card:hover .photo-overlay {
    opacity: 1;
}

.photo-name {
    font-size: 0.78rem;
    color: white;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 23, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 10;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.pagination button {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.82rem;
}

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

.pagination button:not(:disabled):hover {
    border-color: var(--accent);
}

#pageInfo {
    font-size: 0.85rem;
}

.total-info {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow);
}

.modal-content.small {
    width: 420px;
    padding: 24px;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.4rem;
    z-index: 10;
}

.modal-close:hover {
    background: var(--error);
}

.modal-body {
    display: flex;
    max-height: 90vh;
}

.modal-image-container {
    flex: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 500px;
    max-width: 70vw;
}

.modal-image-container img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.modal-image-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
}

.modal-image-nav button {
    background: rgba(0,0,0,0.5);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
}

.modal-image-nav button:hover {
    background: var(--accent);
}

.modal-info {
    width: 320px;
    padding: 24px;
    overflow-y: auto;
    background: var(--bg-secondary);
}

.modal-info h2 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    word-break: break-word;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.info-item {
    margin-bottom: 12px;
}

.info-item.full-width {
    grid-column: 1 / -1;
}

.info-item label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.info-item span, .info-item p {
    font-size: 0.88rem;
    color: var(--text-primary);
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.modal-actions button {
    padding: 10px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border) !important;
}

.btn-danger {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error) !important;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.88rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    position: relative;
    margin-bottom: 16px;
    transition: all 0.2s;
}

.upload-area:hover {
    border-color: var(--accent);
}

.upload-area input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-area p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.upload-file-list {
    margin-top: 12px;
    text-align: left;
}

.upload-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.upload-file-item .file-size {
    color: var(--text-muted);
    margin-left: auto;
}

.upload-file-item button {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 1rem;
}

.upload-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0;
    transition: width 0.3s;
}

#progressText {
    font-size: 0.82rem;
    color: var(--text-secondary);
    min-width: 60px;
}

/* FAB */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 50;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(124, 58, 237, 0.5);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
    color: white;
}

.toast.error {
    background: var(--error);
    color: white;
}

.toast.info {
    background: var(--info);
    color: white;
}

.toast.warning {
    background: var(--warning);
    color: white;
}

/* Utilities */
.muted-text {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.center-text {
    text-align: center;
    padding: 40px;
}

/* Responsive */
@media (max-width: 1024px) {
    .modal-body {
        flex-direction: column;
    }

    .modal-image-container {
        min-width: unset;
        max-width: unset;
        max-height: 60vh;
    }

    .modal-info {
        width: 100%;
    }
}

@media (max-width: 768px) {
    main {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: unset;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        max-width: none;
        flex-wrap: wrap;
    }

    .search-box input {
        min-width: 0;
    }

    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
    }

    .header-left {
        flex-wrap: wrap;
    }

    .server-config {
        flex-wrap: wrap;
    }

    .server-config input {
        width: 100%;
        min-width: 0;
    }

    .auth-bar-content {
        flex-wrap: wrap;
    }

    .auth-bar input {
        width: 100%;
        min-width: 0;
    }

    .modal-content.small {
        width: calc(100vw - 24px);
        max-width: 420px;
    }

    .modal-image-container {
        min-width: unset;
        max-width: unset;
    }

    .modal-body {
        flex-direction: column;
    }

    .modal-info {
        width: 100%;
    }

    .view-options {
        flex-wrap: wrap;
    }

    .content {
        padding: 12px;
    }
}
