/* ===== Gailery Viewer — модальный просмотрщик фото/видео ===== */
/* Подключается на любой странице где нужен просмотр */

.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 1010; justify-content: center; align-items: center; }
.modal-bg.show { display: flex; }
.modal-img-wrap { position: relative; display: inline-block; transform-origin: center center; transition: transform .1s; }
.modal-content { display: flex; flex-direction: column; align-items: center; max-width: 90svw; max-height: 90svh; }
.modal-bg.fs .modal-content { max-width: 100svw; max-height: 100svh; }
.modal-bg .modal-img-wrap img, .modal-bg .modal-img-wrap video, .modal-bg .modal-img-wrap canvas { max-width: 90svw; max-height: 90svh; object-fit: contain; border-radius: 4px; }
.modal-bg.fs .modal-img-wrap img, .modal-bg.fs .modal-img-wrap video, .modal-bg.fs .modal-img-wrap canvas { width: 100svw; height: 100svh; object-fit: contain; border-radius: 0; }
.modal-bg .modal-img-wrap img.cover, .modal-bg .modal-img-wrap video.cover { max-width: none; max-height: none; width: 90svw; height: 90svh; object-fit: cover; border-radius: 4px; }
.modal-bg.fs .modal-img-wrap img.cover, .modal-bg.fs .modal-img-wrap video.cover { width: 100svw; height: 100svh; object-fit: cover; border-radius: 0; }
.modal-bg .modal-img-wrap.cover-wrap { display: block; width: 90svw; height: 90svh; }
.modal-bg.fs .modal-img-wrap.cover-wrap { display: block; width: 100svw; height: 100svh; }
.modal-bg.fs { background: #000; }
.modal-bg.fs .modal-topbar { border-radius: 6px; }
.modal-bg .modal-topbar.zoomed { border-radius: 6px 6px 6px 6px; }
.vid-modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 1020; justify-content: center; align-items: center; flex-direction: column; }
.vid-modal-bg.show { display: flex; }
.vid-modal-close { position: absolute; top: 12px; right: 16px; color: #8b949e; font-size: 32px; cursor: pointer; z-index: 1; line-height: 1; }
.vid-modal-close:hover { color: #f85149; }
.vid-modal-bar { height: 36px; color: #c9d1d9; font-size: 12px; font-family: monospace; display: flex; align-items: center; padding: 0 16px; flex-shrink: 0; }
#vidModalPlayer { width: 90vw; height: calc(90vh - 36px); background: #000; border-radius: 6px; }
.face-overlays { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; overflow: visible; }
.face-box { position: absolute; border: 2px solid rgba(88,166,255,.8); border-radius: 3px; opacity: 0; transition: opacity .2s; pointer-events: auto; cursor: pointer; background: transparent; }
.face-overlays:hover .face-box { opacity: 1; }
.face-box:hover { border-color: #58a6ff; }
.face-box-label { position: absolute; bottom: calc(100% + 4px); left: 0; background: rgba(88,166,255,.9); color: #fff; font-size: 13px; font-weight: 600; padding: 3px 8px; border-radius: 3px; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.modal-btns { position: absolute; z-index: 1001; display: flex; gap: 4px; pointer-events: auto; transition: top .15s ease-out, right .15s ease-out; }
.modal-btns > * { color: #fff; font-size: 20px; cursor: pointer; line-height: 1; height: 30px; min-width: 30px; display: flex; align-items: center; justify-content: center; border-radius: 5px; opacity: .35; transition: opacity .15s, background .15s, transform .15s; user-select: none; }
.modal-btns:hover > * { opacity: 1; background: rgba(0,0,0,.65); -webkit-text-stroke: 1.5px #000; text-shadow: 0 0 3px #000, 0 0 6px #000; }
.modal-btns > *:hover { background: rgba(88,166,255,.9) !important; transform: scale(1.15); }
.modal-close { font-size: 24px; }
.modal-close:hover { background: rgba(248,81,73,.9) !important; }
.modal-nav { position: absolute; top: 50%; color: #fff; font-size: 44px; cursor: pointer; z-index: 1001; opacity: 0; user-select: none; transform: translateY(-50%); transition: opacity .3s ease-out, background .15s, transform .15s; border-radius: 6px; -webkit-text-stroke: 1.5px #000; text-shadow: 0 0 4px #000, 0 0 8px #000; display: flex; align-items: center; justify-content: center; width: 56px; height: 80px; }
.modal-nav .nav-arrow { line-height: 1; position: relative; display: inline-block; }
.modal-nav.visible { opacity: .4; }
.modal-nav.visible:hover { opacity: 1; background: rgba(255,255,255,.85); color: #000; -webkit-text-stroke: 0; text-shadow: none; transform: translateY(-50%) scale(1.15); }
.modal-prev { left: 0; }
.modal-next { right: 0; }
.modal-click-zone { position: absolute; top: 50%; height: 80px; width: 50%; z-index: 1000; pointer-events: none; transform: translateY(-50%); display: none; }
.modal-click-prev { left: 0; }
.modal-click-next { right: 0; }
.modal-click-zone.active { display: block; pointer-events: auto; cursor: pointer; }
.modal-click-phantom { position: fixed; font-size: 44px; color: #fff; -webkit-text-stroke: 1.5px #000; text-shadow: 0 0 4px #000, 0 0 8px #000; pointer-events: none; z-index: 1015; transform: translate(-50%,-50%); opacity: 0; animation: clickPhantom .3s ease-out forwards; }
@keyframes clickPhantom { 0% { opacity: .7; } 100% { opacity: 0; } }
.modal-nav .nav-phantoms { position: absolute; top: 50%; left: 50%; pointer-events: none; }
.modal-nav .nav-phantoms i { position: absolute; top: 0; left: 0; transform: translate(-50%,-50%); opacity: 0; font-size: 30px; color: #fff; -webkit-text-stroke: 0; text-shadow: none; font-weight: 100; font-style: normal; }
.modal-prev.visible:hover .nav-phantoms i { animation: phantomLeft 1s ease-out infinite; }
.modal-next.visible:hover .nav-phantoms i { animation: phantomRight 1s ease-out infinite; }
.modal-prev.visible:hover .nav-phantoms i:nth-child(1) { animation-delay: 0s; }
.modal-prev.visible:hover .nav-phantoms i:nth-child(2) { animation-delay: .2s; }
.modal-prev.visible:hover .nav-phantoms i:nth-child(3) { animation-delay: .4s; }
.modal-next.visible:hover .nav-phantoms i:nth-child(1) { animation-delay: 0s; }
.modal-next.visible:hover .nav-phantoms i:nth-child(2) { animation-delay: .2s; }
.modal-next.visible:hover .nav-phantoms i:nth-child(3) { animation-delay: .4s; }
@keyframes phantomLeft { 0% { transform: translate(-50%,-50%) translateX(0); opacity: .5; } 100% { transform: translate(-50%,-50%) translateX(-40px); opacity: 0; } }
@keyframes phantomRight { 0% { transform: translate(-50%,-50%) translateX(0); opacity: .5; } 100% { transform: translate(-50%,-50%) translateX(40px); opacity: 0; } }
.fit-icon { position: relative; transition: width .2s, height .2s; width: 18px; height: 10px; }
.fit-icon i { position: absolute; width: 5px; height: 5px; border: 1.5px solid #fff; font-style: normal; transition: top .2s, left .2s, right .2s, bottom .2s; }
.fit-icon i.tl { top: 0; left: 0; border-top: 1.5px solid #fff; border-left: 1.5px solid #fff; }
.fit-icon i.tr { top: 0; right: 0; border-top: 1.5px solid #fff; border-right: 1.5px solid #fff; }
.fit-icon i.bl { bottom: 0; left: 0; border-bottom: 1.5px solid #fff; border-left: 1.5px solid #fff; }
.fit-icon i.br { bottom: 0; right: 0; border-bottom: 1.5px solid #fff; border-right: 1.5px solid #fff; }
.fit-icon.outer i.tl { top: -2px; left: -2px; }
.fit-icon.outer i.tr { top: -2px; right: -2px; }
.fit-icon.outer i.bl { bottom: -2px; left: -2px; }
.fit-icon.outer i.br { bottom: -2px; right: -2px; }
.modal-topbar { position: absolute; z-index: 1001; background: rgba(0,0,0,.6); padding: 4px 12px; border-radius: 0 0 6px 6px; display: flex; align-items: center; gap: 10px; color: #c9d1d9; font-size: 13px; transition: top .15s ease-out, left .15s ease-out, width .15s ease-out, opacity .5s; box-sizing: border-box; pointer-events: auto; }
.modal-cam { color: #8b949e; font-size: 11px; margin-left: 6px; }
.modal-raw { background: #f0883e; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; margin-left: 6px; letter-spacing: 0.5px; }
.modal-topbar .sep { color: rgba(255,255,255,.2); margin: 0 2px; }
.modal-gps { color: #58a6ff; font-size: 11px; font-weight: 600; background: rgba(88,166,255,.15); padding: 1px 6px; border-radius: 3px; cursor: pointer; white-space: nowrap; }
.modal-gps:hover { background: rgba(88,166,255,.3); }
.modal-gps-manual { color: #fff; font-size: 10px; font-weight: 600; background: rgba(218,54,51,.8); padding: 2px 6px; border-radius: 3px; white-space: nowrap; }
.modal-add-gps { color: #fff; font-size: 11px; font-weight: 600; background: rgba(35,134,54,.8); padding: 2px 6px; border-radius: 3px; cursor: pointer; white-space: nowrap; }
.modal-add-gps:hover { background: rgba(35,134,54,1); }
.modal-clear-gps { color: #fff; font-size: 11px; font-weight: 600; background: rgba(218,54,51,.7); padding: 2px 6px; border-radius: 3px; cursor: pointer; white-space: nowrap; }
.modal-clear-gps:hover { background: rgba(218,54,51,.9); }
.modal-topbar button { background: none; border: none; color: rgba(255,255,255,.35); font-size: 16px; cursor: pointer; padding: 0 3px; transition: color .2s; vertical-align: middle; }
.modal-topbar button:hover { color: #fff; }
.modal-topbar .ss-stop { display: none; }
.modal-topbar .ss-stop:hover { color: #f85149; }
.modal-topbar.playing .ss-stop { display: inline; }
.modal-topbar.playing .ss-dir { display: none; }
.modal-topbar .modal-del { font-size: 15px; }
.modal-topbar .modal-del:hover { color: #f85149; }
.modal-btns > .hidden, .modal-topbar.hidden { opacity: 0; pointer-events: none; }
.modal-flir-bar { display: inline-flex; align-items: center; gap: 4px; }
.flir-mbtn { padding: 2px 6px; background: transparent; color: #8b949e; border: 1px solid transparent; border-radius: 3px; cursor: pointer; font-size: 14px; margin: 0 1px; }
.flir-mbtn:hover { color: #c9d1d9; border-color: #30363d; }
.flir-mbtn.active { color: #da3633; border-color: #da3633; }
.flir-mode-bar { display: flex; gap: 0; margin-bottom: 12px; border: 1px solid #30363d; border-radius: 4px; overflow: hidden; }
.flir-mode-bar button { flex: 1; padding: 4px 6px; background: #21262d; color: #8b949e; border: none; cursor: pointer; font-size: 10px; font-family: monospace; text-align: center; transition: all .15s; }
.flir-mode-bar button:not(:last-child) { border-right: 1px solid #30363d; }
.flir-mode-bar button.active { background: #da3633; color: #fff; }
.flir-mode-bar button:hover:not(.active) { background: #30363d; color: #c9d1d9; }
#flirOverlayControls input[type=range] { background: transparent; cursor: pointer; vertical-align: middle; }

/* Light theme */
.light-theme .modal-bg { background: rgba(0,0,0,.85); }
.light-theme .vid-modal-bg { background: rgba(0,0,0,.87); }
.light-theme .vid-modal-close { color: #57606a; }
.light-theme .vid-modal-bar { color: #24292f; }
.light-theme .modal-close { color: #57606a; }
.light-theme .modal-nav { color: #57606a; }
.light-theme .modal-fs { color: #57606a; }
.light-theme .modal-rot { color: #57606a; }
.light-theme .modal-fit .fit-icon i { border-color: #57606a; }
.light-theme .modal-topbar { background: rgba(255,255,255,.8); color: #24292f; }
.light-theme .modal-topbar button { color: rgba(36,41,47,.35); }
.light-theme .modal-topbar button:hover { color: #24292f; }
.light-theme .modal-topbar .ss-stop:hover { color: #cf222e; }
.light-theme .modal-gps { background: rgba(9,105,218,.15); color: #0969da; }
.light-theme .modal-gps:hover { background: rgba(9,105,218,.3); }
.light-theme .modal-gps-manual { background: rgba(218,54,51,.9); color: #fff; }
.light-theme .modal-add-gps { background: rgba(31,136,61,.9); color: #fff; }
.light-theme .modal-add-gps:hover { background: rgba(31,136,61,1); }
.light-theme .modal-clear-gps { background: rgba(207,34,46,.8); color: #fff; }
.light-theme .modal-clear-gps:hover { background: rgba(207,34,46,1); }
.light-theme .flir-mbtn { color: #57606a; }
.light-theme .flir-mbtn:hover { color: #24292f; border-color: #d0d7de; }
.light-theme .flir-mbtn.active { color: #cf222e; border-color: #cf222e; }
.light-theme .flir-mode-bar { border-color: #d0d7de; }
.light-theme .flir-mode-bar button { background: #f6f8fa; color: #57606a; }
.light-theme .flir-mode-bar button.active { background: #cf222e; color: #fff; }
.light-theme .flir-mode-bar button:hover:not(.active) { background: #eaeef2; color: #24292f; }

@media (max-width: 768px) {
    .modal-nav { font-size: 36px; padding: 30px 16px; }
    .modal-close { font-size: 30px; min-width: 44px; min-height: 44px; }
    .modal-fs { font-size: 24px; min-width: 44px; min-height: 44px; right: 50px; }
    .modal-topbar { font-size: 12px; padding: 2px 8px; gap: 6px; }
}
