/*
 * _shared/media.css
 * -----------------
 * Sdílené styly pro media-related stránky (/me/media, /me/media/album/{id},
 * /shared, /shared/album/{id}). Před Fází 5 byly tyto styly jen v
 * auth/style.css; po přesunu šablon do _shared/ je potřeba mít je sdílené.
 * Vodaci a budoucí themes získají stejné UI bez kopírování.
 *
 * Závislosti: --bg, --border, --muted, --accent CSS vars — definované
 * v každém tenant theme style.css.
 */

/* Media — alba a items grid. */
.media-page-header { margin-bottom: 1.5rem; }
.media-page-header h1 { margin: 0.5rem 0 0.25rem; }
.media-album-desc { color: var(--muted); margin: 0.25rem 0 0.75rem; }

.media-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-size: 1.1rem;
}

/* New album panel + edit panel — collapsible details. */
.media-new-album, .media-share-panel, .media-album-edit-panel, .media-upload-form, .media-download-panel {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: #fafbfc;
}
.media-new-album summary,
.media-share-panel summary,
.media-album-edit-panel summary,
.media-download-panel summary {
  padding: 0.7rem 1rem;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}
.media-new-album form,
.media-share-panel,
.media-album-edit-panel form,
.media-download-form {
  padding: 0 1rem 1rem;
}
.media-download-form label {
  display: inline-block;
  margin-right: 0.75rem;
}
.media-download-form select {
  padding: 0.3rem 0.4rem;
  margin-left: 0.4rem;
}
.media-new-album label,
.media-album-edit-panel label {
  display: block;
  margin: 0.5rem 0;
}
.media-new-album input[type="text"],
.media-new-album textarea,
.media-album-edit-panel input[type="text"],
.media-album-edit-panel textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  font: inherit;
  box-sizing: border-box;
}
.media-album-edit-panel form { padding-top: 1rem; }

/* Album grid (rozcestník + shared). */
.media-album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.media-album-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  background: #fff;
  transition: transform 0.1s, box-shadow 0.1s;
}
.media-album-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.media-album-cover {
  aspect-ratio: 4 / 3;
  background: #f0f2f5;
  overflow: hidden;
}
.media-album-card .media-album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-album-cover-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 3rem;
  color: var(--border);
}
.media-album-info { padding: 0.6rem 0.85rem; }
.media-album-info h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.media-album-info p  { margin: 0.2rem 0 0; font-size: 0.85rem; }

/* Item grid (uvnitř alba). */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}
.media-thumb {
  position: relative;
  margin: 0;
  aspect-ratio: 1;
  background: #f0f2f5;
  border-radius: 0.4rem;
  overflow: hidden;
}
.media-grid .media-thumb-link {
  position: absolute;
  inset: 0;
  display: block;
}
/* Specificita 0,0,2,1 — porazí responsive.css `.site-main img { height: auto }`
   (0,0,1,1), který jinak v kaskádě vyhrává a nechá fotku jen "na šířku". */
.media-grid .media-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-video-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 3rem;
  color: #fff;
  background: linear-gradient(135deg, #2b2b2b, #4a4a4a);
}
/* Video poster + centered play button overlay. */
.media-video-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-indent: 0.2em;     /* opticky vystředit ▶ uvnitř kruhu */
}

/* Protected indicator (zámeček v rohu vlastníkova thumbu). */
.media-thumb.is-protected::before {
  content: '🔒';
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  font-size: 1rem;
  background: rgba(0,0,0,0.55);
  color: #fff;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 2;
}

