/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header & Navigation */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Keep Leaflet controls below header */
.leaflet-top,
.leaflet-bottom,
.leaflet-control-container,
.leaflet-control-zoom,
.leaflet-control-attribution,
.leaflet-control {
    z-index: 500 !important;
}

.map-container {
    z-index: 1;
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

nav h1 {
    font-size: 1.25rem;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.nav-links a:hover {
    background: var(--background);
    color: var(--text-primary);
}

.nav-links a.active {
    background: var(--primary-color);
    color: white;
}

/* Main Content */
main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

/* Form Section */
.form-section {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 700px;
    margin: 0 auto 2rem;
}

.form-section h2 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.intro {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.required {
    color: var(--error-color);
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="time"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.help-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* Photo Preview */
.photo-preview,
.media-preview {
    margin-top: 0.5rem;
}

.photo-preview img,
.media-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius);
    object-fit: cover;
}

.media-preview video {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius);
}

.upload-btn {
    width: 100%;
    padding: 1rem;
    border: 2px dashed var(--border-color);
    background: var(--background);
    cursor: pointer;
    text-align: center;
    display: block;
}

.upload-btn:hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.upload-btn.has-photo {
    border-style: solid;
    border-color: var(--success-color);
}

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

.photo-buttons .upload-btn {
    flex: 1;
    min-width: 140px;
}

.upload-progress {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Map Container */
.map-container {
    height: 300px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.location-display {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--background);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.location-display.has-location {
    color: var(--success-color);
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-text {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
}

.btn-text:hover {
    color: var(--text-primary);
}

.btn-danger {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: var(--error-color);
    color: white;
    display: none; /* Hidden by default, shown via JS in admin mode */
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-danger:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
}

.form-actions {
    margin-top: 2rem;
}

/* Form Status */
.form-status {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--radius);
    display: none;
}

.form-status.success {
    display: block;
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.form-status.error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.form-status.loading {
    display: block;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #7dd3fc;
}

/* Info Section */
.info-section {
    max-width: 700px;
    margin: 0 auto;
}

.info-box {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.info-box h4 {
    margin-bottom: 0.5rem;
}

.email-address {
    font-size: 1.1rem;
    margin: 0.5rem 0;
}

/* Gallery Page */
.gallery-main {
    max-width: 1400px;
}

.filters-section {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.filters-section h2 {
    margin-bottom: 1rem;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.875rem;
    margin-bottom: 0;
}

.filter-group input {
    width: auto;
}

/* Gallery Content */
.gallery-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.map-panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.gallery-map {
    height: 600px;
    border: none;
    border-radius: 0;
}

.list-panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    max-height: 600px;
}

.list-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sort-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-options label {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.sort-options select {
    width: auto;
    padding: 0.5rem;
}

.reports-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.spinner-large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay p {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-top: -10px;
    margin-left: -10px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Report Card */
.report-card {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.report-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.report-card.active {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.report-thumbnail {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    position: relative;
}

.report-thumbnail img,
.report-thumbnail video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: calc(var(--radius) - 4px);
}

.video-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 0.6rem;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
}

.report-info {
    flex: 1;
    min-width: 0;
}

.report-date {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.report-time {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.report-location {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.report-description {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* No Reports */
.no-reports {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
}

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

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 900px;
    width: 100%;
    margin: 2rem auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--background);
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--border-color);
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.modal-image {
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius) 0 0 var(--radius);
    overflow: hidden;
}

.modal-image img {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
}

.modal-details {
    padding: 2rem;
}

.modal-details h3 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.detail-row {
    margin-bottom: 1rem;
}

.detail-row strong {
    color: var(--text-secondary);
    font-size: 0.875rem;
    display: block;
    margin-bottom: 0.25rem;
}

.modal-actions {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Leaflet Popup Customization */
.leaflet-popup-content {
    margin: 0.5rem;
}

.map-popup {
    min-width: 200px;
}

.map-popup img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.map-popup h4 {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.map-popup p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0.25rem 0;
}

.map-popup .view-details {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--primary-color);
    text-decoration: none;
}

.map-popup .view-details:hover {
    text-decoration: underline;
}

/* Footer */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 900px) {
    .gallery-content {
        grid-template-columns: 1fr;
    }

    .gallery-map {
        height: 400px;
    }

    .list-panel {
        max-height: none;
    }

    .modal-body {
        grid-template-columns: 1fr;
    }

    .modal-image {
        border-radius: var(--radius) var(--radius) 0 0;
    }
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    nav {
        flex-direction: column;
        text-align: center;
    }

    .filters {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group input {
        width: 100%;
    }

    .report-card {
        flex-direction: column;
    }

    .report-thumbnail {
        width: 100%;
        height: 150px;
    }
}
