/* Global styles for mobile-first design */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 0;
    margin: 0;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

nav {
    display: flex;
    justify-content: space-around;
    margin-top: 0.5rem;
}

nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

nav a:hover {
    background-color: #34495e;
}

main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.filter-container {
    background-color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.filter-container h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.filter-group {
    margin-bottom: 1rem;
}

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

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

button {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

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

.btn-primary:hover {
    background-color: #2980b9;
}

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

.btn-secondary:hover {
    background-color: #7f8c8d;
}

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

.btn-danger:hover {
    background-color: #c0392b;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

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

.image-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.image-container {
    width: 100%;
    height: 200px;
    overflow: hidden;
}

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

.image-details {
    padding: 1rem;
}

.image-meta {
    margin-bottom: 1rem;
}

.meta-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.meta-item .label {
    font-weight: 500;
    min-width: 120px;
    color: #666;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.card-actions a,
.card-actions button {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    text-decoration: none;
    font-size: 0.9rem;
}

.no-images {
    text-align: center;
    padding: 2rem;
    color: #666;
}

/* Form styles */
.form-container {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Image source options */
.image-source-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.image-option {
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.image-option:hover {
    background-color: #f8f9fa;
}

.image-option input[type="radio"] {
    margin-right: 0.5rem;
}

.image-option input[type="file"] {
    margin-top: 0.5rem;
    width: 100%;
}

/* Camera styles */
.camera-container {
    margin: 1.5rem 0;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: #f8f9fa;
}

.camera-preview {
    position: relative;
    width: 100%;
    padding-bottom: 75%; /* 4:3 Aspect Ratio */
    overflow: hidden;
    background-color: #000;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.camera-preview video,
.camera-preview canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.preview-container {
    text-align: center;
    padding: 1rem;
    background-color: #fff;
    border-radius: 4px;
}

/* Responsive adjustments for camera */
@media (max-width: 768px) {
    .camera-preview {
        padding-bottom: 133%; /* 3:4 Aspect Ratio for mobile portrait */
    }
    
    .image-source-options {
        flex-direction: column;
    }
}

.form-container h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

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

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .images-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }
    
    .image-container {
        height: 150px;
    }
    
    .meta-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .meta-item .label {
        min-width: auto;
        margin-bottom: 0.25rem;
    }
}

/* Loading state */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    font-size: 1.1rem;
    color: #666;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

/* Modal styles for fullscreen image viewing */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.9); /* Black background with opacity */
    animation: fadeIn 0.3s ease-in-out;
}

/* Modal content */
.modal-content {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 20px;
}

/* Modal image */
#modalImage {
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
    animation: zoomIn 0.3s ease-in-out;
}

/* Close button */
.close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    z-index: 1001;
}

.close:hover,
.close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* Animation for modal fade in */
@keyframes fadeIn {
    from {opacity: 0;}
    to {opacity: 1;}
}

/* Animation for image zoom in */
@keyframes zoomIn {
    from {transform: scale(0.8);}
    to {transform: scale(1);}
}

/* Make images clickable */
.image-container img {
    cursor: pointer;
    transition: transform 0.2s;
}

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