/* 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;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Navigation */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
}

.nav-link:hover {
    opacity: 0.8;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Footer */
.footer {
    background-color: #34495e;
    color: white;
    text-align: center;
    padding: 1rem 0;
    margin-top: auto;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.3s;
    background-color: #95a5a6;
    color: white;
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary {
    background-color: #3498db;
}

.btn-secondary {
    background-color: #95a5a6;
}

.btn-danger {
    background-color: #e74c3c;
}

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

.btn-block {
    display: block;
    width: 100%;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: #666;
    transition: color 0.3s;
}

.btn-icon:hover {
    color: #333;
}

.btn-icon.btn-danger:hover {
    color: #e74c3c;
}

/* Gallery Styles */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.project-info h2 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.project-stats {
    color: #666;
    font-size: 0.875rem;
}

.gallery-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.project-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-selector select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
}

/* Rating Filter Styles */
.rating-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rating-filter label {
    font-weight: 500;
    color: #666;
}

.rating-filter-stars {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.filter-star {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    user-select: none;
    font-size: 1rem;
    color: #666;
    border: 1px solid #ddd;
    background-color: white;
}

.filter-star:hover {
    background-color: #f0f0f0;
    border-color: #bbb;
}

.filter-star.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

.filter-star[data-rating="0"] {
    font-size: 0.875rem;
    font-weight: 500;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed #3498db;
    border-radius: 8px;
    padding: 3rem;
    text-align: center;
    margin-bottom: 2rem;
    background-color: #f8f9fa;
    transition: all 0.3s;
    cursor: pointer;
}

.drop-zone:hover {
    background-color: #e3f2fd;
}

.drop-zone.drag-over {
    background-color: #e3f2fd;
    border-color: #2196f3;
}

.drop-zone-content {
    pointer-events: none;
}

.upload-icon {
    color: #3498db;
    margin-bottom: 1rem;
}

/* Upload Progress */
.upload-progress {
    margin-bottom: 2rem;
}

.upload-item {
    background-color: white;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.upload-item .filename {
    font-weight: 500;
    display: block;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 4px;
    background-color: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

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

.upload-item .status {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.25rem;
    display: block;
}

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

.image-item {
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
}

.image-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.image-item:hover .image-actions-overlay {
    opacity: 1;
}

.image-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    padding: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.image-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin: 0;
}

.image-wrapper {
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s, opacity 0.3s;
}

.image-wrapper:hover img {
    transform: scale(1.05);
}

/* Lazy loading image states */
.image-wrapper img.lazy-load-img {
    opacity: 0;
    filter: blur(5px);
}

.image-wrapper img.lazy-load-img.loading {
    opacity: 0.5;
    filter: blur(3px);
}

.image-wrapper img.lazy-load-img.loaded {
    opacity: 1;
    filter: blur(0);
}

/* Placeholder background for lazy images */
.image-wrapper img[data-src] {
    background-color: #f0f0f0;
    background-image: linear-gradient(45deg, #f5f5f5 25%, transparent 25%, transparent 75%, #f5f5f5 75%, #f5f5f5),
                      linear-gradient(45deg, #f5f5f5 25%, transparent 25%, transparent 75%, #f5f5f5 75%, #f5f5f5);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
}

/* NEW Badge */
.new-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #27ae60;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Video Thumbnail Styles */
.video-thumbnail {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s, filter 0.3s;
}

/* Apply same lazy loading styles to video thumbnails */
.video-thumbnail img.lazy-load-img {
    opacity: 0;
    filter: blur(5px);
}

.video-thumbnail img.lazy-load-img.loading {
    opacity: 0.5;
    filter: blur(3px);
}

.video-thumbnail img.lazy-load-img.loaded {
    opacity: 1;
    filter: blur(0);
}

.video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.video-thumbnail:hover .video-play-overlay {
    background-color: rgba(0, 0, 0, 0.9);
}

.image-info {
    padding: 1rem;
}

.image-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* Star Rating Styles */
.star-rating {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.25rem;
}

.star {
    font-size: 1.25rem;
    color: #ddd;
    cursor: pointer;
    transition: color 0.2s;
    user-select: none;
}

.star:hover,
.star.filled {
    color: #f39c12;
}

.star-rating:hover .star {
    color: #f39c12;
}

.star-rating .star:hover ~ .star {
    color: #ddd;
}

/* Interactive Star Rating for Gallery Items */
.star-rating-interactive {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.25rem;
}

.star-rating-interactive .star {
    font-size: 1rem;
    color: #ddd;
    cursor: pointer;
    transition: color 0.2s;
    user-select: none;
}

.star-rating-interactive .star.active {
    color: #f39c12;
}

.star-rating-interactive .star:hover {
    color: #f39c12;
}

/* Action Buttons Overlay */
.image-actions-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 5;
}

.image-actions-overlay .image-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0;
}

.action-btn {
    background-color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.action-btn:hover {
    background-color: white;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.action-btn svg {
    display: block;
}

.action-btn.download-btn:hover svg {
    stroke: #3498db;
}

.action-btn.delete-btn:hover svg {
    stroke: #e74c3c;
}

/* Viewer star rating active state */
#viewer-star-rating .star.active {
    color: #f39c12;
}

.image-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0 1rem 1rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #666;
}

.empty-state p {
    margin-bottom: 0.5rem;
}

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

.modal-content {
    background-color: white;
    border-radius: 8px;
    max-width: 90vw;
    max-height: 85vh; /* Reduced to ensure rating controls are visible */
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: auto; /* Allow scrolling if content is too large */
}

.modal-content img,
.modal-content video {
    max-width: 100%;
    max-height: calc(70vh - 80px); /* Reduced from 90vh to 70vh for better visibility of controls */
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto; /* Center the image horizontally */
}

.modal-content video {
    background-color: #000;
}

.modal-small {
    max-width: 500px;
    width: 90%;
}

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

.modal-body {
    padding: 1.5rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: white;
    background-color: rgba(0,0,0,0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.modal-close:hover {
    background-color: rgba(0,0,0,0.7);
}

/* Viewer Navigation Buttons */
.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0,0,0,0.5);
    color: white;
    border: none;
    padding: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
    z-index: 10;
}

.viewer-nav:hover {
    background-color: rgba(0,0,0,0.7);
}

.viewer-nav-prev {
    left: 1rem;
}

.viewer-nav-next {
    right: 1rem;
}

.viewer-info {
    padding: 1rem;
    background-color: white;
}

.viewer-actions {
    margin-bottom: 1rem;
    text-align: center;
}

.viewer-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.viewer-rating {
    margin-top: 1rem;
    text-align: center;
}

.viewer-rating p {
    margin-bottom: 0.5rem;
    color: #666;
    font-size: 0.875rem;
}

.viewer-rating .star-rating {
    justify-content: center;
}

.viewer-rating .star {
    font-size: 1.5rem;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-box {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

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

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Admin Styles */
.admin-header {
    margin-bottom: 2rem;
}

.admin-section {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.admin-section h3 {
    margin-bottom: 1rem;
}

.active-project-info {
    padding: 1rem;
    background-color: #e3f2fd;
    border-radius: 4px;
}

.help-text {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

.project-controls {
    margin-bottom: 1rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.admin-table th {
    font-weight: 600;
    background-color: #f5f5f5;
}

.admin-table code {
    background-color: #f5f5f5;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-size: 0.875rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 3px;
    font-weight: 500;
}

.badge-success {
    background-color: #27ae60;
    color: white;
}

.badge-default {
    background-color: #95a5a6;
    color: white;
}

.server-info {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.info-item label {
    font-weight: 600;
    margin-right: 0.5rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-error {
    background-color: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

/* PIN Modal Styles */
.pin-modal-content {
    max-width: 400px;
    width: 90%;
    padding: 2rem;
    text-align: center;
}

.pin-modal-content h3 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.pin-modal-content p {
    color: #666;
    margin-bottom: 1.5rem;
}

.pin-input-container {
    margin-bottom: 1.5rem;
}

.pin-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.5rem;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 8px;
    letter-spacing: 0.5rem;
    font-weight: 600;
}

.pin-input:focus {
    outline: none;
    border-color: #3498db;
}

.pin-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.error-message {
    color: #e74c3c;
    font-size: 0.875rem;
    margin-top: 1rem;
}

/* Upload Page Styles */
.upload-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 0;
}

.upload-header {
    text-align: center;
    margin-bottom: 2rem;
}

.upload-header h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.upload-header p {
    color: #666;
}

.upload-hint {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.5rem;
}

.upload-success {
    text-align: center;
    padding: 3rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.success-icon {
    color: #27ae60;
    margin-bottom: 1rem;
}

.upload-success h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.upload-success p {
    color: #666;
    margin-bottom: 1.5rem;
}

/* Loading Indicator */
.loading-indicator {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Skeleton loading animation */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton-loader {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Performance optimization with CSS containment */
.image-gallery {
    contain: layout style;
}

.image-item {
    contain: layout style paint;
}

/* Responsive */
@media (max-width: 768px) {
    .gallery-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .gallery-controls {
        width: 100%;
        flex-direction: column;
    }
    
    .image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }
    
    .admin-table {
        font-size: 0.875rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .pin-modal-content {
        padding: 1.5rem;
    }
    
    .pin-input {
        font-size: 1.25rem;
        padding: 0.75rem;
    }
}
