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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Sort Button */
.sort-dropdown {
    position: relative;
}

.sort-btn {
    background: white;
    color: #667eea;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.sort-icon {
    width: 20px;
    height: 20px;
}

.sort-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    min-width: 220px;
    z-index: 100;
}

.sort-menu.active {
    display: block;
}

.sort-option {
    display: block;
    width: 100%;
    padding: 14px 18px;
    border: none;
    background: white;
    color: #333;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.sort-option:last-child {
    border-bottom: none;
}

.sort-option:hover {
    background: #f8f9ff;
}

.sort-option.active {
    background: #667eea;
    color: white;
    font-weight: 600;
}

/* Mobile-specific: Remove padding for native app feel */
@media (max-width: 768px) {
    body {
        padding: 0;
        background: #000;
    }

    .container {
        margin: 0;
        max-width: 100%;
    }

    header {
        padding: 10px 15px;
        margin-bottom: 0;
        background: #000;
    }

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

    .sort-btn {
        padding: 10px 16px;
        font-size: 0.95rem;
    }

    .sort-menu {
        right: auto;
        left: 0;
    }
}

h1 {
    color: white;
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.upload-btn {
    background: white;
    color: #667eea;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Photo Grid */
.photo-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

/* Flat Grid (for time sorting) */
.flat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

/* Uploader Section (for grouped view) */
.uploader-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.uploader-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(59, 130, 246, 0.2));
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
}

.uploader-header:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(59, 130, 246, 0.3));
}

.uploader-header-text {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.collapse-icon {
    font-size: 16px;
    transition: transform 0.3s ease;
    color: #fff;
}

.uploader-section.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.uploader-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 20px;
    transition: all 0.3s ease;
}

.uploader-section.collapsed .uploader-grid {
    display: none;
}

.photo-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.photo-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.photo-card img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
}

/* Mobile: Native photo app style - no gaps, no borders */
@media (max-width: 768px) {
    .photo-grid {
        gap: 10px;
        margin-top: 0;
    }

    .flat-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;
    }

    .uploader-section {
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.03);
    }

    .uploader-header {
        padding: 12px 15px;
        background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(59, 130, 246, 0.25));
    }

    .uploader-header-text {
        font-size: 16px;
    }

    .uploader-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;
        padding: 0;
    }

    .photo-card {
        border-radius: 0;
        box-shadow: none;
    }

    .photo-card:hover {
        transform: none;
        box-shadow: none;
    }

    .photo-card img {
        height: 33vw;
    }
}

.photo-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.4) 70%, transparent 100%);
    pointer-events: none;
}

.uploader-name {
    font-size: 0.9rem;
    color: white;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.uploader-name::before {
    content: "📷 ";
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    opacity: 0.8;
}

.empty-state h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #333;
}

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

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

/* Drop Zone */
.drop-zone {
    border: 3px dashed #e0e0e0;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.drop-zone.drag-over {
    border-color: #667eea;
    background-color: #f0f4ff;
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.upload-icon {
    width: 60px;
    height: 60px;
    color: #667eea;
}

.drop-zone p {
    color: #666;
    font-size: 1rem;
}

.or-text {
    color: #999;
    font-size: 0.9rem;
}

.file-label {
    background: #667eea;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: 500;
}

.file-label:hover {
    background: #5568d3;
}

#fileInput {
    display: none;
}

.preview {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.preview-item {
    position: relative;
}

.preview img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.preview-item .remove-preview {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.preview-item .remove-preview:hover {
    background: #cc0000;
}

.file-count {
    margin-top: 10px;
    color: #667eea;
    font-weight: 500;
    text-align: center;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

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

.upload-status {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
}

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

.upload-status.error {
    background: #f8d7da;
    color: #721c24;
}

/* Fullscreen Viewer */
.fullscreen-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    -webkit-user-select: none;
    user-select: none;
}

.fullscreen-viewer.active {
    display: flex;
}

/* Mobile: Pure black background for native feel */
@media (max-width: 768px) {
    .fullscreen-viewer {
        background: #000;
    }
}

.viewer-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y pinch-zoom;
}

.image-slider {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
    will-change: transform;
}

.image-slider.no-transition {
    transition: none;
}

.image-slider.fast-transition {
    transition: transform 0.25s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.image-slide {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 80px 100px;
}

.image-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    user-select: none;
    pointer-events: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}

#fullscreenImage {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    user-select: none;
}

