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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    display: flex;
    min-height: 600px;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    padding: 20px;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.sidebar-header h2 {
    font-size: 1.2em;
    color: #333;
}

#folder-tree {
    margin-top: 15px;
}

.folder-item {
    padding: 10px;
    margin: 5px 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.folder-item:hover {
    background: #e3f2fd;
    border-color: #667eea;
    transform: translateX(5px);
}

.folder-item.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.folder-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.folder-name {
    font-weight: 500;
}

.image-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85em;
}

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

.folder-actions {
    opacity: 0;
    transition: opacity 0.2s;
}

.folder-item:hover .folder-actions {
    opacity: 1;
}

.delete-folder-btn {
    background: #ff4444;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
}

.delete-folder-btn:hover {
    background: #cc0000;
}

/* Content area */
.content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

/* Search section */
.search-section {
    margin-bottom: 30px;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#search-input {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1em;
    transition: border-color 0.3s;
}

#search-input:focus {
    outline: none;
    border-color: #667eea;
}

#search-status {
    padding: 10px;
    border-radius: 8px;
    font-size: 0.95em;
}

#search-status.loading {
    background: #fff3cd;
    color: #856404;
}

#search-status.success {
    background: #d4edda;
    color: #155724;
}

/* Upload section */
.upload-section {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.current-folder {
    color: #666;
    font-size: 0.95em;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-search {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 15px 30px;
}

.btn-search:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(245, 87, 108, 0.4);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

/* Images grid */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.image-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
}

.image-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-color: #667eea;
}

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

.image-info-preview {
    padding: 15px;
}

.image-title {
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-description-preview {
    font-size: 0.85em;
    color: #666;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.no-content {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 1.1em;
}

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

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content.image-preview {
    max-width: 900px;
    padding: 20px;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 20px;
}

.modal-content input:focus {
    outline: none;
    border-color: #667eea;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2em;
    color: #999;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #333;
}

#modal-image {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 20px;
}

.image-info h3 {
    margin-bottom: 10px;
    color: #333;
}

.image-info p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .images-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .search-bar {
        flex-direction: column;
    }
    
    header h1 {
        font-size: 1.8em;
    }
}

/* Loading spinner */
.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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