html {
    box-sizing: border-box;
    font-size: 16px;
    scroll-behavior: smooth;
}

*,
*:before,
*:after {
    box-sizing: inherit;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    margin: 0;
    padding: 2%;
}

.container {
    max-width: 50em;
    width: 100%;
    margin: 2em auto;
    background: #ffffff;
    border-radius: 1.25em;
    box-shadow: 0 1.25em 3em rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
    color: #fff;
    padding: 2em;
    text-align: center;
}

.header h1 {
    margin: 0 0 0.25em 0;
    font-size: 2em;
}

.header p {
    margin: 0;
    opacity: 0.9;
}

.form-container {
    padding: 1em;
}

.edit-notice {
    color: #555;
    background: #f0f0f0;
    padding: 0.8em;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 1.5em;
}

.section {
    margin-bottom: 2.5em;
    padding: 1.5em;
    background: #fdfdfd;
    border-radius: 0.8em;
    border-left: 0.3em solid #4285f4;
}

.section-title {
    font-size: 1.2em;
    color: #333;
    margin: 0 0 1em 0;
    display: flex;
    align-items: center;
    gap: 0.5em;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5em;
}

.section-number {
    background: #4285f4;
    color: white;
    border-radius: 50%;
    width: 1.5em;
    height: 1.5em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    font-weight: bold;
}

.form-group {
    margin-bottom: 1.5em;
    position: relative;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5em;
}

.form-row .form-group {
    flex: 1 1 48%;
    min-width: 0;
}

.form-row .form-group.full-width {
    flex: 1 1 100%;
}

label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 600;
    color: #555;
}

/* Red asterisk for all required fields (labels and headings) */
.required,
label .required,
h4 .required {
    color: #e74c3c;
    margin-left: 2px;
}

input,
select {
    width: 100%;
    padding: 0.75em 1em;
    border: 1px solid #dcdcdc;
    border-radius: 0.5em;
    font-size: 1em;
    background: #fff;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus,
select:focus {
    border-color: #4285f4;
    outline: none;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

input:invalid:not(:placeholder-shown):not(:focus),
select:invalid:not(:focus) {
    /* border-color: #e74c3c; */
}

.error-message {
    color: #e74c3c;
    font-size: 0.875em;
    margin-top: 0.4em;
    min-height: 1em;
    display: none;
}

.char-counter {
    font-size: 0.8em;
    color: #888;
    text-align: right;
    position: absolute;
    bottom: -1.2em;
    right: 0.2em;
}

.final-submit-button-container {
    text-align: center;
    margin-top: 2em;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1em;
    align-items: center;
}

.sample-data-btn {
    padding: 0.5em 1em;
    font-size: 0.9em;
    border: 1px solid #4285f4;
    color: #4285f4;
    background: #fff;
    border-radius: 1.5em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sample-data-btn:hover {
    background: #f0f7ff;
}

.submit-btn {
    background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
    color: #fff;
    padding: 1em 3em;
    border: none;
    border-radius: 2em;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.7em 1.5em rgba(0, 0, 0, 0.2);
}

.attributes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1em 2em;
}

.attribute-category h4 {
    margin-top: 0;
    margin-bottom: 0.8em;
    color: #4285f4;
}

.checkbox-group {
    display: flex;
    align-items: center;
    margin-bottom: 0.75em;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 0.75em;
    width: 1.2em;
    height: 1.2em;
    accent-color: #34a853;
}

.checkbox-group label {
    margin-bottom: 0;
    font-weight: 500;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5em;
}

.photo-category {
    background: #f9f9f9;
    padding: 1em;
    border-radius: 8px;
}

.photo-category h4 {
    margin-top: 0;
    margin-bottom: 1em;
}

.file-input {
    display: none;
}

.file-input-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    width: 100%;
    padding: 1em;
    background: #fff;
    border: 2px dashed #dcdcdc;
    border-radius: 8px;
    cursor: pointer;
}

.existing-files-grid,
.existing-file {
    margin-bottom: 1rem;
}

.existing-file {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    display: inline-block;
}

.existing-preview-img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    display: block;
}

.existing-file-controls {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(248, 249, 250, 0.95);
    padding: 4px;
    font-size: 0.8em;
}

.replace-btn {
    background: none;
    border: 1px solid #007bff;
    color: #007bff;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
}

.remove-label {
    cursor: pointer;
    margin: 0;
}