/* Mobile: Larger fullscreen images, fill screen, no borders */
@media (max-width: 768px) {
    .image-slide {
        padding: 0;
    }

    .image-slide img {
        max-width: 100%;
        max-height: 100%;
        width: 100%;
        height: 100%;
        object-fit: contain;
        border-radius: 0;
    }

    #fullscreenImage {
        max-width: 100%;
        max-height: 100%;
        width: 100%;
        height: 100%;
        object-fit: contain;
        border-radius: 0;
    }
}

.fullscreen-info {
    margin-top: 20px;
    text-align: center;
}

.fullscreen-uploader {
    color: white;
    font-size: 1.2rem;
    font-weight: 500;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.fullscreen-uploader::before {
    content: "📷 ";
}

/* Delete button in fullscreen viewer - hidden by default */
.delete-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 68, 68, 0.9);
    color: white;
    border: none;
    font-size: 28px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1001;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: none; /* Hidden by default */
}

/* Show delete button only in admin mode */
body.admin-mode .delete-btn {
    display: flex;
}

.delete-btn:hover {
    background: rgba(204, 0, 0, 1);
    transform: scale(1.1);
}

.delete-btn:active {
    transform: scale(0.95);
}

/* Delete button on thumbnails - hidden by default */
.delete-thumbnail-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 68, 68, 0.95);
    color: white;
    border: none;
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Show thumbnail delete buttons only in admin mode */
body.admin-mode .delete-thumbnail-btn {
    display: flex;
}

.delete-thumbnail-btn:hover {
    background: rgba(204, 0, 0, 1);
    transform: scale(1.15);
}

.delete-thumbnail-btn:active {
    transform: scale(0.9);
}

/* Mobile: smaller delete button */
@media (max-width: 768px) {
    .delete-btn {
        top: 10px;
        left: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
        background: rgba(0, 0, 0, 0.6);
    }

    .delete-btn:hover {
        background: rgba(255, 68, 68, 0.9);
    }

    .delete-thumbnail-btn {
        top: 4px;
        right: 4px;
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
}

.close-viewer {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    font-size: 40px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s;
    z-index: 2001;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close-viewer:hover {
    background: rgba(255, 255, 255, 0.3);
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    font-size: 60px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s;
    z-index: 2001;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.prev-btn {
    left: 20px;
}

.next-btn {
    right: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 {
        font-size: 1.5rem;
        color: white;
    }

    .modal-content {
        padding: 20px;
    }

    .drop-zone {
        padding: 20px;
    }

    .upload-icon {
        width: 40px;
        height: 40px;
    }

    .nav-btn {
        font-size: 40px;
        width: 50px;
        height: 50px;
        opacity: 0.8;
        background: rgba(0, 0, 0, 0.3);
    }

    .prev-btn {
        left: 5px;
    }

    .next-btn {
        right: 5px;
    }

    .close-viewer {
        top: 5px;
        right: 5px;
        font-size: 30px;
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.3);
    }

    /* Floating Action Button (FAB) for Upload - Extended FAB with text */
    .upload-btn {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: auto;
        height: 56px;
        border-radius: 28px;
        padding: 0 20px 0 16px;
        font-size: 0.95rem;
        font-weight: 600;
        z-index: 999;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        white-space: nowrap;
    }

    .upload-btn::before {
        content: '+';
        font-size: 28px;
        font-weight: 300;
        line-height: 1;
    }

    .upload-btn:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    }

    .upload-btn:active {
        transform: scale(0.95);
    }
}

@media (max-width: 480px) {
    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

