/* Modal – spójny, nowoczesny wygląd (ciemny + akcent motywu) */

.modal{
  position:fixed;
  inset:0;
  z-index:9999;
  display:none;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:transparent;
  border:0;
  outline:0;
}

.modal.is-open,
.modal.open,
.modal[aria-hidden="false"]{display:flex}

.modal-backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0.42);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  animation:modalFadeIn .14s ease-out both;
}

.modal-card{
  position:relative;
  width:min(1100px, calc(100vw - 48px));
  max-height:calc(100vh - 48px);
  overflow:hidden;
  border-radius:18px;
  border:1px solid color-mix(in srgb, var(--accent) 18%, rgba(255,255,255,0.10));
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%),
    linear-gradient(180deg, rgba(12,16,24,0.96) 0%, rgba(12,16,24,0.90) 100%);
  box-shadow:0 26px 78px rgba(0,0,0,0.72);
  animation:modalCardIn .16s ease-out both;
}

.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  border-bottom:1px solid rgba(255,255,255,0.08);
  background:rgba(255,255,255,0.02);
}

.modal-title{font-weight:950;font-size:13px;letter-spacing:.02em;color:rgba(255,255,255,0.92)}

.modal-body{
  padding:14px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:radial-gradient(60% 60% at 50% 40%, rgba(255,255,255,0.02) 0%, transparent 70%);
}

.modal-body img{
  display:block;
  max-width:100%;
  max-height:calc(100vh - 170px);
  width:auto;
  height:auto;
  border-radius:16px;
  background:rgba(0,0,0,0.28);
  border:1px solid rgba(255,255,255,0.10);
  object-fit:contain;
}

body.modal-open{overflow:hidden}

@keyframes modalFadeIn{from{opacity:0}to{opacity:1}}
@keyframes modalCardIn{from{opacity:0;transform:translateY(10px) scale(0.985)}to{opacity:1;transform:translateY(0) scale(1)}}

@media (max-width: 520px){
  .modal{padding:12px}
  .modal-card{width:calc(100vw - 24px);max-height:calc(100vh - 24px)}
  .modal-body img{max-height:calc(100vh - 150px)}
}

/* ===== Wspólna galeria zdjęć ===== */
.gallery-modal .modal-card{
  width:min(1280px, calc(100vw - 32px));
}

.gallery-modal .modal-body{
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  gap:12px;
}

.gallery-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  width:100%;
}

.gallery-counter{
  color:rgba(255,255,255,0.68);
  font-size:12px;
  white-space:nowrap;
}

.gallery-stage{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:min(72vh, 760px);
  width:100%;
  touch-action:pan-y pinch-zoom;
}

.gallery-stage img{
  display:block;
  max-width:100%;
  max-height:calc(100vh - 220px);
  width:auto;
  height:auto;
  border-radius:16px;
  background:rgba(0,0,0,0.28);
  border:1px solid rgba(255,255,255,0.10);
  object-fit:contain;
}

.gallery-nav{
  position:absolute;
  top:50%;
  transform:translateY(-50%);
  width:44px;
  height:44px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(255,255,255,0.14);
  background:rgba(11,16,24,0.72);
  color:#fff;
  font-size:22px;
  line-height:1;
  cursor:pointer;
  transition:transform .08s ease, background .12s ease, border-color .12s ease, opacity .12s ease;
}

.gallery-nav:hover{
  background:rgba(21,28,40,0.88);
  border-color:color-mix(in srgb, var(--accent) 28%, rgba(255,255,255,0.12));
}

.gallery-nav:active{transform:translateY(-50%) scale(0.98)}
.gallery-nav[disabled]{opacity:.35;cursor:default}
.gallery-nav.prev{left:10px}
.gallery-nav.next{right:10px}

.gallery-thumbs{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:center;
  overflow-x:auto;
  padding:12px 2px 8px;
  margin-top:10px;
  width:100%;
  max-width:min(100%, 900px);
  margin-left:auto;
  margin-right:auto;
  scrollbar-width:thin;
}

.gallery-thumbs::-webkit-scrollbar{
  height:8px;
}

.gallery-thumbs::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,0.16);
  border-radius:999px;
}

.gallery-thumb{
  flex:0 0 auto;
  width:74px;
  height:74px;
  padding:0;
  border-radius:14px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.04);
  cursor:pointer;
  transition:border-color .12s ease, transform .08s ease, box-shadow .12s ease, opacity .12s ease;
}

.gallery-thumb:hover{
  border-color:color-mix(in srgb, var(--accent) 32%, rgba(255,255,255,0.14));
}

.gallery-thumb:active{
  transform:scale(0.98);
}

.gallery-thumb.is-active{
  border-color:var(--accent);
  box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 26%, transparent);
}

.gallery-thumb img{
  display:block;
  width:100%;
  height:100%;
  object-fit:contain;
  background:rgba(0,0,0,0.18);
  padding:4px;
}

