/* Peak Visits – Frontend Styles */
.pv-wrap {
    font-family: inherit;
    max-width: 680px;
    margin: 1.5rem 0;
}
.pv-peak-header {
    margin-bottom: 1.25rem;
}
.pv-peak-name {
    font-size: 1.4em;
    font-weight: 600;
    margin: 0 0 4px;
}
.pv-peak-elevation,
.pv-peak-location {
    display: inline-block;
    font-size: 0.85em;
    color: #666;
    margin-right: 12px;
}
.pv-peak-elevation::before { content: "▲ "; }
.pv-peak-location::before  { content: "📍 "; }
.pv-peak-desc {
    margin: 8px 0 4px;
    color: #555;
    font-size: 0.95em;
}
.pv-visit-count {
    font-size: 0.85em;
    color: #888;
    margin: 6px 0 0;
}

/* Toggle button */
.pv-toggle-form {
    display: inline-block;
    padding: 8px 18px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    margin-bottom: 1rem;
    transition: background 0.15s;
}
.pv-toggle-form:hover { background: #135e96; }

/* Form */
.pv-form {
    background: #f8f9fa;
    border: 1px solid #dde1e4;
    border-radius: 6px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.pv-field {
    margin-bottom: 1rem;
}
.pv-field label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    font-size: 0.9em;
}
.pv-field input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    box-sizing: border-box;
}
.pv-field input[type="text"]:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34,113,177,.15);
}