/* Action buttons na thumbu — zobraz na hover. */
.media-thumb-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 0.4rem;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  opacity: 0;
  transition: opacity 0.15s;
}
.media-thumb:hover .media-thumb-actions { opacity: 1; }
.media-thumb-actions form { margin: 0; }
.media-thumb-btn {
  background: rgba(255,255,255,0.85);
  border: none;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.media-thumb-btn:hover { background: #fff; }
.media-thumb-btn.is-active { background: #ffd966; }

/* Share list — uživatelé jako toggle button. */
.media-share-list {
  list-style: none;
  padding: 0 1rem 1rem;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.media-share-list li { margin: 0; }
.media-share-list form { margin: 0; }
.media-share-toggle {
  background: #fff;
  border: 1px solid var(--border);
  padding: 0.35rem 0.8rem 0.35rem 0.4rem;
  border-radius: 1.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.2;
}
.media-share-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  overflow: hidden;
}
.media-share-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-share-info {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
}
.media-share-toggle small {
  font-size: 0.75rem;
  color: var(--muted);
}
.media-share-toggle.is-shared {
  background: #e8f5e8;
  border-color: #4a9d4a;
  color: #1f5e1f;
}
.media-share-toggle.is-shared small { color: #4a9d4a; }
.media-share-toggle:hover { box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Sort toggle (newest/oldest) v hlavičce alba. */
.media-sort {
  display: inline-flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}
.media-sort a {
  padding: 0.15rem 0.5rem;
  border: 1px solid #d0d0d0;
  border-radius: 0.25rem;
  text-decoration: none;
  color: #555;
  background: #fafafa;
}
.media-sort a:hover { background: #f0f0f0; }
.media-sort a.is-active {
  background: #2c5b8c;
  color: #fff;
  border-color: #2c5b8c;
}

/* Upload form. */
.media-upload-form { padding: 0.85rem 1rem; }
.media-upload-label {
  display: block;
  cursor: pointer;
  text-align: center;
  padding: 1.25rem;
  border: 2px dashed var(--border);
  border-radius: 0.4rem;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}
.media-upload-label:hover {
  border-color: #4a9d4a;
  background: #f3faf3;
}
.media-upload-label input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.media-upload-cta { font-weight: 500; font-size: 1rem; }
.media-upload-form small { display: block; margin-top: 0.5rem; text-align: center; }
.media-upload-errors {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
  color: #c1121f;
  font-size: 0.85rem;
}
#media-upload-status p { margin: 0.5rem 0; }
#media-upload-status .error { color: #c1121f; }

/* Toolbar — zarovnání všech tří panelů. */
.media-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}

/* ============================================================
 * Filter bar pro sjednocený seznam alb (/me/media):
 * pills mine/shared/managed + sort dropdown.
 * ============================================================ */
.media-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0;
  padding: 0.6rem 0.8rem;
  background: #f8fafd;
  border: 1px solid #e0e6ee;
  border-radius: 0.4rem;
}
.media-filter-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.media-filter-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  border-radius: 1rem;
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.media-filter-pill.is-on  { background: #fff; border-color: #c5d4e6; color: #1f2937; }
.media-filter-pill.is-off { background: transparent; border-color: #d6dce3; color: #777; }
.media-filter-pill:hover  { background: #eef3fa; }
.media-filter-pill .media-filter-mark { font-size: 0.85em; opacity: 0.7; }
.media-filter-pill-mine.is-on    { box-shadow: inset 3px 0 0 #2c8a3f; }
.media-filter-pill-shared.is-on  { box-shadow: inset 3px 0 0 #2c5b8c; }
.media-filter-pill-managed.is-on { box-shadow: inset 3px 0 0 #6b3fa0; }

.media-sort-control { display: inline-flex; align-items: center; gap: 0.4rem; }
.media-sort-control select { padding: 0.25rem 0.4rem; font-size: 0.9rem; }

/* ============================================================
 * Ownership badge na album cards. Barevný left-border + corner pill.
 * ============================================================ */
.media-album-card.is-mine    { border-left: 4px solid #2c8a3f; }
.media-album-card.is-shared  { border-left: 4px solid #2c5b8c; }
.media-album-card.is-managed { border-left: 4px solid #6b3fa0; }

.media-album-cover { position: relative; }
.media-album-badge {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  padding: 0.2rem 0.55rem;
  border-radius: 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(4px);
  color: #1f2937;
  z-index: 2;
  pointer-events: none;
  white-space: nowrap;
}
.media-album-badge-mine    { color: #155724; background: rgba(212,237,218,0.92); }
.media-album-badge-shared  { color: #1a3d63; background: rgba(207,226,243,0.92); }
.media-album-badge-managed { color: #4b1f6e; background: rgba(231,217,247,0.92); }

@media (max-width: 720px) {
  .media-filter-bar { padding: 0.5rem; gap: 0.5rem; }
  .media-sort-control { width: 100%; }
  .media-sort-control select { flex: 1; }
}
/* Site-main expanze pro media stránky. */
.site-main:has(.media-grid),
.site-main:has(.media-album-grid),
.site-main:has(.media-page-header) {
  max-width: 80rem;
}

/* ============================================================
 * Inline lightbox — sjednocený prohlížeč pro media-album +
 * article-gallery. Markup vytváří lightbox.js (overlay je
 * injectovaný do <body>, nikoli součást šablon).
 * ============================================================ */
.lightbox-open { overflow: hidden; }
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.93);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox[hidden] { display: none; }
.lightbox-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.lightbox-img {
  max-width: 96vw;
  max-height: calc(100vh - 4.5rem);
  object-fit: contain;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;       /* nutné aby pointer events fungovaly pro pinch/pan */
  transform-origin: center center;
  will-change: transform;
}
.lightbox-img.is-zoomed { cursor: grab; }
.lightbox-img.is-zoomed:active { cursor: grabbing; }
.lightbox-video {
  max-width: 96vw;
  max-height: calc(100vh - 4.5rem);
  background: #000;
  outline: none;
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 2;
  transition: background 0.15s;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.28);
}
.lightbox-close:focus-visible,
.lightbox-prev:focus-visible,
.lightbox-next:focus-visible {
  outline: 2px solid #6cf;
  outline-offset: 2px;
}
.lightbox-close { top: 1rem; right: 1rem; }
.lightbox-prev  { left:  1rem; top: 50%; transform: translateY(-50%); }
.lightbox-next  { right: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox-meta {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.6rem 1rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), transparent);
  color: #eee;
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  align-items: center;
  z-index: 2;
}
.lightbox-position { opacity: 0.8; min-width: 4rem; white-space: nowrap; }
.lightbox-caption  { flex: 1; opacity: 0.95; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-orig {
  color: #8cf;
  text-decoration: none;
  white-space: nowrap;
}
.lightbox-orig:hover { text-decoration: underline; }
.lightbox-orig-status {
  white-space: nowrap;
  font-size: 0.8rem;
  opacity: 0.8;
}

@media (max-width: 720px) {
  .lightbox-close,
  .lightbox-prev,
  .lightbox-next {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.4rem;
  }
  .lightbox-prev { left: 0.5rem; }
  .lightbox-next { right: 0.5rem; }
  .lightbox-close { top: 0.5rem; right: 0.5rem; }
  .lightbox-meta { font-size: 0.8rem; padding: 0.5rem 0.7rem; }
}
