/* ============================================================
   گالری Masonry + Float
   نسخه سبک و اصلاح‌شده برای موبایل
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  background: #0f0f0f;
  color: #fff;
  font-family: Tahoma, Arial, sans-serif;
  font-size: 14px;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: 80px;
}

img {
  display: block;
  max-width: 100%;
  border: 0;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ============ هدر ============ */

.gallery-header {
  background: #141414;
  border-bottom: 1px solid #222;
  padding: 10px 12px 0;
  position: relative;
  z-index: 10;
}

.header-top {
  padding-bottom: 10px;
  overflow: hidden;
}

.header-top h1 {
  float: right;
  font-size: 18px;
  font-weight: bold;
  color: #ffd93d;
  line-height: 30px;
}

.progress-info {
  float: left;
  line-height: 30px;
}

#progressText {
  font-size: 12px;
  color: #ccc;
  margin-left: 8px;
  vertical-align: middle;
}

.refresh-all-btn {
  display: none;
  padding: 4px 10px;
  background: #ff4757;
  color: #fff;
  border: 0;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}

.refresh-all-btn.visible {
  display: inline-block;
}

.progress-bar {
  height: 4px;
  background: #222;
  overflow: hidden;
  clear: both;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #ffd93d;
}

/* ============ نوار ابزار ============ */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
  direction: rtl;
}

.toolbar-label {
  font-size: 12px;
  color: #bbb;
  white-space: nowrap;
}

/* ============ گالری ============ */

.masonry {
  display: block;
  position: relative;
  width: 100%;
  padding: 0;
  margin: 0;
  direction: rtl;
  overflow: visible;
  font-size: 0;
  line-height: 0;
}

.item {
  position: absolute;
  display: block;
  float: none;
  width: calc(100% / var(--gallery-columns, 4));
  max-width: calc(100% / var(--gallery-columns, 4));
  margin: 0;
  padding: 0;
  border: 0;
  background: #1a1a1a;
  overflow: visible;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
  z-index: 1;
}

.item:hover,
.item:active,
.item.active {
  z-index: 50;
}

.item img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  background: #2a2a2a;
  object-fit: contain;
}

/* ============ دکمه‌های روی عکس ============ */

.item > div > button,
.item > button {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  min-height: 42px !important;
  margin: 0 !important;
  padding: 10px 5px !important;
  border: 0 !important;
  border-radius: 0 !important;
  font-family: inherit !important;
  font-size: 13px !important;
  font-weight: bold !important;
  cursor: pointer !important;
  text-align: center !important;
  opacity: 1 !important;
  vertical-align: top !important;
  line-height: 1.5 !important;
  box-sizing: border-box !important;
}

.item > div:first-child {
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 0 !important;
  font-size: 0 !important;
}

/* ============ لایه روی عکس ============ */

.overlay {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  padding: 0;
  text-align: center;
  overflow: visible;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  box-sizing: border-box;
  z-index: 10;
}

.item:hover .overlay,
.item:active .overlay,
.item.active .overlay {
  display: flex;
}

.overlay-content {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  text-align: center;
  overflow: visible;
}

/* دکمه‌های داخل overlay */

.overlay-content button,
.overlay-content .overlay-btn {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  min-height: 44px !important;
  margin: 0 !important;
  padding: 10px 5px !important;
  border: 0 !important;
  border-radius: 0 !important;
  font-family: inherit !important;
  font-size: 13px !important;
  font-weight: bold !important;
  cursor: pointer !important;
  text-align: center !important;
  opacity: 0.85 !important;
  vertical-align: top !important;
  line-height: 1.5 !important;
  white-space: normal !important;
  overflow-wrap: break-word !important;
  box-sizing: border-box !important;
  text-shadow: 0 1px 1px rgba(255,255,255,0.3) !important;
}

.overlay-content button:hover,
.overlay-content .overlay-btn:hover {
  opacity: 1 !important;
}

.item:hover > div > button,
.item:active > div > button,
.item.active > div > button,
.item:hover > button,
.item:active > button,
.item.active > button {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* ============ متن‌های روی عکس ============ */

.overlay-content h3,
.overlay-content h4 {
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  line-height: 1.5;
  margin: 6px;
  padding: 0;
  overflow-wrap: break-word;
  text-align: right;
}

.overlay-content p {
  color: #e8e8e8;
  font-size: 12px;
  line-height: 1.5;
  margin: 5px 6px;
  padding: 0;
  overflow-wrap: break-word;
}

/* ============ دکمه شناور ============ */

.floating-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  min-width: 130px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #ff4757, #ff6b6b);
  color: #fff;
  border-radius: 50px;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(255,71,87,0.5);
  transition: transform 0.2s ease;
  user-select: none;
  line-height: 1.4;
}

.floating-btn:hover {
  transform: translateY(-3px);
}

.floating-btn:active {
  transform: translateY(-1px) scale(0.98);
}

.floating-text {
  display: block;
  white-space: nowrap;
}

/* ============ زوم گالری ============ */

.gallery-zoom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  direction: ltr;
  padding: 10px;
  background: #1a1a1a;
  border-radius: 10px;
}

.gallery-zoom button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 7px;
  background: #ffd93d;
  color: #111;
  font-size: 22px;
  cursor: pointer;
}

.gallery-zoom input {
  width: 130px;
  accent-color: #ffd93d;
  cursor: pointer;
}

#zoomLabel {
  color: #ffd93d;
  font-size: 13px;
  min-width: 45px;
  text-align: center;
}

/* ============ آیکن پخش ============ */

.play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  border: 2px solid #fff;
  color: #fff;
  font-size: 14px;
  line-height: 36px;
  text-align: center;
  z-index: 2;
}

