/* CSS Variables for Dynamic Theming */
:root {
    --primary-color: #667eea;
    --primary-gradient-start: #667eea;
    --primary-gradient-end: #764ba2;
}

/* Reset and Base Styles */
* {
    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, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    min-height: 100vh;
    color: #333;
    position: relative;
}

/* Fixed Background Logo */
body::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    max-width: 700px;
    height: 70vh;
    background-image: var(--background-logo-url, none);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.35;
    pointer-events: none;
    z-index: 0;
    filter: blur(0px);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Header */
header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    padding: 40px 20px;
}

.logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo {
    max-height: 200px;
    max-width: 500px;
    object-fit: contain;
    animation: fadeIn 0.5s ease-in;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
    border-radius: 15px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.tagline {
    font-size: 1.5rem;
    opacity: 0.9;
}

/* Event Input Section */
.event-input {
    background: white;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    max-width: 500px;
    margin: 0 auto;
}

.event-input h2 {
    margin-bottom: 20px;
    color: #667eea;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

input[type="text"] {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

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

button {
    padding: 15px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
}

button:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

.hint {
    color: #999;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* Gallery Section */
.gallery-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.event-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.event-info h2 {
    color: #667eea;
    font-size: 2.2rem;
}

#photoCount {
    color: #999;
    font-size: 1.3rem;
}

.refresh-btn {
    padding: 12px 24px;
    background: #667eea;
    font-size: 1.1rem;
}

/* Photo Grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.photo-item {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    background: #f5f5f5;
    aspect-ratio: 1;
}

.photo-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #f0f0f0;
    /* Ensure images load on mobile */
    -webkit-user-select: none;
    user-select: none;
}

.photo-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    padding: 20px 15px 15px;
    font-size: 1.1rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.photo-item:hover .photo-info {
    opacity: 1;
}

.photo-number {
    font-weight: 600;
    font-size: 1.2rem;
}

.photo-time {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 5px;
}

.photo-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    opacity: 1;  /* Always visible for like button */
}

/* Like button always visible */
.photo-actions .like-btn {
    opacity: 1;
    visibility: visible;
}

/* Download and delete buttons only on hover */
.photo-actions .download-btn,
.photo-actions .delete-btn {
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.photo-item:hover .photo-actions .download-btn,
.photo-item:hover .photo-actions .delete-btn {
    opacity: 1;
    visibility: visible;
}

.like-btn, .download-btn, .delete-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.like-btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

.like-btn.liked {
    background: #ff6b6b;
    color: white;
}

.like-btn:hover {
    background: #ff6b6b;
    color: white;
    transform: scale(1.05);
}

.like-count {
    font-size: 1rem;
}

.download-btn, .delete-btn {
    border-radius: 50%;
    width: 45px;
    height: 45px;
    padding: 0;
    font-size: 1.2rem;
}

.download-btn:hover {
    background: #52c41a;
    transform: scale(1.1);
}

.delete-btn:hover {
    background: #ff4d4f;
    transform: scale(1.1);
}

.admin-only {
    opacity: 0.7;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

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

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

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

.empty-state p:first-child {
    font-size: 3rem;
    margin-bottom: 10px;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    cursor: pointer;
    animation: fadeIn 0.3s;
}

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

.lightbox img {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.5);
    transition: opacity 0.3s ease;
}

.close {
    position: absolute;
    top: 30px;
    right: 40px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #667eea;
}

/* Lightbox Navigation Buttons */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 60px;
    font-weight: bold;
    cursor: pointer;
    padding: 20px 25px;
    border-radius: 10px;
    transition: all 0.3s;
    z-index: 1001;
    line-height: 1;
}

.lightbox-nav:hover {
    background: rgba(102, 126, 234, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav.prev {
    left: 30px;
}

.lightbox-nav.next {
    right: 30px;
}

/* Lightbox Counter */
.lightbox-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 18px;
    font-weight: bold;
    z-index: 1001;
}

/* Mobile Responsive Lightbox */
@media (max-width: 768px) {
    .lightbox-nav {
        font-size: 40px;
        padding: 15px 20px;
    }
    
    .lightbox-nav.prev {
        left: 10px;
    }
    
    .lightbox-nav.next {
        right: 10px;
    }
    
    .close {
        top: 10px;
        right: 15px;
        font-size: 30px;
    }
    
    .lightbox-counter {
        bottom: 15px;
        font-size: 14px;
        padding: 8px 15px;
    }
}

/* Footer */
footer {
    text-align: center;
    color: white;
    padding: 40px 20px;
    opacity: 0.9;
}

.contact-info {
    margin-top: 30px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.contact-info h3 {
    margin-bottom: 15px;
    font-size: 1.6rem;
}

.contact-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.contact-link {
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    transition: all 0.3s;
    font-size: 1.2rem;
}

.contact-link:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .event-input {
        padding: 30px 20px;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .event-info {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    /* Make all photo actions visible on mobile (no hover on touch screens) */
    .photo-actions .download-btn,
    .photo-actions .delete-btn {
        opacity: 1;
        visibility: visible;
    }
    
    /* Make photo info always visible on mobile */
    .photo-info {
        opacity: 1;
    }
    
    /* Reduce button sizes on mobile for better fit */
    .download-btn, .delete-btn {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
    
    .like-btn {
        padding: 8px 12px;
        font-size: 1rem;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* QR Scanner Styles */
.qr-scan-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
    font-weight: 600;
    width: 100%;
    max-width: 300px;
}

.qr-scan-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

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

.qr-scanner {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    animation: fadeIn 0.3s ease;
}

.qr-scanner h2 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.back-btn {
    background: #f44336;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.back-btn:hover {
    background: #da190b;
    transform: translateY(-2px);
}

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

/* Refresh button styling improvement */
.refresh-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Guest Upload Button */
.guest-upload-btn {
    background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(82, 196, 26, 0.3);
}

.guest-upload-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(82, 196, 26, 0.5);
}

/* Guest Upload Modal */
.guest-upload-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.guest-upload-modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #333;
    margin: 0 0 10px 0;
}

.modal-content > p {
    color: #666;
    margin: 0 0 30px 0;
}

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

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

.form-group input[type="text"],
.form-group input[type="file"] {
    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;
}

.form-group input[type="file"] {
    padding: 10px;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.cancel-btn,
.submit-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.cancel-btn {
    background: #f0f0f0;
    color: #666;
}

.cancel-btn:hover {
    background: #e0e0e0;
}

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

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.upload-progress {
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 25px;
    background: #f0f0f0;
    border-radius: 12px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s;
    width: 0%;
}

#photoCountHint {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #666;
}
