
/* No unscoped `*`/`body` reset here - this file is now loaded site-wide
   (layout.html) so the #109 overlay gets this same styling wherever it's
   opened from, and an unscoped body background here would have fought
   with styles.css's classic-theme body background depending on link
   order. Global resets belong in styles.css, not a page-specific file.

   Everything below is scoped under .photo-detail-panel (the wrapper
   _photo_detail_panel.html renders) rather than left bare - several of
   these class/selector names (.action-buttons, button.btn, .btn-secondary,
   .assign-form, form button[type="submit"], ...) are generic enough that
   other pages (admin.html, races.html, login.html, ...) already use them
   for their own, differently-styled buttons; loading this file site-wide
   without scoping would have restyled those too. */

.photo-detail-container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.photo-detail-card {
    background-color: white;
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Image Display */
.photo-detail-panel .photo-frame {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin-bottom: 2rem;
}

.photo-detail-panel img.img-fluid {
    max-height: 600px;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    object-fit: contain;
    width: auto;
    max-width: 100%;
    display: block;
}

/* Match highlight overlay (#101) - percentage-positioned boxes drawn over
   the photo by static/js/photoDetailPanel.js, computed from the loaded
   <img>'s naturalWidth/naturalHeight so they track Body.coordinates'
   pixel space regardless of the image's rendered display size. inset:0
   matches .photo-frame being inline-block sized to the <img> itself (see
   above), so the overlay's box exactly covers the visible photo.
   pointer-events:none throughout - #101 is display-only; #102 will need
   to turn this on for the boxes it makes clickable. */
.photo-detail-panel .match-highlight-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.photo-detail-panel .match-body-box {
    position: absolute;
    box-sizing: border-box;
    border-radius: 4px;
}

.photo-detail-panel .match-body-box.is-match {
    border: 3px solid var(--success);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.photo-detail-panel .match-body-box.is-other {
    border: 2px dashed rgba(255, 255, 255, 0.6);
    opacity: 0.85;
}

.photo-detail-panel .match-face-box {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid var(--success);
    border-radius: 3px;
}

.photo-detail-panel .match-bib-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--success);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.photo-detail-panel .full-res-icon-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: white;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.photo-detail-panel .full-res-icon-btn:hover {
    background: rgba(0, 0, 0, 0.75);
    transform: scale(1.08);
}

.photo-detail-panel .full-res-icon-btn:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

.photo-detail-panel .full-res-overlay {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 0.75rem;
    z-index: 3;
}

.photo-detail-panel .full-res-overlay-box {
    position: relative;
    background: white;
    color: #111827;
    max-width: 320px;
    padding: 1.75rem 1.5rem 1.5rem;
    border-radius: 0.75rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.photo-detail-panel .full-res-overlay-box p {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

.photo-detail-panel .full-res-overlay-icon {
    display: block;
    font-size: 1.75rem;
    color: #F59E0B;
    margin-bottom: 0.75rem;
}

.photo-detail-panel .full-res-overlay-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    border: none;
    background: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #9CA3AF;
    cursor: pointer;
    padding: 0.25rem;
}

.photo-detail-panel .full-res-overlay-close:hover {
    color: #374151;
}


.photo-detail-panel .action-buttons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.photo-detail-panel button.btn,
.photo-detail-panel form button[type="submit"] {
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.photo-detail-panel button.btn-success {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.photo-detail-panel button.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.photo-detail-panel button.btn-secondary {
    background: white;
    color: #6B7280;
    border: 2px solid #E5E7EB;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.photo-detail-panel button.btn-secondary:hover {
    background: #F9FAFB;
    border-color: #D1D5DB;
    color: #374151;
}

.photo-detail-panel a.btn-secondary {
    background: white;
    color: #6B7280;
    border: 2px solid #E5E7EB;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.photo-detail-panel a.btn-secondary:hover {
    background: #F9FAFB;
    border-color: #D1D5DB;
    color: #374151;
}

.photo-detail-panel .assign-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 2px solid #E5E7EB;
}

.photo-detail-panel .assign-label {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #374151;
    text-align: center;
    width: 100%;
}

.photo-detail-panel .assign-input {
    padding: 0.75rem 1.25rem;
    border-radius: 0.75rem;
    border: 2px solid #E5E7EB;
    width: 100%;
    max-width: 400px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.photo-detail-panel .assign-input:focus {
    outline: none;
    border-color: #FF6B35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.photo-detail-panel .assign-button {
    background: linear-gradient(135deg, #FF6B35 0%, #FF7593 100%);
    border: none;
    color: white;
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 0.75rem 2rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.25);
}

.photo-detail-panel .assign-button:hover {
    background: linear-gradient(135deg, #E85A2A 0%, #E85A7A 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.35);
}

.photo-detail-panel .back-button-container {
    margin-top: 2rem;
    text-align: center;
}

.flash-messages {
    margin-bottom: 2rem;
}

body.raceface-theme .photo-detail-card {
    background: var(--rf-dark-card);
    border: 1px solid var(--rf-dark-border);
    color: var(--rf-text-primary);
}

body.raceface-theme .photo-detail-panel .assign-form {
    border-top-color: var(--rf-dark-border);
}

body.raceface-theme .photo-detail-panel .assign-label {
    color: var(--rf-text-primary);
}

body.raceface-theme .photo-detail-panel .assign-input {
    background: #0e0e0e;
    color: var(--rf-text-primary);
    border-color: var(--rf-dark-border);
}

body.raceface-theme .photo-detail-panel .assign-input::placeholder {
    color: var(--rf-text-dim);
}

body.raceface-theme .photo-detail-panel button.btn-secondary,
body.raceface-theme .photo-detail-panel a.btn-secondary {
    background: transparent;
    color: var(--rf-text-primary);
    border-color: var(--rf-dark-border);
}

body.raceface-theme .photo-detail-panel button.btn-secondary:hover,
body.raceface-theme .photo-detail-panel a.btn-secondary:hover {
    border-color: var(--rf-orange);
    color: var(--rf-orange);
}

@media (max-width: 768px) {
    .photo-detail-card {
        padding: 1.5rem;
    }

    .photo-detail-panel img.img-fluid {
        max-height: 400px;
    }

    .photo-detail-panel .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .photo-detail-panel button.btn,
    .photo-detail-panel form button[type="submit"] {
        width: 100%;
        justify-content: center;
    }

    .photo-detail-panel .assign-input {
        max-width: 100%;
    }

    .photo-detail-panel .assign-button {
        width: 100%;
    }
}

/* ---- #102: your answer for a photo, pick-yourself mode, guided review ---- */
.photo-detail-panel .me-state {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    margin-bottom: 0.75rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
}
.photo-detail-panel .me-state.confirmed { background: rgba(16, 185, 129, 0.15); color: #047857; }
.photo-detail-panel .me-state.denied    { background: rgba(107, 114, 128, 0.15); color: #4b5563; }
.photo-detail-panel .me-state.pending   { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.photo-detail-panel .me-state-sub { font-weight: 400; opacity: 0.8; }

.photo-detail-panel .review-progress,
.photo-detail-panel .pick-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 1rem;
    margin-bottom: 0.75rem;
    border-radius: 0.5rem;
    background: rgba(255, 107, 53, 0.12);
    font-size: 0.95rem;
}
.photo-detail-panel .pick-banner[hidden] { display: none; }

/* Pick mode: the detected people become clickable. */
.photo-detail-panel .photo-frame.is-picking .match-highlight-overlay { pointer-events: auto; cursor: crosshair; }
.photo-detail-panel .photo-frame.is-picking .match-body-box {
    pointer-events: auto;
    cursor: pointer;
    border: 3px solid #FF6B35;
    background: rgba(255, 107, 53, 0.12);
    opacity: 1;
}
.photo-detail-panel .photo-frame.is-picking .match-body-box:hover { background: rgba(255, 107, 53, 0.32); }
.photo-detail-panel .photo-frame.is-picking .photo-overlay-hotzone { display: none; }

/* "Me" / "Is this you?" badge on photo thumbnails (My Photos, race page). */
.me-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 2;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
/* !important: the raceface theme restyles generic text colors on gallery cards. */
.me-badge.confirmed { background: #059669; color: #fff !important; }
.me-badge.pending   { background: #f59e0b; color: #1f2937 !important; }
.me-badge i { color: inherit !important; }

.review-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border-radius: 0.75rem;
    background: rgba(255, 107, 53, 0.12);
}

.add-to-my-photos-option {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    margin: 1rem 0 0;
    cursor: pointer;
}
.add-to-my-photos-option small { display: block; opacity: 0.75; margin-top: 0.15rem; }

/* ---- #97: who is already identified in a photo, assigning, your bib ---- */
.photo-detail-panel .match-body-tag {
    position: absolute;
    left: 0;
    bottom: 0;
    max-width: 100%;
    padding: 2px 8px;
    border-radius: 0 6px 0 4px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(17, 24, 39, 0.85);
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.photo-detail-panel .match-body-tag.me { background: #059669; }
.photo-detail-panel .match-body-tag.assigned_by_me { background: #2563eb; }
/* Assign mode: people who are already identified can't be picked. */
.photo-detail-panel .photo-frame.is-assigning .match-body-box.is-identified {
    pointer-events: none;
    border-style: dashed;
    background: rgba(17, 24, 39, 0.35);
}
.photo-detail-panel .bib-box,
.photo-detail-panel .assign-section { margin: 1rem 0; }
.photo-detail-panel .bib-input { width: 9rem; display: inline-block; }
.photo-detail-panel .bib-note { font-size: 0.85rem; opacity: 0.8; margin-left: 0.5rem; }
.photo-detail-panel .my-assignments { list-style: none; padding: 0; margin: 0.75rem 0 0; font-size: 0.9rem; }
.photo-detail-panel .assign-form[hidden] { display: none !important; }

/* ---- #97 follow-up: muted "You" box, centered assign form ---- */
.photo-detail-panel .match-body-box.is-me:not(.is-match) { border: 2px solid #94a3b8; opacity: 1; }
.photo-detail-panel .match-body-tag.me { background: #64748b; }
.photo-detail-panel .assign-section { text-align: center; padding: 1rem; margin: 1.25rem 0; border-radius: 0.75rem; background: rgba(255, 107, 53, 0.08); }
.photo-detail-panel .assign-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 0.75rem; }
.photo-detail-panel .assign-title i { color: #FF6B35; margin-right: 0.4rem; }
.photo-detail-panel .assign-row { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.photo-detail-panel .assign-row .assign-input { flex: 1 1 16rem; max-width: 24rem; }
.photo-detail-panel .assign-help { font-size: 0.85rem; opacity: 0.8; margin: 0.5rem 0 0; }
.photo-detail-panel .my-assignments { text-align: center; }

/* Identified people (you, assigned, already identified) are all muted grey and can't be chosen to assign. */
.photo-detail-panel .match-body-box.has-tag:not(.is-match) { border: 2px solid #94a3b8; opacity: 1; }
.photo-detail-panel .photo-frame.is-assigning .match-body-box.is-me,
.photo-detail-panel .photo-frame.is-assigning .match-body-box.is-identified,
.photo-detail-panel .photo-frame.is-targeting .match-body-box.is-match {
    pointer-events: none;
    border-style: dashed;
    background: rgba(17, 24, 39, 0.35);
}
.photo-detail-panel .match-body-tag.other { background: #475569; }

/* ---- #155 feedback: every control in the photo panel must look and feel clickable ----
   (a tester couldn't tell "Actually, I'm not in this photo", "Select a different person",
   the Assign button, or the photo's left/right/zoom icons were buttons). All of them
   get a pointer, a visible resting outline where they had none, and a clear hover. */
.photo-detail-panel button.btn,
.photo-detail-panel a.btn,
.photo-detail-panel .assign-button,
.photo-detail-panel .full-res-icon-btn {
    cursor: pointer;
}
.photo-detail-panel button.btn:focus-visible,
.photo-detail-panel a.btn:focus-visible,
.photo-detail-panel .assign-button:focus-visible,
.photo-detail-panel .full-res-icon-btn:focus-visible {
    outline: 3px solid #FF6B35;
    outline-offset: 2px;
}

/* "Select a different person...", "I'm a different person..." */
.photo-detail-panel .btn-outline-secondary {
    border: 2px solid #FF6B35 !important;
    color: #FF6B35 !important;
    background: transparent !important;
    border-radius: 9999px;
    padding: 0.45rem 1.1rem;
    font-weight: 600;
    transition: all 0.15s ease;
}
.photo-detail-panel .btn-outline-secondary:hover {
    background: #FF6B35 !important;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.35);
}

/* Text-style buttons ("Actually, I'm not in this photo" undo, Remove, Change, Not now) */
.photo-detail-panel .btn-link {
    text-decoration: underline;
    border-radius: 0.5rem;
    transition: background 0.15s ease;
}
.photo-detail-panel .btn-link:hover {
    background: rgba(255, 107, 53, 0.15);
    text-decoration: none;
}

/* Green / grey action buttons: lift + brighten on hover */
.photo-detail-panel button.btn-success:hover,
.photo-detail-panel button.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    filter: brightness(1.1);
}

/* Assign: a clear pill with an arrow-lift on hover, and a pressed state */
.photo-detail-panel .assign-button {
    box-shadow: 0 3px 10px rgba(255, 107, 53, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.35);
}
.photo-detail-panel .assign-button:hover {
    filter: brightness(1.08);
    box-shadow: 0 6px 16px rgba(255, 107, 53, 0.55);
}
.photo-detail-panel .assign-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 4px rgba(255, 107, 53, 0.4);
}

/* Zoom (full-size) icon on the photo */
.photo-detail-panel .full-res-icon-btn {
    border: 2px solid rgba(255, 255, 255, 0.85);
}
.photo-detail-panel .full-res-icon-btn:hover:not(:disabled) {
    background: #FF6B35;
    border-color: #fff;
    transform: scale(1.12);
}

/* ---- #155 feedback 2: grey/outline buttons in the dark (raceface) theme need an obvious hover too.
   "Actually, I'm not in this photo", "I'm not in this photo" and the bib "Save" are .btn-secondary:
   a visible outline at rest, and an orange fill on hover. Higher specificity + !important so the
   raceface theme's transparent-background rules above can't win. ---- */
body.raceface-theme .photo-detail-panel button.btn-secondary,
body.raceface-theme .photo-detail-panel a.btn-secondary,
.photo-detail-panel button.btn-secondary {
    border: 2px solid rgba(255, 107, 53, 0.55) !important;
    cursor: pointer;
}
body.raceface-theme .photo-detail-panel button.btn-secondary:hover,
body.raceface-theme .photo-detail-panel a.btn-secondary:hover,
.photo-detail-panel button.btn-secondary:hover,
.photo-detail-panel a.btn-secondary:hover {
    background: #FF6B35 !important;
    border-color: #FF6B35 !important;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.35);
    filter: none;
}
body.raceface-theme .photo-detail-panel button.btn-secondary:hover i,
.photo-detail-panel button.btn-secondary:hover i { color: #fff !important; }
body.raceface-theme .photo-detail-panel .btn-link:hover,
.photo-detail-panel .btn-link:hover {
    background: rgba(255, 107, 53, 0.2) !important;
    color: #FF6B35 !important;
}