/* ============ خطای تصویر ============ */

.item.error {
  background: #222;
  min-height: 120px;
}

.item .item-refresh-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  margin: -18px 0 0 -40px;
  padding: 10px 5px;
  background: #ff4757;
  color: #fff;
  border: 0;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  z-index: 5;
}

/* ============ تنظیمات عمومی ============ */

button {
  font-family: inherit;
}

a {
  color: #6A5ACD;
}

details {
  max-width: 600px;
  margin: auto;
}

summary {
  background: #222;
  color: white;
  font-size: 16px;
  position: relative;
  border: 1px solid #00ff0e;
}

summary::marker {
  display: none;
}

summary::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -12px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid #666;
}

details[open] summary {
  display: none;
}

/* ============ ویدئو ============ */

.video-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  margin: 0;
  border-radius: 0;
  max-width: none;
}

/* ============ تلگرام ============ */

.telegram-button {
  background: #14114f;
  color: white;
  border: none;
  border-radius: 18px;
  font-weight: 500;
  cursor: pointer;
  align-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.telegram-button:hover {
  background: #2B97E8;
}

/* ============ متن روی تصویر ============ */

.textco {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  width: 100%;
  z-index: 2;
  color: white;
}

#editimagetext {
  display: inline-block;
  border: 1px solid #000;
}

/* ============ پنجره پاپ‌آپ ============ */

.hover_bkgr_fricc {
  direction: rtl;
  unicode-bidi: plaintext;
  background: rgba(0,0,0,0.4);
  cursor: pointer;
  display: none;
  height: 100%;
  position: fixed;
  text-align: center;
  top: 0;
  width: 100%;
  z-index: 10000;
  overflow: auto;
}

.hover_bkgr_fricc .helper {
  display: inline-block;
  height: 100%;
  vertical-align: middle;
}

.hover_bkgr_fricc > div {
  background: #110707;
  box-shadow: 10px 10px 60px #0e00c7;
  display: inline-block;
  height: auto;
  max-width: 551px;
  min-height: 100px;
  vertical-align: middle;
  width: 90%;
  position: relative;
  border-radius: 8px;
  padding: 15px 5%;
}

.popupCloseButton {
  background: #fff;
  border: 3px solid #999;
  border-radius: 50px;
  cursor: pointer;
  display: inline-block;
  font-family: Arial;
  font-weight: bold;
  position: absolute;
  top: -20px;
  right: -20px;
  font-size: 25px;
  line-height: 30px;
  width: 50px;
  height: 50px;
  text-align: center;
}

.popupCloseButton:hover {
  background: #ccc;
}

/* ============ ورودی‌ها ============ */

.input-group {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  width: 100%;
}

/* ============ منوی کشویی ============ */

.dropdown {
  position: relative;
}

.dropdown-content {
  display: none;
  color: black;
  width: 100%;
  position: absolute;
  background: #f1f1f1;
  min-width: 160px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  z-index: 100;
}

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  display: block;
  border: 1px dashed;
}

.dropdown:hover .dropdown-content {
  display: block;
}

/* ============ پاپ‌آپ تصویر ============ */

.popup {
  position: relative;
  display: inline-block;
  cursor: pointer;
  user-select: none;
}

.popupimage {
  visibility: hidden;
  width: 160px;
  background: #555;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 8px 0;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -80px;
}

.popupimage::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #555 transparent transparent transparent;
}

.show {
  visibility: visible;
  animation: fadeIn 1s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============ تصویر سیاه و سفید ============ */

.blk img {
  filter: grayscale(100%);
}

/* ============================================================
   تنظیمات موبایل
   ============================================================ */

@media (max-width: 600px) {

  .toolbar {
    padding: 10px 8px;
    gap: 6px;
  }

  .toolbar-label {
    font-size: 11px;
  }

  .header-top h1 {
    font-size: 14px;
  }

  #progressText {
    font-size: 11px;
  }

  /* دکمه‌های داخل عکس در موبایل */

  .overlay-content button,
  .overlay-content .overlay-btn,
  .item > div > button,
  .item > button {
    min-height: 48px !important;
    padding: 12px 6px !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
  }

  .overlay-content h3,
  .overlay-content h4 {
    font-size: 12px;
  }

  .overlay-content p {
    font-size: 11px;
  }

  .floating-btn {
    bottom: 15px;
    right: 15px;
    min-width: 110px;
    padding: 10px 14px;
    font-size: 12px;
    border-radius: 40px;
  }

  .play-icon {
    width: 32px;
    height: 32px;
    margin: -16px;
    font-size: 11px;
    line-height: 28px;
  }
}

/* موبایل‌های خیلی کوچک */

@media (max-width: 360px) {

  .overlay-content button,
  .overlay-content .overlay-btn,
  .item > div > button,
  .item > button {
    min-height: 52px !important;
    padding: 13px 5px !important;
    font-size: 12px !important;
  }
}

/* =========================================
   جلوگیری از خروج افقی متن از کارت Masonry
   اجازه خروج عمودی متن از پایین عکس
   ========================================= */

.item {
    overflow: visible !important;
    min-width: 0 !important;
}

.overlay {
    overflow: visible !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.overlay h3,
.overlay h4,
.overlay p,
.overlay-content h3,
.overlay-content h4,
.overlay-content p {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    white-space: normal !important;

    overflow-wrap: anywhere !important;
    word-wrap: break-word !important;
    word-break: normal !important;

    box-sizing: border-box !important;
    text-align: right;
}

/* جلوگیری از خروج لینک‌های طولانی */
.overlay a,
.overlay-content a,
.item a {
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-all !important;
}