/* Photo options */
.pv-photo-tabs {
    display: flex;
    gap: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
    width: fit-content;
    margin-bottom: 10px;
}
.pv-photo-tab {
    padding: 6px 16px;
    border: none;
    background: #fff;
    cursor: pointer;
    font-size: 0.875em;
    color: #555;
    transition: all 0.15s;
}
.pv-photo-tab + .pv-photo-tab { border-left: 1px solid #ccc; }
.pv-photo-tab.active { background: #2271b1; color: #fff; }

/* File upload */
.pv-file-input { display: none; }
.pv-file-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px dashed #aaa;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    font-size: 0.9em;
    transition: border-color 0.15s, background 0.15s;
}
.pv-file-label:hover { border-color: #2271b1; background: #f0f5fb; color: #2271b1; }
.pv-file-icon { font-size: 1.2em; }

/* Preview */
.pv-preview-wrap { position: relative; display: inline-block; margin-top: 8px; }
.pv-preview-img { max-width: 180px; max-height: 160px; border-radius: 4px; object-fit: cover; display: block; }
.pv-remove-photo {
    position: absolute;
    top: 4px; right: 4px;
    background: rgba(0,0,0,.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px; height: 22px;
    font-size: 12px;
    cursor: pointer;
    line-height: 1;
}

/* Camera */
.pv-camera-video {
    width: 100%;
    max-width: 320px;
    border-radius: 4px;
    display: block;
    background: #000;
}
.pv-camera-controls { margin: 8px 0; display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.pv-btn-primary, .pv-btn-secondary, .pv-btn-cancel {
    padding: 8px 18px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.15s;
}
.pv-btn-primary { background: #2271b1; color: #fff; border-color: #2271b1; }
.pv-btn-primary:hover { background: #135e96; }
.pv-btn-primary:disabled { background: #a0c0df; cursor: default; }
.pv-btn-secondary { background: #fff; color: #333; border-color: #ccc; }
.pv-btn-secondary:hover { border-color: #2271b1; color: #2271b1; }
.pv-btn-cancel { background: transparent; color: #777; border-color: transparent; }
.pv-btn-cancel:hover { color: #333; }

.pv-form-actions { display: flex; gap: 8px; align-items: center; margin-top: 1.25rem; }
.pv-field-check { display: flex; align-items: center; }
.pv-checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9em; }
.pv-checkbox-label input[type="checkbox"] { width: 16px; height: 16px; }
.pv-field-note { font-size: 0.8em; color: #888; margin: -0.5rem 0 0.5rem; }

/* Messages */
.pv-messages { margin-top: 0.75rem; font-size: 0.9em; }
.pv-messages.pv-success { color: #155724; background: #d4edda; border: 1px solid #c3e6cb; border-radius: 4px; padding: 8px 12px; }
.pv-messages.pv-error   { color: #721c24; background: #f8d7da; border: 1px solid #f5c6cb; border-radius: 4px; padding: 8px 12px; }

/* Visits list */
.pv-visits-list { margin-top: 1rem; }
.pv-no-visits { color: #888; font-style: italic; }
.pv-visit-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}
.pv-visit-card:last-child { border-bottom: none; }
.pv-visit-photo {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
}
.pv-visit-photo img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

/* No-photo icon placeholder */
.pv-no-photo-icon {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    background: #f0f0ec;
    border: 1px solid #e0e0da;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    box-sizing: border-box;
}
.pv-no-photo-icon svg {
    display: block;
    width: 44px;
    height: 44px;
}

/* Clickable photo trigger */
.pv-lightbox-trigger {
    position: relative;
    display: block;
    border: none;
    padding: 0;
    background: none;
    cursor: zoom-in;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}
.pv-lightbox-trigger img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
    transition: filter 0.2s;
}
.pv-lightbox-trigger:hover img { filter: brightness(0.75); }
.pv-photo-zoom {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.2s;
}
.pv-lightbox-trigger:hover .pv-photo-zoom { opacity: 1; }

/* ── Lightbox ───────────────────────────────────────────────────── */
.pv-noscroll,
.pv-noscroll body { overflow: hidden !important; }

.pv-lightbox {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    /* display toggled by JS between none and flex */
    align-items: center;
    justify-content: center;
    /* iOS safe areas */
    padding: env(safe-area-inset-top, 12px) env(safe-area-inset-right, 12px) env(safe-area-inset-bottom, 12px) env(safe-area-inset-left, 12px);
    box-sizing: border-box;
    /* Ensure it sits above everything including fixed WP admin bar */
    -webkit-overflow-scrolling: touch;
}
.pv-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.92);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.pv-lightbox-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: min(95vw, 900px);
    padding: 0 12px;
    animation: pvLbIn 0.18s ease;
}
@keyframes pvLbIn {
    from { opacity: 0; transform: scale(0.93); }
    to   { opacity: 1; transform: scale(1); }
}
.pv-lightbox-img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 60px;
}
.pv-lightbox-img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 78vh;
    max-height: 78dvh;
    border-radius: 6px;
    object-fit: contain;
    box-shadow: 0 4px 32px rgba(0,0,0,.5);
    -webkit-user-drag: none;
}
.pv-lightbox-spinner {
    position: absolute;
    width: 36px; height: 36px;
    border: 3px solid rgba(255,255,255,.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pvSpin 0.7s linear infinite;
    display: none;
}
.pv-lightbox-spinner.active { display: block; }
@keyframes pvSpin { to { transform: rotate(360deg); } }

.pv-lightbox-caption {
    margin-top: 12px;
    color: rgba(255,255,255,.7);
    font-size: 0.85em;
    text-align: center;
    max-width: 100%;
    padding: 0 8px;
    word-break: break-word;
}
.pv-lightbox-close {
    position: absolute;
    top: -14px;
    right: 0;
    width: 40px; height: 40px;
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.pv-lightbox-close:hover,
.pv-lightbox-close:active { background: rgba(255,255,255,.3); }
@media (max-width: 480px) {
    .pv-lightbox-inner { padding: 0 6px; }
    .pv-lightbox-close { top: -46px; right: 6px; width: 44px; height: 44px; }
    .pv-lightbox-img { max-height: 72vh; max-height: 72dvh; border-radius: 4px; }
}
.pv-visit-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.pv-visit-name { font-size: 1em; }
.pv-visit-date { font-size: 0.82em; color: #888; }
.pv-error { color: #a00; font-style: italic; }

/* New visit card animation */
.pv-visit-card.pv-new {
    animation: pvSlideIn 0.4s ease;
}
@keyframes pvSlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Load more button */
.pv-load-more-wrap {
    text-align: center;
    padding: 1rem 0 0.5rem;
}
.pv-load-more {
    padding: 9px 28px;
    font-size: 0.9em;
    font-weight: 500;
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.pv-load-more:hover {
    border-color: #2271b1;
    color: #2271b1;
}
.pv-load-more:disabled {
    color: #999;
    border-color: #ddd;
    cursor: default;
}

/* Geo check status */
.pv-geo-status {
    margin-bottom: 0.75rem;
    font-size: 0.9em;
}
.pv-geo-checking {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    color: #666;
}
.pv-geo-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ccc;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: pv-spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes pv-spin {
    to { transform: rotate(360deg); }
}
.pv-geo-too-far {
    display: block;
    padding: 0.6em 0.9em;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #6d4c00;
    font-weight: 500;
}
.pv-geo-error {
    display: block;
    padding: 0.6em 0.9em;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    color: #991b1b;
}


/* Peak photo */
.pv-peak-photo-wrap {
    margin-bottom: 1.25rem;
    text-align: left;
}
.pv-peak-photo-btn {
    display: inline-block;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    max-width: 100%;
}
.pv-peak-photo {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 1440px;
    object-fit: cover;
    border-radius: 6px;
    transition: opacity 0.2s;
}
.pv-peak-photo-btn:hover .pv-peak-photo {
    opacity: 0.88;
}
.pv-peak-photo-btn .pv-photo-zoom {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    pointer-events: none;
}
.pv-peak-photo-btn:hover .pv-photo-zoom {
    opacity: 1;
}

/* Peak list shortcode */
.pv-list-wrap {
    overflow-x: auto;
    margin: 0;
}
.pv-list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}
.pv-list-table thead tr {
    border-bottom: 2px solid #e0e0e0;
}
.pv-list-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: #444;
    white-space: nowrap;
}
.pv-list-table td {
    padding: 10px 12px;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}
.pv-list-row:last-child td {
    border-bottom: none;
}
.pv-list-row:hover td {
    background: #f9f9f9;
}
.pv-list-col-photo {
    width: 72px;
    padding: 8px 10px !important;
}
.pv-list-photo-btn {
    display: block;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    width: 60px;
    height: 60px;
}
.pv-list-thumb {
    display: block;
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    transition: opacity 0.2s;
}
.pv-list-photo-btn:hover .pv-list-thumb {
    opacity: 0.8;
}
.pv-list-photo-btn .pv-photo-zoom {
    font-size: 1.1rem;
}
.pv-list-no-photo {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 4px;
    color: #aaa;
}
.pv-list-desc {
    margin: 4px 0 0;
    font-size: 0.85em;
    color: #888;
}
.pv-list-col-visits {
    text-align: center;
    white-space: nowrap;
}
.pv-list-col-elev,
.pv-list-col-last {
    white-space: nowrap;
}
.pv-mobile-meta {
    display: none;
}

/* ── Mobile card layout ────────────────────────────────────────────────── */
@media (max-width: 600px) {

    .pv-list-wrap {
        overflow-x: visible;
    }

    /* Hide the table header */
    .pv-list-table thead {
        display: none;
    }

    /* Reset table elements to block */
    .pv-list-table,
    .pv-list-table tbody {
        display: block;
        width: 100%;
    }

    /* Each row becomes a card */
    .pv-list-row {
        display: grid !important;
        grid-template-columns: 80px 1fr;
        grid-template-rows: auto auto;
        column-gap: 12px;
        row-gap: 0;
        border: 1px solid #e8e8e8;
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 12px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
        background: #fff;
    }

    /* All cells reset */
    .pv-list-row td {
        display: block;
        border-bottom: none;
        padding: 0;
        width: auto !important;
        text-align: left !important;
    }

    /* Photo — grid row 1-2, col 1 */
    .pv-list-col-photo {
        grid-column: 1;
        grid-row: 1 / 3;
        align-self: start;
    }
    .pv-list-photo-btn,
    .pv-list-no-photo {
        width: 80px;
        height: 80px;
        border-radius: 6px;
    }
    .pv-list-thumb {
        width: 80px;
        height: 80px;
        border-radius: 6px;
    }

    /* Name — grid row 1, col 2 */
    .pv-list-col-name {
        grid-column: 2;
        grid-row: 1;
        align-self: center;
        min-width: 0;
    }
    .pv-list-col-name strong {
        font-size: 1.05em;
        display: block;
    }

    /* Metadata strip — grid row 2, col 2 */
    .pv-list-col-elev {
        grid-column: 2;
        grid-row: 2;
        align-self: start;
        padding-top: 6px !important;
        margin-top: 6px;
        border-top: 1px solid #f0f0f0;
        font-size: 0.82em;
        color: #666;
        display: flex;
        flex-wrap: wrap;
        column-gap: 14px;
        row-gap: 2px;
    }

    /* Remaining metadata cells: hidden on mobile, info shown in elev cell */
    .pv-list-col-loc,
    .pv-list-col-visits,
    .pv-list-col-last {
        display: none !important;
    }

    /* Mobile metadata spans inside elevation cell */
    .pv-mobile-meta {
        display: flex;
        flex-wrap: wrap;
        column-gap: 12px;
        row-gap: 2px;
        margin-top: 4px;
        font-size: 0.95em;
    }
    .pv-mm-loc,
    .pv-mm-visits,
    .pv-mm-last {
        display: inline-block;
        white-space: nowrap;
    }
}
}

/* Linked peak list rows */
.pv-list-row-linked:hover td {
    background: #eef4fb;
}
@media (max-width: 600px) {
    .pv-list-row-linked:hover {
        background: #eef4fb;
    }
    .pv-list-row-linked:hover td {
        background: none;
    }
}
.pv-list-row-linked .pv-list-photo-btn {
    position: relative;
    z-index: 1;
}
