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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #fafafa;
    color: #333;
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Login Section */
#login-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: white;
    padding: 3rem;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    text-align: center;
    color: #000;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 2px;
    font-size: 1rem;
    background: white;
}

.password-row{ display:flex; gap:.5rem; align-items:center }
.password-row input{ flex:1 }

.form-group input:focus {
    outline: none;
    border-color: #000;
}

/* App Section */
#app-section {
    display: none;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #000;
}

.header .user-info {
    font-size: 0.9rem;
    color: #666;
}

/* Controls */
.controls {
    margin-bottom: 2rem;
}

.control-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-input, .filter-select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 2px;
    font-size: 0.9rem;
    background: white;
}

.search-input {
    flex: 1;
    min-width: 200px;
}

.bulk-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 2px;
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover:not(:disabled) {
    background: #f5f5f5;
}

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

.btn-primary {
    background: #000;
    color: white;
    border-color: #000;
}

.btn-primary:hover:not(:disabled) {
    background: #333;
}

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

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Upload */
.upload-area {
    border: 2px dashed #ddd;
    border-radius: 4px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    margin-bottom: 2rem;
    transition: border-color 0.2s;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #000;
}

.upload-area h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: #666;
    font-size: 0.9rem;
}

.progress-bar {
    width: 100%;
    height: 2px;
    background: #eee;
    border-radius: 1px;
    overflow: hidden;
    margin-bottom: 2rem;
    display: none;
}

.progress-fill {
    height: 100%;
    background: #000;
    transition: width 0.3s;
}

/* Stats */
.stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    font-size: 0.9rem;
    color: #666;
}

/* Gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.image-card {
    background: white;
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.2s;
    position: relative;
}

.image-card:hover {
    transform: translateY(-1px);
}

.image-card.selected {
    outline: 2px solid #000;
}

.image-checkbox {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
}

.image-preview-container {
    position: relative;
    width: 100%;
    height: 150px;
    overflow: hidden;
    cursor: pointer;
}

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

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}

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

.overlay-btn {
    background: white;
    border: none;
    border-radius: 4px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.overlay-btn:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

/* Private image placeholder */
.private-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    color: #6b7280;
    text-align: center;
    border-radius: 4px;
}

.private-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

.private-text {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.private-filename {
    font-size: 0.8rem;
    opacity: 0.8;
    word-break: break-all;
    padding: 0 0.5rem;
}

.image-info {
    padding: 1rem;
}

.image-name {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.image-meta {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.75rem;
}

.image-status-row {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 1rem;
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.status-badge.public {
    background: #dcfce7;
    color: #16a34a;
}

.status-badge.private {
    background: #fef2f2;
    color: #dc2626;
}

/* Improved action buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.btn-action {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap;
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-primary {
    background: #000;
    color: white;
    border-color: #000;
}

.btn-primary:hover {
    background: #333;
}

.btn-secondary {
    background: white;
    color: #333;
    border-color: #ddd;
}

.btn-secondary:hover {
    background: #f9f9f9;
}

.btn-copy {
    background: #059669;
    color: white;
    border-color: #059669;
}

.btn-copy:hover {
    background: #047857;
}

.btn-warning {
    background: #f59e0b;
    color: white;
    border-color: #f59e0b;
}

.btn-warning:hover {
    background: #d97706;
}

/* URL display improvements */
.url-display {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.url-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
    background: #fafafa;
    color: #666;
}

.copy-btn {
    padding: 0.5rem;
    background: #000;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: #333;
    transform: scale(1.05);
}

.private-notice {
    background: #fef2f2;
    color: #dc2626;
    padding: 0.75rem;
    border-radius: 4px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid #fecaca;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 2rem;
    border-top: 1px solid #eee;
}

/* 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 {
    background: white;
    margin: 2% auto;
    border-radius: 4px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    color: #666;
}

.modal-close:hover {
    color: #000;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 0;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.modal-body {
    padding: 1.5rem;
    text-align: center;
}

#modal-image {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.modal-info {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: start;
    text-align: left;
}

.modal-details {
    font-size: 0.9rem;
}

.modal-details p {
    margin: 0.5rem 0;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Status Messages */
.status {
    margin-top: 1rem;
}

.status div {
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.status .success {
    background: #f0f9f0;
    color: #16a34a;
}

.status .error {
    background: #fef2f2;
    color: #dc2626;
}

.status .info {
    background: #f0f9ff;
    color: #2563eb;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.loading {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.error {
    color: #dc2626;
    text-align: center;
    padding: 2rem;
    background: #fef2f2;
    border-radius: 4px;
    margin: 1rem 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .control-row {
        flex-direction: column;
    }

    .bulk-actions {
        justify-content: space-between;
    }

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

    .modal-content {
        width: 95%;
        margin: 5% auto;
    }

    .modal-info {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .modal-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .pagination {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .stats {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    /* Mobile improvements for new UI */
    .action-buttons {
        gap: 0.4rem;
    }

    .btn-action {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .overlay-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .private-placeholder-large {
        padding: 2rem 1rem;
    }

    .private-icon-large {
        font-size: 3rem;
    }

    .url-display {
        flex-direction: column;
    }

    .url-input {
        margin-bottom: 0.5rem;
    }
}

/* Hide elements that aren't minimal */
.upload-icon {
    display: none;
}

.category-badge {
    display: none;
}

/* Black background toggle styles */
.black-bg-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.black-bg-toggle input[type="checkbox"] {
    margin: 0;
}

/* Black background for images */
.black-background .image-preview {
    background-color: #000 !important;
    padding: 8px;
    object-fit: contain;
}

.black-background #modal-image {
    background-color: #000 !important;
    padding: 8px;
    border-radius: 8px;
}

/* Enhanced container styling for black background */
.black-background .image-preview-container {
    background-color: #000 !important;
    border-radius: 4px;
}

.black-background .modal-body {
    background-color: #f9f9f9;
}

/* Black background for private placeholders */
.black-background .private-placeholder {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%) !important;
    color: #9ca3af !important;
}

.black-background .private-icon {
    color: #6b7280 !important;
}

.black-background .private-text {
    color: #d1d5db !important;
}

.black-background .private-filename {
    color: #9ca3af !important;
}

/* Gallery-level black background */
.black-background .gallery {
    background-color: #111;
    padding: 1rem;
    border-radius: 8px;
}

.black-background .image-card {
    background-color: #222;
    border: 1px solid #333;
}

/* Modal private placeholder */
.modal-private-placeholder {
    margin-bottom: 1.5rem;
}

.private-placeholder-large {
    padding: 3rem;
    text-align: center;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 8px;
    color: #6b7280;
}

.private-icon-large {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.private-text-large {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.private-filename-large {
    font-size: 1rem;
    margin-bottom: 1rem;
    word-break: break-all;
    color: #374151;
}

.private-note {
    font-size: 0.9rem;
    opacity: 0.8;
    font-style: italic;
}

/* Revoked states */
.status-badge.revoked {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.private-placeholder.revoked {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%) !important;
    color: #dc2626 !important;
    border: 2px dashed #f87171;
}

.revoked-notice {
    background: #fef2f2;
    color: #dc2626;
    padding: 0.75rem;
    border-radius: 4px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid #fecaca;
} 