/* photos-manager.css — shared frontend styles for photos-service consumers
 * Loaded by both presbytere and geneafan via:
 *   <link rel="stylesheet" href="https://photos.genealogie.app/v1/photos-manager.css">
 * Versioned by path segment (/v1/) so consumers opt in to upgrades.
 */

main { max-width: 1100px; margin: 0 auto; padding: 0 1rem 5rem; }
h1 { font-size: clamp(1.5rem, 4vw, 2.25rem); font-weight: 400; letter-spacing: 0.03em; margin: 1rem 0 0.5rem; }
.subtitle { color: #6b6b6b; font-style: italic; font-size: 0.9rem; margin-bottom: 1.25rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; margin-bottom: 1rem; }
.toolbar select, .toolbar button { font: inherit; padding: 0.5rem 0.85rem; border: 1px solid #d8d2c6; border-radius: 4px; background: #fff; color: #2c2c2c; }
.toolbar button.primary { background: #b8a88a; border-color: #b8a88a; color: #fff; cursor: pointer; }
.toolbar button.primary:hover { background: #a89a7e; }
.toolbar .grow { flex: 1; }
.toolbar label { font-size: 0.78rem; color: #6b6b6b; text-transform: uppercase; letter-spacing: 0.08em; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile-min, 140px), 1fr)); gap: 0.5rem; }
.grid.pinching { touch-action: none; user-select: none; }
.grid-section-title { grid-column: 1 / -1; margin: 1rem 0 0.25rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.12em; color: #6b6b6b; font-weight: 500; display: flex; align-items: baseline; gap: 0.5rem; }
.grid-section-title:first-child { margin-top: 0; }
.grid-section-title .count { font-size: 0.7rem; color: #b8a88a; letter-spacing: 0; text-transform: none; font-weight: 400; }
.tile { position: relative; aspect-ratio: 1; background: #f0ebe2; border-radius: 4px; overflow: hidden; cursor: pointer; border: 0; padding: 0; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.tile:hover img { transform: scale(1.04); }
.tile .caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 0.4rem 0.5rem; background: linear-gradient(transparent, rgba(0,0,0,0.55)); color: #fff; font-size: 0.72rem; line-height: 1.2; text-align: left; pointer-events: none; }
.tile .badges { position: absolute; top: 0.35rem; left: 0.35rem; display: flex; gap: 0.25rem; }
.tile .badges span { display: inline-block; background: rgba(255,255,255,0.85); color: #6b6b6b; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.1rem 0.4rem; border-radius: 8px; }
.tile .badges span.public { background: rgba(184,168,138,0.9); color: #fff; }
.tile .badges span.gallery { background: rgba(46,83,130,0.85); color: #fff; }
.tile.video { background: #2c2c2c; color: #fff; }
.tile.video .video-thumb { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; flex-direction: column; gap: 0.5rem; color: #d8d2c6; }
.tile.video .video-thumb svg { width: 38px; height: 38px; opacity: 0.85; }
.tile.video .video-thumb .duration { font-size: 0.75rem; opacity: 0.85; }
.tile.video .video-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem; background: linear-gradient(transparent 30%, rgba(0,0,0,0.45)); color: #fff; pointer-events: none; }
.tile.video .video-overlay svg { width: 38px; height: 38px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5)); }
.tile.video .video-overlay .duration { font-size: 0.75rem; background: rgba(0,0,0,0.55); padding: 0.1rem 0.4rem; border-radius: 4px; }

.info-btn { position: absolute; bottom: 0.3rem; right: 0.3rem; appearance: none; -webkit-appearance: none; background: rgba(255,255,255,0.85); border: 0; border-radius: 50%; width: 22px; height: 22px; padding: 0; display: flex; align-items: center; justify-content: center; color: #6b6b6b; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.2); z-index: 3; font-size: 0.72rem; font-weight: 600; font-style: italic; line-height: 1; opacity: 0.75; transition: opacity 0.15s; }
.tile:hover .info-btn { opacity: 1; }
.info-btn:hover, .info-btn:focus-visible { background: #fff; color: #2c2c2c; outline: 0; opacity: 1; }
.tile .caption { padding-right: 2rem; }

body.select-mode .info-btn { display: none; }
.tile.selected { outline: 3px solid #b8a88a; outline-offset: -3px; }
.tile.selected::after { content: '✓'; position: absolute; top: 0.4rem; left: 0.4rem; width: 28px; height: 28px; background: #b8a88a; color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; font-weight: 600; z-index: 4; }
body.select-mode .tile .badges { display: none; }
.select-bar { position: fixed; left: 0; right: 0; bottom: 0; background: #2c2c2c; color: #fff; padding: 0.75rem 1rem; display: none; align-items: center; gap: 0.5rem; z-index: 50; box-shadow: 0 -4px 12px rgba(0,0,0,0.25); }
.select-bar.visible { display: flex; }
.select-bar .count { font-size: 0.9rem; }
.select-bar .grow { flex: 1; }
.select-bar button { font: inherit; padding: 0.5rem 0.85rem; border: 0; border-radius: 4px; background: rgba(255,255,255,0.12); color: #fff; cursor: pointer; }
.select-bar button:hover { background: rgba(255,255,255,0.2); }
.select-bar button.danger { background: #b04040; }
.select-bar button.danger:hover { background: #c25050; }
.select-bar button:disabled { opacity: 0.4; cursor: default; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.92); display: none; align-items: center; justify-content: center; z-index: 200; touch-action: none; }
.lightbox.open { display: flex; }
.lightbox:fullscreen { background: #000; }
.lightbox .lb-stage { width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.lightbox .lb-stage img, .lightbox .lb-stage video { max-width: 100vw; max-height: 100vh; object-fit: contain; display: block; transform-origin: center; will-change: transform; }
.lightbox .lb-stage iframe { width: min(100vw, 1280px); height: min(85vh, 720px); border: 0; }
.lightbox .lb-caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 1rem 1.5rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.7)); font-size: 0.9rem; line-height: 1.4; pointer-events: none; }
.lightbox .lb-caption .title { font-weight: 500; margin-bottom: 0.2rem; }
.lightbox button { position: absolute; appearance: none; -webkit-appearance: none; background: rgba(0,0,0,0.5); color: #fff; border: 0; cursor: pointer; z-index: 10; }
.lightbox button:hover, .lightbox button:focus-visible { background: rgba(0,0,0,0.75); outline: 0; }
.lightbox .lb-close { top: 1rem; right: 1rem; width: 40px; height: 40px; border-radius: 50%; font-size: 1.4rem; line-height: 1; padding: 0; }
.lightbox .lb-edit { top: 1rem; left: 1rem; padding: 0.5rem 0.85rem; border-radius: 18px; font: inherit; font-size: 0.8rem; }
.lightbox .lb-nav { top: 50%; transform: translateY(-50%); width: 48px; height: 64px; font-size: 2rem; line-height: 1; padding: 0; border-radius: 4px; }
.lightbox .lb-prev { left: 0.5rem; }
.lightbox .lb-next { right: 0.5rem; }
.lightbox .lb-nav:disabled { opacity: 0.3; cursor: default; }
@media (max-width: 600px) { .lightbox .lb-nav { width: 40px; height: 56px; font-size: 1.6rem; } }

.tabs { display: flex; align-items: center; gap: 0.25rem; border-bottom: 1px solid #ece6d9; margin-bottom: 1rem; }
.tabs .tab { font: inherit; background: transparent; border: 0; padding: 0.6rem 1rem; cursor: pointer; color: #6b6b6b; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs .tab.active { color: #2c2c2c; border-bottom-color: #b8a88a; }
.tabs .grow { flex: 1; }
.tabs .save-state { font-size: 0.78rem; color: #b8a88a; padding-right: 0.5rem; font-style: italic; }
.hint { color: #6b6b6b; font-size: 0.85rem; margin: 0 0 1rem; font-style: italic; }

.grid-sortable .tile { cursor: default; }
.grid-sortable .tile.dragging { opacity: 0.4; }
.grid-sortable .tile::before { content: attr(data-order); position: absolute; top: 0.35rem; right: 0.35rem; background: rgba(255,255,255,0.85); color: #6b6b6b; font-size: 0.65rem; padding: 0.1rem 0.4rem; border-radius: 8px; pointer-events: none; z-index: 2; }
.drag-handle { appearance: none; -webkit-appearance: none; position: absolute; bottom: 0.3rem; right: 0.3rem; width: 30px; height: 30px; background: #fff; border: 1px solid #d8d2c6; border-radius: 4px; cursor: grab; touch-action: none; line-height: 0; color: #2c2c2c; padding: 0; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,0.2); z-index: 3; user-select: none; -webkit-user-select: none; }
.drag-handle svg { display: block; width: 16px; height: 16px; }
.drag-handle:hover, .drag-handle:focus-visible { background: #fff; color: #2c2c2c; outline: 0; }
.drag-handle:active { cursor: grabbing; }
.grid-sortable.saving { pointer-events: none; opacity: 0.7; }

.empty { color: #bbb; font-style: italic; padding: 2rem; text-align: center; }

.dlg { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: none; align-items: flex-start; justify-content: center; padding: 1rem; z-index: 100; overflow-y: auto; }
.dlg.open { display: flex; }
.dlg .panel { background: #fff; border-radius: 6px; max-width: 720px; width: 100%; padding: 1.25rem; box-shadow: 0 8px 32px rgba(0,0,0,0.2); margin: 1rem 0; }
.dlg h2 { font-size: 1.1rem; font-weight: 500; margin: 0 0 0.75rem; }
.dlg .row { display: flex; gap: 0.5rem; margin-bottom: 0.6rem; align-items: center; }
.dlg label { font-size: 0.78rem; color: #6b6b6b; text-transform: uppercase; letter-spacing: 0.08em; flex: 0 0 130px; }
.dlg input[type=text], .dlg input[type=number], .dlg textarea, .dlg select { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid #d8d2c6; border-radius: 3px; background: #fff; flex: 1; min-width: 0; }
.dlg textarea { resize: vertical; min-height: 70px; }
.dlg .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid #ece6d9; }
.dlg .actions button { font: inherit; padding: 0.5rem 1rem; border: 1px solid #d8d2c6; border-radius: 4px; background: #fff; cursor: pointer; }
.dlg .actions button.primary { background: #b8a88a; border-color: #b8a88a; color: #fff; }
.dlg .actions button.danger { color: #b04040; }
.dlg .actions .grow { flex: 1; }

.detail-img { width: 100%; max-height: 50vh; object-fit: contain; background: #f0ebe2; border-radius: 4px; margin-bottom: 0.5rem; aspect-ratio: 4 / 3; }
@media (min-width: 820px) { .detail-img { max-height: 70vh; } }
.detail-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.detail-media { display: flex; flex-direction: column; }
.detail-form { display: flex; flex-direction: column; gap: 0.6rem; }
@media (min-width: 820px) {
	.dlg .detail-panel { max-width: 1100px; }
	.detail-grid { flex-direction: row; align-items: flex-start; gap: 1.25rem; }
	.detail-media { flex: 1; min-width: 0; }
	.detail-form { flex: 0 0 360px; }
}
.exif-strip { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; padding: 0.5rem 0.75rem; margin-bottom: 0.75rem; background: #faf8f5; border-radius: 4px; font-size: 0.78rem; color: #6b6b6b; }
.exif-strip span { white-space: nowrap; }
.exif-strip a { color: #2e5382; text-decoration: none; }
.exif-strip a:hover { text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; min-height: 2rem; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; background: #f0ebe2; border-radius: 12px; padding: 0.25rem 0.6rem; font-size: 0.78rem; }
.chip .x { background: none; border: none; cursor: pointer; color: #6b6b6b; padding: 0; font-size: 1rem; line-height: 1; }
/* Default chip palette — apps can override per entity-type via theme tokens. */
.chip.projet { background: #dde7f3; color: #2e5382; }
.chip.piece { background: #efe0cf; color: #70512d; }
.chip.evenement { background: #dcefd4; color: #3f6b2e; }
.chip.personne { background: #dde7f3; color: #2e5382; }
.chip.famille { background: #efe0cf; color: #70512d; }
.chip.lieu { background: #dcefd4; color: #3f6b2e; }
.chip.source { background: #f0e7d4; color: #70653b; }

.upload-list { max-height: 50vh; overflow-y: auto; margin: 0.75rem 0; }
.upload-item { display: grid; grid-template-columns: 60px 1fr auto; gap: 0.6rem; align-items: center; padding: 0.4rem 0; border-bottom: 1px solid #ece6d9; }
.upload-item .thumb { width: 60px; height: 60px; background: #f0ebe2; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; color: #999; overflow: hidden; }
.upload-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-item .name { font-size: 0.85rem; word-break: break-all; }
.upload-item .size { font-size: 0.72rem; color: #999; }
.upload-item .status { font-size: 0.78rem; color: #6b6b6b; min-width: 90px; text-align: right; }
.upload-item.ok .status { color: #3f6b2e; }
.upload-item.err .status { color: #b04040; }
.upload-item .progress { grid-column: 2 / -1; height: 4px; background: #ece6d9; border-radius: 2px; overflow: hidden; }
.upload-item .progress > .bar { height: 100%; background: #b8a88a; transition: width 0.2s ease; width: 0%; }
.upload-item.ok .progress > .bar { background: #3f6b2e; }
.upload-item.err .progress > .bar { background: #b04040; }

.attach-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 0.4rem; margin-bottom: 0.75rem; }
.attach-photos .thumb { aspect-ratio: 1; background: #f0ebe2; border-radius: 3px; overflow: hidden; }
.attach-photos .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.entity-picker { max-height: 38vh; overflow-y: auto; border: 1px solid #ece6d9; border-radius: 4px; padding: 0.4rem 0.6rem; }
.entity-group { margin-bottom: 0.5rem; }
.entity-group h3 { font-size: 0.7rem; color: #b8a88a; text-transform: uppercase; letter-spacing: 0.15em; margin: 0.5rem 0 0.3rem; font-weight: 400; }
.entity-row { display: flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0; }
.entity-row label { flex: 1; font-size: 0.85rem; cursor: pointer; }
