/* ═══════════════════════════════════════════════════════════════════
   Zvířecí encyklopedie — custom.css  (mobile-first)
   Bootstrap 5.3 + Font Awesome 6.4
   ═══════════════════════════════════════════════════════════════════ */

/* ── Base ────────────────────────────────────────────────────────── */
body { background:#f4f4f2; font-family:'Segoe UI',system-ui,sans-serif; font-size:15px; }
* { box-sizing:border-box; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
    background:#fff;
    border-bottom:1px solid #e5e5e0;
    padding:.5rem 0;
}
.sidebar-label {
    font-size:10px; font-weight:700; letter-spacing:.1em;
    text-transform:uppercase; color:#aaa; padding:.4rem 1rem .3rem;
}
.cat-item {
    display:flex; align-items:center; gap:10px;
    width:100%; padding:10px 1rem;
    background:none; border:none; text-align:left;
    font-size:14px; color:#444; cursor:pointer;
    border-left:3px solid transparent;
    transition:background .13s,color .13s;
}
.cat-item:hover   { background:#f0f0ec; color:#111; }
.cat-item.active  { background:#eef5ee; color:#1a6b2e; border-left-color:#1a6b2e; font-weight:600; }
.cat-dot {
    width:10px; height:10px; border-radius:50%;
    flex-shrink:0; display:inline-block;
}
.cat-count {
    margin-left:auto; font-size:11px;
    background:#eee; border-radius:20px; padding:1px 7px; color:#888;
}
.cat-item.active .cat-count { background:#d5ebd5; color:#1a6b2e; }

/* ── Search ──────────────────────────────────────────────────────── */
.search-wrap { position:relative; }
.search-wrap .fa-search {
    position:absolute; left:12px; top:50%; transform:translateY(-50%);
    color:#aaa; pointer-events:none; font-size:14px;
}
.search-wrap input { padding-left:36px; }

/* ── Animal grid ─────────────────────────────────────────────────── */
.animal-card {
    background:#fff; border:1px solid #e5e5e0; border-radius:12px;
    overflow:hidden; cursor:pointer;
    transition:transform .15s, box-shadow .15s, border-color .15s;
    animation:fadeUp .22s ease both;
}
.animal-card:hover  { transform:translateY(-2px); box-shadow:0 4px 18px rgba(0,0,0,.1); border-color:#ccc; }
.animal-card.active { border:2px solid #1a6b2e; }
@keyframes fadeUp { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

.card-thumb {
    width:100%; height:130px; object-fit:cover; display:block;
    background:#ececec; cursor:pointer;
}
.card-thumb-ph {
    width:100%; height:130px; background:#ececec;
    display:flex; align-items:center; justify-content:center;
    color:#bbb; font-size:13px;
}
.card-body-inner { padding:9px 11px 11px; }
.card-animal-name { font-weight:600; font-size:14px; color:#111; line-height:1.3; }
.card-cat-pill {
    display:inline-flex; align-items:center; gap:5px;
    font-size:11px; border-radius:20px; padding:2px 8px;
    margin-top:5px; font-weight:500; color:#fff;
}
.card-meta { font-size:11px; color:#bbb; margin-top:4px; }

/* ── Detail panel ────────────────────────────────────────────────── */
#detailPanel {
    background:#fff; border:1px solid #e5e5e0; border-radius:14px;
    padding:1.1rem; margin-bottom:1.25rem; display:none;
}
#detailPanel.show { display:block; animation:fadeUp .2s ease; }

/* Gallery */
.gallery-main {
    position:relative; width:100%; padding-top:60%;
    background:#ececec; border-radius:10px; overflow:hidden; cursor:pointer;
}
.gallery-main img {
    position:absolute; inset:0; width:100%; height:100%;
    object-fit:cover; border-radius:10px;
    transition:opacity .2s;
}
.gallery-main .no-img {
    position:absolute; inset:0; display:flex; flex-direction:column;
    align-items:center; justify-content:center;
    color:#ccc; font-size:13px; gap:6px;
}
.gallery-main .no-img i { font-size:28px; }

/* Gallery arrow buttons */
.gal-arrow {
    position:absolute; top:50%; transform:translateY(-50%);
    background:rgba(0,0,0,.35); border:none; color:#fff;
    width:34px; height:34px; border-radius:50%;
    font-size:13px; cursor:pointer; z-index:10;
    display:flex; align-items:center; justify-content:center;
    transition:background .15s; opacity:.8;
}
.gal-arrow:hover { background:rgba(0,0,0,.6); opacity:1; }
.gal-prev        { left:8px; }
.gal-next        { right:8px; }

.gallery-strip { display:flex; gap:6px; flex-wrap:wrap; margin-top:7px; }
.gallery-strip img {
    width:52px; height:52px; object-fit:cover;
    border-radius:7px; cursor:pointer;
    border:2px solid transparent; opacity:.65;
    transition:opacity .14s, border-color .14s;
    flex-shrink:0;
}
.gallery-strip img.active { opacity:1; border-color:#1a6b2e; }
.gallery-strip img:hover  { opacity:.9; }
.gallery-add-btn {
    width:52px; height:52px; border-radius:7px;
    border:1.5px dashed #ccc; background:none;
    cursor:pointer; color:#bbb; font-size:20px;
    display:flex; align-items:center; justify-content:center;
    transition:background .13s, border-color .13s; flex-shrink:0;
}
.gallery-add-btn:hover { background:#f0f0ec; border-color:#888; color:#666; }

/* Swipe hint on mobile */
.swipe-hint { font-size:11px; color:#bbb; text-align:center; margin-top:4px; display:none; }

/* ── Sound player ────────────────────────────────────────────────── */
.sound-row {
    display:flex; align-items:center; gap:10px;
    padding:8px 10px; background:#f8f8f6;
    border-radius:8px; margin-bottom:6px;
    border:1px solid #ececec; transition:border-color .13s, background .13s;
}
.sound-row-active { border-color:#1a6b2e !important; background:#f0f7f0 !important; }

.sound-controls { display:flex; gap:4px; flex-shrink:0; }

.snd-btn {
    width:30px; height:30px; border-radius:6px; border:none;
    background:#e8e8e4; color:#555; cursor:pointer; font-size:12px;
    display:flex; align-items:center; justify-content:center;
    transition:background .13s, color .13s; flex-shrink:0;
}
.snd-btn:hover          { background:#d8d8d2; color:#222; }
.snd-play.playing       { background:#1a6b2e; color:#fff; }
.snd-play.playing:hover { background:#155a24; }
.snd-loop.loop-on       { background:#3a7bd5; color:#fff; }
.snd-loop.loop-on:hover { background:#2e62b0; }

.sound-track-wrap   { flex:1; min-width:0; }
.sound-track-label  { font-size:13px; color:#333; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin-bottom:4px; }
.sound-progress-bar { height:4px; background:#ddd; border-radius:2px; overflow:hidden; }
.sound-progress-fill {
    height:100%; width:0%; background:#1a6b2e;
    border-radius:2px; transition:width .1s linear;
}

.sound-del-btn {
    background:none; border:none; cursor:pointer;
    color:#ccc; font-size:13px; padding:2px 4px; flex-shrink:0;
    transition:color .13s;
}
.sound-del-btn:hover { color:#b03030; }

/* ── Drop zone ───────────────────────────────────────────────────── */
.drop-zone {
    border:1.5px dashed #ccc; border-radius:8px; padding:1rem;
    text-align:center; cursor:pointer; color:#999; font-size:13px;
    transition:background .13s, border-color .13s;
}
.drop-zone:hover, .drop-zone.dragover { background:#eef5ee; border-color:#1a6b2e; color:#1a6b2e; }

/* ── Lightbox overlay ────────────────────────────────────────────── */
#lightbox {
    display:none; position:fixed; inset:0; z-index:2000;
    background:rgba(0,0,0,.93);
    flex-direction:column; align-items:center; justify-content:center;
    touch-action:pan-y;
}
#lightbox.show { display:flex; }
#lightbox img {
    max-width:96vw; max-height:88vh;
    object-fit:contain; border-radius:6px;
    user-select:none; -webkit-user-drag:none;
}
.lb-close {
    position:absolute; top:14px; right:18px;
    background:none; border:none; color:#fff;
    font-size:28px; cursor:pointer; line-height:1; opacity:.8;
}
.lb-close:hover { opacity:1; }
.lb-arrow {
    position:absolute; top:50%; transform:translateY(-50%);
    background:rgba(255,255,255,.12); border:none; color:#fff;
    font-size:22px; cursor:pointer; padding:14px 10px; border-radius:6px;
    transition:background .15s; line-height:1;
}
.lb-arrow:hover { background:rgba(255,255,255,.25); }
.lb-prev { left:10px; }
.lb-next { right:10px; }
.lb-counter {
    position:absolute; bottom:14px; left:50%; transform:translateX(-50%);
    color:#fff; font-size:12px; opacity:.6;
}
/* Swipe support */
.lb-dots {
    position:absolute; bottom:30px; left:50%; transform:translateX(-50%);
    display:flex; gap:6px;
}
.lb-dot { width:7px; height:7px; border-radius:50%; background:rgba(255,255,255,.35); }
.lb-dot.active { background:#fff; }

/* ── User badge ──────────────────────────────────────────────────── */
.user-badge {
    width:34px; height:34px; border-radius:50%; flex-shrink:0;
    display:inline-flex; align-items:center; justify-content:center;
    color:#fff; font-weight:700; font-size:14px;
}

/* ── Toast ────────────────────────────────────────────────────────── */
#toastContainer {
    position:fixed; bottom:1.2rem; right:1.2rem; z-index:3000;
    display:flex; flex-direction:column; gap:7px; pointer-events:none;
}
.toast-msg {
    background:#1a6b2e; color:#fff; padding:10px 16px;
    border-radius:9px; font-size:14px;
    box-shadow:0 3px 16px rgba(0,0,0,.2);
    opacity:0; transform:translateY(6px);
    transition:opacity .2s, transform .2s; pointer-events:none;
}
.toast-msg.show  { opacity:1; transform:translateY(0); }
.toast-msg.error { background:#b03030; }

/* ── Image preview in modal ──────────────────────────────────────── */
#imgPreview { display:none; }
#imgPreview.show { display:none; } /* legacy — no longer used */

#imgPreviewWrap { margin-top:10px; }

.img-preview-thumb-wrap {
    position:relative; display:inline-block; cursor:zoom-in;
    border-radius:8px; overflow:hidden;
    border:1px solid #ddd; line-height:0;
}
.img-preview-thumb-wrap img {
    display:block; max-width:100%; max-height:160px;
    object-fit:cover; border-radius:8px;
}
.img-preview-overlay {
    position:absolute; inset:0;
    background:rgba(0,0,0,0); display:flex;
    align-items:center; justify-content:center;
    color:#fff; font-size:20px; opacity:0;
    transition:opacity .15s, background .15s;
    border-radius:8px;
}
.img-preview-thumb-wrap:hover .img-preview-overlay {
    opacity:1; background:rgba(0,0,0,.35);
}
.img-preview-info {
    font-size:11px; color:#999; margin-top:5px;
    word-break:break-all;
}

/* ── Color picker swatch ─────────────────────────────────────────── */
.color-swatch {
    width:28px; height:28px; border-radius:50%; display:inline-block;
    border:2px solid rgba(0,0,0,.15); vertical-align:middle; cursor:pointer;
}

/* ── Groups page ─────────────────────────────────────────────────── */
.group-list-item {
    display:flex; align-items:center; gap:9px;
    padding:10px 1rem; cursor:pointer;
    border-left:3px solid transparent;
    transition:background .13s, color .13s;
    font-size:14px; color:#444;
    border-bottom:1px solid #f0f0ec;
}
.group-list-item:hover  { background:#f8f8f6; }
.group-list-item.active { background:#eef5ee; border-left-color:#1a6b2e; font-weight:600; color:#1a6b2e; }
.group-list-dot  { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.group-list-name { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.group-list-count { font-size:11px; background:#eee; border-radius:20px; padding:1px 7px; color:#888; flex-shrink:0; }
.group-list-item.active .group-list-count { background:#d5ebd5; color:#1a6b2e; }

.group-animal-row {
    display:flex; align-items:center; gap:10px;
    background:#fff; border:1px solid #e5e5e0; border-radius:10px;
    padding:8px 10px; margin-bottom:7px;
    cursor:default; transition:box-shadow .13s;
    user-select:none;
}
.group-animal-row[draggable="true"] { cursor:grab; }
.group-animal-row.dragging { opacity:.45; box-shadow:0 4px 16px rgba(0,0,0,.12); }
.group-animal-row.drag-over { border-color:#1a6b2e; background:#eef5ee; }

.group-drag-handle { color:#ccc; font-size:13px; flex-shrink:0; cursor:grab; }
.group-order-badge { font-size:11px; color:#aaa; width:18px; text-align:center; flex-shrink:0; font-weight:600; }
.group-animal-thumb {
    width:46px; height:46px; object-fit:cover; border-radius:7px;
    background:#ececec; flex-shrink:0; display:block;
}
.group-animal-thumb-ph {
    width:46px; height:46px; border-radius:7px; background:#ececec;
    display:flex; align-items:center; justify-content:center;
    color:#ccc; font-size:14px; flex-shrink:0;
}
.group-animal-info { flex:1; min-width:0; }
.group-cat-pill {
    display:inline-block; font-size:11px; border-radius:20px;
    padding:1px 7px; color:#fff; font-weight:500; margin-top:2px;
    white-space:nowrap;
}
.group-animal-del {
    background:none; border:none; cursor:pointer;
    color:#ccc; font-size:13px; padding:2px 4px; flex-shrink:0;
    transition:color .13s;
}
.group-animal-del:hover { color:#b03030; }

/* Picker */
.picker-row {
    display:flex; align-items:center; justify-content:space-between;
    padding:8px 10px; border-bottom:1px solid #f0f0ec; gap:8px;
}
.picker-row:last-child { border-bottom:none; }
.picker-row.already-in { opacity:.5; }
.picker-row-info { flex:1; min-width:0; display:flex; align-items:center; flex-wrap:wrap; gap:4px; }

/* ── Mobile overrides ────────────────────────────────────────────── */
@media (max-width:767px) {
    .sidebar { border-bottom:1px solid #e5e5e0; border-right:none; }
    .swipe-hint { display:block; }
    #detailPanel { padding:.85rem; }
    .lb-arrow { display:none; } /* swipe replaces arrows on mobile */
}

/* ── Desktop sidebar ─────────────────────────────────────────────── */
@media (min-width:768px) {
    .sidebar { border-right:1px solid #e5e5e0; border-bottom:none; min-height:calc(100vh - 48px); }
}

/* ════════════════════════════════════════════════════════════════════
   PRESENTATION MODE
   ════════════════════════════════════════════════════════════════════ */
#presentMode {
    position:fixed; inset:0; z-index:1500;
    background:#111;
    flex-direction:column;
    display:none; /* shown via JS style.display='flex' */
}

/* Top bar */
.pm-topbar {
    display:flex; align-items:center; justify-content:space-between;
    padding:.6rem 1rem; background:rgba(0,0,0,.5);
    flex-shrink:0; gap:12px;
}
.pm-group-name {
    font-size:14px; font-weight:600; color:#fff;
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.pm-counter { font-size:13px; color:rgba(255,255,255,.55); flex-shrink:0; }
.pm-close-btn {
    background:none; border:none; color:rgba(255,255,255,.7);
    font-size:20px; cursor:pointer; padding:4px 6px; line-height:1;
    flex-shrink:0; transition:color .15s;
}
.pm-close-btn:hover { color:#fff; }

/* Body */
.pm-body {
    flex:1; display:flex; align-items:center;
    overflow:hidden; position:relative; min-height:0;
}

/* Prev/next ANIMAL navigation */
.pm-nav {
    position:absolute; top:50%; transform:translateY(-50%);
    z-index:10; background:rgba(255,255,255,.1); border:none;
    color:#fff; width:40px; height:80px; border-radius:6px;
    font-size:18px; cursor:pointer; display:flex;
    align-items:center; justify-content:center;
    transition:background .15s; flex-shrink:0;
}
.pm-nav:hover   { background:rgba(255,255,255,.22); }
.pm-nav-prev    { left:6px; }
.pm-nav-next    { right:6px; }

/* Card */
.pm-card {
    flex:1; display:flex; gap:0; overflow:hidden;
    margin:0 52px;
    max-height:100%; min-height:0;
}

/* Gallery side — wider, image-focused */
.pm-gallery {
    width:55%; flex-shrink:0; display:flex; flex-direction:column;
    padding:.75rem .75rem .75rem 0; min-height:0;
}
.pm-gallery .gallery-main {
    flex:1; min-height:0;
    padding-top:0 !important;   /* override the 60% ratio used on index */
    border-radius:10px; overflow:hidden;
    display:flex; align-items:center; justify-content:center;
    background:#000;
}
/* Image fills height, not cropped */
.pm-gallery .gallery-main img {
    position:static !important; /* override absolute positioning from index */
    width:auto !important;
    height:100%;
    max-width:100%;
    max-height:100%;
    object-fit:contain !important;
    border-radius:0;
    display:block;
}
.pm-gallery .gallery-strip    { margin-top:6px; flex-shrink:0; }

/* Info side */
.pm-info {
    flex:1; min-width:0; overflow-y:auto; padding:.75rem 0 .75rem .75rem;
    display:flex; flex-direction:column; gap:.5rem;
}
.pm-animal-name {
    font-size:clamp(1.2rem,3.5vw,2rem); font-weight:700; color:#fff; line-height:1.2;
}
.pm-cat-pill {
    display:inline-block; font-size:12px; border-radius:20px;
    padding:3px 10px; color:#fff; font-weight:500; align-self:flex-start;
}
.pm-desc {
    font-size:14px; color:rgba(255,255,255,.7); line-height:1.65;
}
.pm-sounds-label {
    font-size:10px; font-weight:700; letter-spacing:.09em;
    text-transform:uppercase; color:rgba(255,255,255,.4);
}
/* Adapt sound rows for dark bg */
#pmSoundList .sound-row {
    background:rgba(255,255,255,.07); border-color:rgba(255,255,255,.1);
}
#pmSoundList .sound-row-active {
    background:rgba(26,107,46,.35) !important; border-color:#1a6b2e !important;
}
#pmSoundList .snd-btn        { background:rgba(255,255,255,.15); color:#ddd; }
#pmSoundList .snd-btn:hover  { background:rgba(255,255,255,.28); color:#fff; }
#pmSoundList .snd-play.playing { background:#1a6b2e; color:#fff; }
#pmSoundList .sound-track-label { color:rgba(255,255,255,.85); }
#pmSoundList .sound-progress-bar { background:rgba(255,255,255,.15); }

/* Dots */
.pm-dots {
    display:flex; justify-content:center; gap:6px;
    padding:.5rem; flex-shrink:0; flex-wrap:wrap;
}
.pm-dot {
    width:8px; height:8px; border-radius:50%;
    background:rgba(255,255,255,.25); cursor:pointer;
    transition:background .15s, transform .15s;
}
.pm-dot.active   { background:#fff; transform:scale(1.3); }
.pm-dot:hover    { background:rgba(255,255,255,.6); }

/* Lightbox inside presentation */
#pmLightbox {
    position:absolute; inset:0; z-index:20;
    background:rgba(0,0,0,.95);
    flex-direction:column; align-items:center; justify-content:center;
}
#pmLightbox img {
    max-width:96vw; max-height:58vh;
    object-fit:contain; border-radius:6px;
    margin-bottom:.5rem;
}
/* Sound panel at bottom of lightbox overlay */
.pm-lb-sounds {
    position:absolute; bottom:0; left:0; right:0;
    padding:.6rem 1rem .75rem;
    margin-top:.75rem;
    background:linear-gradient(to top, rgba(0,0,0,.88) 80%, transparent);
    display:flex; flex-wrap:wrap; gap:6px; justify-content:center;
    max-height:40vh; overflow-y:auto;
}
.pm-lb-sounds .sound-row {
    background:rgba(255,255,255,.08); border-color:rgba(255,255,255,.12);
    min-width:200px; flex:1; max-width:340px;
}
.pm-lb-sounds .sound-row-active {
    background:rgba(26,107,46,.35) !important; border-color:#1a6b2e !important;
}
.pm-lb-sounds .snd-btn        { background:rgba(255,255,255,.15); color:#ddd; }
.pm-lb-sounds .snd-btn:hover  { background:rgba(255,255,255,.28); color:#fff; }
.pm-lb-sounds .snd-play.playing { background:#1a6b2e; color:#fff; }
.pm-lb-sounds .sound-track-label { color:rgba(255,255,255,.85); }
.pm-lb-sounds .sound-progress-bar { background:rgba(255,255,255,.15); }

/* Mobile presentation */
@media (max-width:650px) {
    .pm-card       { flex-direction:column; margin:0; overflow-y:auto; padding:0 .75rem; }
    .pm-gallery    { width:100%; padding:0; flex-shrink:0; height:55vw; min-height:200px; }
    .pm-gallery .gallery-main { height:100%; border-radius:8px; }
    .pm-info       { padding:.5rem 0; }
    .pm-nav        { top:auto; bottom:60px; transform:none; height:44px; width:44px; border-radius:50%; }
    .pm-nav-prev   { left:8px; }
    .pm-nav-next   { right:8px; }
    .pm-animal-name { font-size:1.25rem; }
}