/* The add / view pin panel: a centered side card on desktop, a bottom sheet
   below 768px. The edit boxes inside it are styled in forms.css. */

.add-panel-backdrop {
    position: fixed;
    inset: 0;
    background: #0f14126b;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
    z-index: 10;
}

.add-panel-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.add-panel {
    position: fixed;
    top: 50%;
    right: 32px;
    transform: translateY(-50%) translate(16px);
    width: min(380px, 100vw - 48px);
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    z-index: 11;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    display: flex;
    flex-direction: column;
}

.add-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) translate(0);
}

@media (max-width: 767.98px) {
    .add-panel {
        inset: auto 0 0;
        transform: translateY(100%);
        width: auto;
        max-height: 88vh;
        border-radius: 20px 20px 0 0;
    }

    .add-panel.is-open {
        transform: translateY(0);
    }
}

.add-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 20px 4px;
}

.add-panel-head h2,
.add-panel-head .h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--surface-2);
    border-radius: 8px;
    color: var(--ink-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.icon-btn:hover {
    color: var(--ink);
}

.icon-btn svg {
    width: 15px;
    height: 15px;
}

/* ---------- Fields ---------- */

.add-panel-body {
    padding: 14px 20px 4px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.field-label {
    margin: 0 0 8px;
    font-size: .78rem;
    font-weight: 700;
    color: var(--ink-dim);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.field-hint {
    margin: 10px 0 0;
    font-size: .8rem;
    color: var(--ink-dim);
}

.field-hint a {
    color: var(--teal-ink);
    font-weight: 600;
}

.field-hint.is-error {
    color: #8a2b2e;
}

.address-search-row {
    display: flex;
    gap: 8px;
}

.address-search-row .form-control {
    flex: 1 1 auto;
    min-width: 0;
}

.address-search-row .btn {
    flex: 0 0 auto;
    padding: 10px 16px;
}

.add-panel.is-view-mode .address-search-row #addressSearchBtn,
.add-panel.is-view-mode #addressSearchStatus {
    display: none;
}

.map-canvas--mini {
    position: relative;
    height: 150px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    cursor: crosshair;
    margin-bottom: 8px;
}

.mini-hint {
    font-size: .72rem;
    color: var(--ink-dim);
}

/* ---------- Add steps ---------- */

/* Adding a pin shows one step at a time. View mode sets neither class, so
   it shows the fields of both steps, minus the step-only bits below. */
.add-panel.is-step-1 .add-step--2,
.add-panel.is-step-2 .add-step--1,
.add-panel.is-view-mode .add-step-nav,
.add-panel.is-view-mode .add-summary {
    display: none;
}

/* Second step: what was picked in the first one, on a single row. */
.add-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.add-summary .field-label {
    margin: 0;
    flex: 0 0 auto;
}

.add-summary-address {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    font-size: .88rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.add-summary .cat-icon {
    flex: 0 0 auto;
}

/* ---------- View mode ---------- */

/* The fields are laid out in add-step order; viewing keeps the name and
   description first, then category, address and the rest. */
.add-panel.is-view-mode #categoryField { order: 1; }
.add-panel.is-view-mode #addressField { order: 2; }
.add-panel.is-view-mode #picturesField { order: 3; }
.add-panel.is-view-mode #viewRatingField { order: 4; }
.add-panel.is-view-mode #viewCommentField { order: 5; }
.add-panel.is-view-mode #verifyEmailHint { order: 6; }

/* The pin is already shown on the main map, so the mini map is only for
   picking a location while adding. */
.add-panel.is-view-mode #miniMapField {
    display: none;
}

/* Viewing a pin reuses the form with its fields read-only. They keep the
   same outline as the editable boxes (--field-border, from forms.css) on a
   tinted fill, so each value sits in a clearly bounded box without looking
   like something to type into. */
.add-panel.is-view-mode .form-control:not(#userComment),
#issuemap-app .add-panel.is-view-mode .form-select {
    border-color: var(--field-border);
    background-color: var(--surface-2);
    color: var(--ink);
    opacity: 1;
    cursor: default;
}

.add-panel.is-view-mode .form-control:not(#userComment):focus {
    box-shadow: none;
    border-color: var(--field-border);
}

/* Nothing to choose while viewing, so drop the dropdown arrow. */
#issuemap-app .add-panel.is-view-mode .form-select {
    padding-right: 0.875rem;
    background-image: none;
}

.add-panel.is-view-mode .add-panel.is-view-mode .image-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

/* ---------- Image previews ---------- */

.image-preview {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    line-height: 16px;
    border: none;
    border-radius: 50%;
    background: #0f1412a6;
    color: #fff;
    font-size: .85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview-remove:hover {
    background: #0f1412d9;
}

.radio-row {
    display: flex;
    gap: 18px;
}

.radio {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    margin: 0;
}

.radio input {
    accent-color: var(--teal);
    width: 16px;
    height: 16px;
}

.add-panel-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px 20px;
    margin-top: 4px;
}