.image-preview,
.video-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.image-preview img,
.video-preview video {
    width: 120px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.file-error {
    color: #e74c3c;
    font-size: 0.875em;
    margin-top: 0.5rem;
    min-height: 1em;
}

/* Hide "Upload More" buttons by default in edit mode; JS will show them if needed */
.edit-mode .photo-category .file-input-button {
    display: none;
}
.helper-text {
    font-size: 13px;
    color: #777;
    margin-top: 4px;
}

.how-to-get-coordinates {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.5;
}

/* Location capture block (Google Maps coordinates, link, screenshot) */
.location-capture {
    margin-top: 1.5em;
    padding: 1.25em 1.5em;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.location-intro {
    margin: 0 0 1em;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

.location-video-links {
    display: block;
    margin-top: 0.35em;
    font-size: 13px;
}

.location-video-links a {
    color: #1a73e8;
}

details.location-help {
    margin-bottom: 1.25em;
    font-size: 13px;
    color: #666;
}

details.location-help summary {
    cursor: pointer;
    color: #1a73e8;
    font-weight: 600;
    margin-bottom: 0.5em;
}

details.location-help ol {
    margin: 0.5em 0 0 1.25em;
    padding: 0;
}

.location-step {
    margin-bottom: 1.5em;
}

.location-step:last-child {
    margin-bottom: 0;
}

.location-step > label,
.location-step-label {
    display: block;
    margin-bottom: 0.35em;
    font-weight: 600;
    color: #4285f4;
}

.step-hint {
    margin: 0 0 0.65em;
    font-size: 13px;
    color: #666;
    line-height: 1.45;
}

.location-step > input[type="text"],
.location-step > input[type="url"] {
    width: 100%;
    box-sizing: border-box;
}

.coordinates-confirm {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5em;
    margin-top: 0.65em;
    padding: 0.65em 0.85em;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #555;
}

.coordinates-confirm.is-empty {
    background: #f8fafc;
    border-style: dashed;
}

.coordinates-confirm.is-filled {
    background: #f0fdf4;
    border-color: #86efac;
}

.coordinates-confirm.is-error {
    background: #fef2f2;
    border-color: #fca5a5;
}

.coordinates-status {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
}

.coordinates-confirm.is-filled .coordinates-status {
    color: #166534;
    font-weight: 600;
}

.coordinates-confirm.is-error .coordinates-status {
    color: #b91c1c;
    font-weight: 600;
}

.coordinates-confirm.is-empty .coordinates-status {
    color: #64748b;
}

.coordinates-values {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75em 1.25em;
    width: 100%;
    padding-top: 0.25em;
}

.coordinates-values.hidden {
    display: none;
}

.coordinates-values output {
    font-weight: 600;
    color: #333;
}

.coordinates-manual.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: #1a73e8;
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
}

.link-btn:hover {
    color: #34a853;
}

.location-capture-view .location-step {
    margin-bottom: 1.25em;
}

.location-view-value {
    margin: 0;
    font-size: 14px;
    color: #333;
}

.location-view-url {
    word-break: break-all;
}


/* Preview items styling */
.preview-item {
    position: relative;
    display: inline-block;
    margin: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    background: white;
}

.media-container {
    width: 100px;
    height: 100px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-container img,
.media-container video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.remove-preview-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ff4444;
    color: white;
    border: none;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 10;
}

.remove-preview-btn:hover {
    background: #cc0000;
}

/* Validation styling */
.invalid {
    border-color: #ff4444 !important;
}

.error-message {
    color: #ff4444;
    font-size: 0.85em;
    margin-top: 5px;
    display: none;
}

.char-counter {
    font-size: 0.8em;
    color: #666;
    text-align: right;
    margin-top: 2px;
}

.char-counter.near-limit {
    color: #ff9800;
}

.char-counter.over-limit {
    color: #ff4444;
    font-weight: bold;
}

/* --- Mobile-friendly (forms + location block) --- */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }

    .container {
        margin: 0.75em auto;
        border-radius: 0.75em;
    }

    .header {
        padding: 1.25em 1em;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .header p {
        font-size: 0.95em;
    }

    .form-container {
        padding: 0.75em;
    }

    .section {
        padding: 1em;
        margin-bottom: 1.5em;
    }

    .section-title {
        font-size: 1.05em;
        flex-wrap: wrap;
    }

    .form-row {
        gap: 0;
    }

    .form-row .form-group {
        flex: 1 1 100%;
    }

    /* Prevent iOS zoom on input focus */
    input,
    select,
    textarea {
        font-size: 16px;
    }

    .submit-btn {
        width: 100%;
        max-width: 100%;
        padding: 0.9em 1.5em;
        font-size: 1.05em;
    }

    .sample-data-btn {
        width: 100%;
    }

    .final-submit-button-container {
        flex-direction: column;
        gap: 0.75em;
    }

    .attributes-grid,
    .photo-grid {
        grid-template-columns: 1fr;
    }

    .location-capture {
        margin-top: 1em;
        padding: 1em;
    }

    .location-intro {
        font-size: 13px;
    }

    .location-video-links {
        margin-top: 0.5em;
        line-height: 1.6;
    }

    .location-step > label,
    .location-step-label {
        font-size: 0.95em;
        line-height: 1.4;
    }

    .location-step > input[type="text"],
    .location-step > input[type="url"] {
        font-size: 16px;
        padding: 0.85em 0.75em;
    }

    #coordinatesPaste {
        word-break: break-word;
    }

    .coordinates-confirm {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5em;
        padding: 0.65em 0.75em;
    }

    .coordinates-values {
        flex-direction: column;
        gap: 0.35em;
    }

    .coordinates-values span {
        width: 100%;
        word-break: break-all;
    }

    .coordinates-values output {
        display: inline;
        max-width: 100%;
        word-break: break-all;
    }

    .link-btn {
        min-height: 44px;
        padding: 0.5em 0;
        font-size: 14px;
        text-align: left;
    }

    .file-input-button {
        min-height: 48px;
        padding: 0.85em 1em;
        font-size: 1em;
    }

    .replace-btn {
        min-height: 36px;
        padding: 0.35em 0.75em;
    }

    .location-view-url {
        font-size: 12px;
    }

    .existing-preview-img {
        width: 100%;
        max-width: 280px;
        height: auto;
        aspect-ratio: 4 / 3;
    }

    .image-preview img,
    .video-preview video {
        width: 100%;
        max-width: 160px;
        height: auto;
    }
}

@media (max-width: 380px) {
    body {
        padding: 0.25rem;
    }

    .header h1 {
        font-size: 1.35em;
    }

    .location-capture {
        padding: 0.85em;
    }

    details.location-help {
        font-size: 12px;
    }

    details.location-help summary {
        padding: 0.5em 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}