/* ===== Modal przycinania zdjęcia (dodawanie/edycja) ===== */
.crop-wrap{display:flex;flex-direction:column;gap:10px;width:100%}
.crop-canvas{display:block;max-width:100%;max-height:70vh;border:1px solid color-mix(in srgb, var(--accent) 20%, rgba(255,255,255,0.10));border-radius:16px;background:#000;touch-action:none;user-select:none}
.crop-hint{color:rgba(255,255,255,0.70);font-size:12px;line-height:1.35}
.crop-actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:flex-end}

@media (max-width: 520px){
  .crop-actions{justify-content:stretch}
  .crop-actions .btn{flex:1 1 140px}
}

/* ===== Galeria zdjęć napraw ===== */
.repair-gallery-modal .modal-card{
  width:min(1280px, calc(100vw - 32px));
}

.repair-gallery-modal .modal-body{
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  gap:12px;
}

.repair-gallery-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  width:100%;
}

.repair-gallery-counter{
  color:rgba(255,255,255,0.68);
  font-size:12px;
  white-space:nowrap;
}

.repair-gallery-stage{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:min(72vh, 760px);
  width:100%;
  touch-action:pan-y pinch-zoom;
}

.repair-gallery-stage img{
  display:block;
  max-width:100%;
  max-height:calc(100vh - 220px);
  width:auto;
  height:auto;
  border-radius:16px;
  background:rgba(0,0,0,0.28);
  border:1px solid rgba(255,255,255,0.10);
  object-fit:contain;
}

.repair-gallery-nav{
  position:absolute;
  top:50%;
  transform:translateY(-50%);
  width:44px;
  height:44px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(255,255,255,0.14);
  background:rgba(11,16,24,0.72);
  color:#fff;
  font-size:22px;
  line-height:1;
  cursor:pointer;
  transition:transform .08s ease, background .12s ease, border-color .12s ease, opacity .12s ease;
}

.repair-gallery-nav:hover{
  background:rgba(21,28,40,0.88);
  border-color:color-mix(in srgb, var(--accent) 28%, rgba(255,255,255,0.12));
}

.repair-gallery-nav:active{transform:translateY(-50%) scale(0.98)}
.repair-gallery-nav[disabled]{opacity:.35;cursor:default}
.repair-gallery-nav.prev{left:10px}
.repair-gallery-nav.next{right:10px}

.repair-gallery-thumbs{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:center;
  overflow-x:auto;
  padding:12px 2px 2px;
  margin-top:10px;
  width:100%;
  max-width:min(100%, 900px);
  margin-left:auto;
  margin-right:auto;
  scrollbar-width:thin;
}

.repair-gallery-thumbs::-webkit-scrollbar{
  height:8px;
}

.repair-gallery-thumbs::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,0.16);
  border-radius:999px;
}

.repair-gallery-thumb{
  flex:0 0 auto;
  width:74px;
  height:74px;
  padding:0;
  border-radius:14px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.04);
  cursor:pointer;
  transition:border-color .12s ease, transform .08s ease, box-shadow .12s ease, opacity .12s ease;
}

.repair-gallery-thumb:hover{
  border-color:color-mix(in srgb, var(--accent) 32%, rgba(255,255,255,0.14));
}

.repair-gallery-thumb:active{
  transform:scale(0.98);
}

.repair-gallery-thumb.is-active{
  border-color:var(--accent);
  box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 26%, transparent);
}

.repair-gallery-thumb img{
  display:block;
  width:100%;
  height:100%;
  object-fit:contain;
  background:rgba(0,0,0,0.18);
  padding:4px;
}

.repair-gallery-open{
  white-space:nowrap;
}

@media (max-width: 700px){
  .gallery-modal .modal{
    padding:10px;
  }
  .gallery-modal .modal-card{
    width:calc(100vw - 20px);
    max-height:calc(100vh - 20px);
  }
  .gallery-stage{
    min-height:min(64vh, 580px);
  }
  .gallery-stage img{
    max-height:calc(100vh - 210px);
  }
  .gallery-thumbs{
    gap:8px;
    margin-top:8px;
    max-width:100%;
  }
  .gallery-thumb{
    width:62px;
    height:62px;
    border-radius:12px;
  }
  .gallery-nav{
    width:40px;
    height:40px;
    font-size:20px;
  }

  .repair-gallery-modal .modal{
    padding:10px;
  }
  .repair-gallery-modal .modal-card{
    width:calc(100vw - 20px);
    max-height:calc(100vh - 20px);
  }
  .repair-gallery-stage{
    min-height:min(64vh, 580px);
  }
  .repair-gallery-stage img{
    max-height:calc(100vh - 210px);
  }
  .repair-gallery-thumbs{
    gap:8px;
    margin-top:8px;
    max-width:100%;
  }
  .repair-gallery-thumb{
    width:62px;
    height:62px;
    border-radius:12px;
  }
  .repair-gallery-nav{
    width:40px;
    height:40px;
    font-size:20px;
  }
}
