/* ============================================================
   RESPONSIVE.CSS — اصلاحات ریسپانسیو (باید آخرین CSS لود‌شده باشد)
   اصل کار: ظاهر دسکتاپ و تم‌ها دست‌نخورده می‌ماند؛
   فقط جاهایی که چیدمان خراب می‌شد اصلاح شده.
   ============================================================ */

/* ---------- پایه ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, video, svg, canvas { max-width: 100%; }
iframe { max-width: 100%; }
.card-body h3, .job-card h3, .alert, .file-detail h1, .file-detail h2 { overflow-wrap: anywhere; }
.admin-table td, .admin-table th { overflow-wrap: break-word; }
pre, code { max-width: 100%; }
pre { overflow-x: auto; }

/* آیتم‌هایی که فقط داخل منوی موبایل دیده می‌شوند */
.nav-sm-only { display: none; }
.nav-socials { display: none; }

/* ============================================================
   HEADER — دسکتاپ و لپ‌تاپ (بالای 1180px)
   ============================================================ */

/* ستون‌های کناری هیچ‌وقت کوچکتر از محتوای خودشان نمی‌شوند (قبلاً روی منوی وسط می‌افتادند).
   وقتی جا هست، همان سه‌ستون هم‌عرض قبلی می‌ماند. */
.site-header .container.header-inner {
  gap: 12px;
  grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
}
.header-right, .header-left { min-width: 0; }
.main-nav { white-space: nowrap; }

/* کاربر لاگین‌کرده: دکمه‌های بیشتری در هدر هست، پس کانتینر کمی پهن‌تر */
.site-header.is-auth .container.header-inner { max-width: 1680px; }

/* نام کاربر زیادی بلند نشود */
.header-actions .btn.user-btn { max-width: 150px; }
.header-actions .btn.user-btn .btn-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1680px) {
  .site-header.is-auth .header-actions .btn.admin-btn .btn-text { display: none; }
  .site-header.is-auth .header-actions .btn.admin-btn {
    padding-inline: 8px; width: 36px; justify-content: center;
  }
}

@media (max-width: 1440px) {
  .main-nav a { padding: 8px 9px; font-size: 13.5px; }
  .site-header .container.header-inner { padding-inline: 20px; }
  .brand { margin-inline-start: 12px; }
  .site-header.is-auth .header-actions .btn.user-btn .btn-text { display: none; }
  .site-header.is-auth .header-actions .btn.user-btn {
    padding-inline: 8px; width: 36px; justify-content: center;
  }
}

/* اسم «pigy» کنار لوگو در حالت دسکتاپ همیشه نمایش داده می‌شود
   (قبلاً زیر 1280px توسط style.css/components.css مخفی می‌شد) */
@media (min-width: 1181px) {
  .header-right .brand > span:not(.brand-icon) { display: inline; }
}

/* لپ‌تاپ‌ها (1181–1440px): سوشال‌ها و اسم‌ها می‌مانند؛ دکمه‌های ورود/ثبت‌نام آیکونی
   و منوی وسط کمی فشرده می‌شود تا همه‌چیز جا شود */
@media (min-width: 1181px) and (max-width: 1440px) {
  .site-header .container.header-inner { padding-inline: 14px; gap: 8px; }
  .brand { margin-inline-start: 8px; }
  .header-right { gap: 8px; }
  .header-left { gap: 8px; }
  .header-actions { gap: 4px; }
  .main-nav { gap: 2px; }
  .main-nav a { padding: 8px 7px; font-size: 13px; }
  .main-nav a.nav-highlight { padding: 6px 10px; }
  .header-actions .btn .btn-text { display: none; }
  .header-actions .btn { padding-inline: 8px; width: 36px; justify-content: center; }
}

/* ادمین/کاربر لاگین در ابتدای بازه‌ی لپ‌تاپ: آیکون جستجو جا را آزاد می‌کند */
@media (min-width: 1181px) and (max-width: 1260px) {
  .site-header.is-auth .header-actions .icon-btn[aria-label="جستجو"] { display: none; }
}

/* نام طراح (VivoWeb) در همه‌ی عرض‌ها داخل هدر دیده می‌شود؛
   فقط برچسب کوچک «طراح سایت» در عرض‌های کم حذف می‌شود */
.header-designer .designer-text { display: flex; }
.header-designer .designer-name { white-space: nowrap; }
@media (max-width: 1300px) {
  .header-designer .designer-label { display: none; }
  .header-designer { padding: 6px 10px; }
}
@media (max-width: 640px) {
  .header-designer { padding: 4px 7px; gap: 5px; }
  .header-designer img { width: 20px; height: 20px; }
  .header-designer .designer-name { font-size: 12px; }
}
@media (max-width: 360px) {
  .header-designer { padding: 4px 5px; gap: 4px; }
  .header-designer .designer-name { font-size: 11px; }
}

/* سوشال‌ها: راست‌ترین بخش هدر، همیشه (جز گوشی‌های باریک) */
.header-socials { display: flex; }

/* ============================================================
   HEADER — تبلت و موبایل (تا 1180px): منوی همبرگری
   ============================================================ */
@media (max-width: 1180px) {
  .site-header .container.header-inner {
    display: flex;
    justify-content: space-between;
    padding-inline: 14px;
    gap: 8px;
  }
  .brand { margin-inline-start: 0; }
  .header-right { gap: 10px; flex: 0 1 auto; }
  .header-left  { gap: 6px;  flex: 0 1 auto; }

  .mobile-menu-btn { display: inline-flex; }

  .main-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    width: auto;
    justify-self: stretch;     /* قبلاً center بود و دراور را باریک می‌کرد */
    justify-content: flex-start;
    align-items: stretch;
    background: var(--bg-1);
    flex-direction: column;
    flex: none;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    transform: translateY(-120%);
    visibility: hidden;
    transition: transform .3s ease, visibility 0s linear .3s;
    max-height: calc(100vh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    gap: 4px;
    margin: 0;
    z-index: 99;
    white-space: normal;
  }
  .main-nav.open {
    transform: translateY(0);
    visibility: visible;
    transition: transform .3s ease, visibility 0s;
  }
  .main-nav a { padding: 13px 16px; font-size: 15px; }
  .main-nav a.nav-highlight {
    background: none; border: none; box-shadow: none;
    padding: 13px 16px;
    color: var(--accent-light, #fbbf24);
    font-weight: 700;
  }
  .main-nav a.nav-highlight::before { display: none; }

  /* در این بازه دکمه‌ی ورود و دکمه‌ها همچنان آیکونی در هدر می‌مانند */
  .header-actions .btn-ghost { display: inline-flex; }
  .header-actions .btn .btn-text { display: none; }
  .header-actions .btn {
    padding-inline: 8px; width: 36px; justify-content: center;
  }
  .header-actions .btn.user-btn { max-width: none; }

  .nav-sep {
    display: block; height: 1px; margin: 6px 0;
    background: var(--border);
  }

  /* منوی تم همیشه داخل صفحه بماند */
  .theme-switcher { position: static; }
  .theme-menu {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-start: 14px;
    inset-inline-end: auto;
    width: min(220px, calc(100vw - 28px));
    min-width: 0;
    max-width: calc(100vw - 28px);
    box-sizing: border-box;
  }
}

/* موبایل: فقط چیزهای ضروری در هدر؛ بقیه داخل منو */
@media (max-width: 640px) {
  .nav-sm-only { display: block; }
  .nav-sep.nav-sm-only { display: block; }
  .hide-sm { display: none !important; }

  .site-header .container.header-inner { padding-inline: 12px; }
  .header-right { gap: 6px; }
  .header-socials { gap: 3px; }
  .header-socials a { width: 26px; height: 26px; border-radius: 7px; }
  .header-socials a img { width: 15px; height: 15px; }
  .header-actions { gap: 4px; }
  .theme-btn-text { display: none; }
  .theme-btn { padding-inline: 8px; }
  .brand-icon, .brand-icon img { width: 36px; height: 36px; }
}

@media (max-width: 360px) {
  .site-header .container.header-inner { padding-inline: 10px; gap: 4px; }
  .header-right { gap: 6px; }
  .brand-icon, .brand-icon img { width: 32px; height: 32px; }
  .icon-btn { width: 36px; height: 36px; }
}

/* ============================================================
   ADMIN — پنل مدیریت
   ============================================================ */
.admin-layout { grid-template-columns: 240px minmax(0, 1fr); }
.admin-content { min-width: 0; }
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-nav a { flex-shrink: 0; }

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .admin-sidebar.card { padding: 10px !important; }
  .admin-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .admin-nav a {
    white-space: nowrap;
    padding: 9px 12px;
    border: 1px solid var(--border);
    background: var(--bg-2);
  }
  .admin-nav a.active { border-inline-start-width: 1px; border-color: var(--primary); }

  /* جدول‌ها: اسکرول افقی داخل خود جدول، نه کل صفحه */
  .admin-table { min-width: 600px; }
  .admin-table th, .admin-table td { padding: 9px 10px; }
  .admin-table td[style*="display:flex"] {
    display: table-cell !important;
    white-space: nowrap;
  }
  .admin-table td[style*="display:flex"] > * {
    display: inline-block;
    margin: 0 0 4px 6px;
    vertical-align: middle;
  }

  /* فرم‌های چندستونه‌ی inline */
  form[style*="grid-template-columns:2fr"],
  form[style*="grid-template-columns:1fr 1fr 100px"] {
    grid-template-columns: 1fr 1fr !important;
  }
  form[style*="grid-template-columns:2fr"] > .btn,
  form[style*="grid-template-columns:2fr"] > button,
  form[style*="grid-template-columns:1fr 1fr 100px"] > .btn,
  form[style*="grid-template-columns:1fr 1fr 100px"] > button {
    grid-column: 1 / -1;
  }

  /* صفحه‌ی جزئیات فایل (عمومی) */
  .file-detail { grid-template-columns: minmax(0, 1fr) !important; gap: 20px !important; }
}

@media (max-width: 640px) {
  .admin-content h1, .admin-layout + h1, section h1 { font-size: 20px; }
  .admin-content .card[style*="padding:24px"],
  form.card[style*="padding:24px"] { padding: 16px !important; }
  .admin-content .card[style*="padding:20px"] { padding: 14px !important; }

  /* فرم‌های فیلتر/جستجو */
  .admin-content form[style*="flex-wrap"] > input,
  .admin-content form[style*="flex-wrap"] > select,
  .admin-content form[style*="flex-wrap"] > .field {
    flex: 1 1 100%;
    min-width: 0;
  }
  .admin-content form[style*="flex-wrap"] > .btn,
  .admin-content form[style*="flex-wrap"] > button { flex: 1 1 auto; }

  /* درخواست‌ها: دکمه‌های عملیات */
  .admin-content [style*="display:flex"][style*="flex-wrap"] > .btn { flex: 1 1 auto; }

  /* فرم‌های ۲ ستونه → تک‌ستونه */
  form[style*="grid-template-columns:2fr"],
  form[style*="grid-template-columns:1fr 1fr 100px"],
  div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .admin-table { min-width: 520px; font-size: 13px; }
}

/* ============================================================
   صفحات عمومی (فرم‌ها، ثبت‌نام، استخدام ...)
   ============================================================ */
@media (max-width: 560px) {
  div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  .container[style*="max-width"] { padding-inline: 14px; }
  .field input, .field select, .field textarea { font-size: 16px; } /* جلوگیری از زوم iOS */
  .auth-card { padding-inline: 18px; }
  .container > .card[style*="padding:32px"] { padding: 22px 18px !important; }
  .container > .card div[style*="display:flex"][style*="gap:12px"] { flex-wrap: wrap; }
  .container > .card div[style*="display:flex"][style*="gap:12px"] > * { flex: 1 1 140px; }
  .footer-bottom .container { text-align: center; }
}

/* سطل تعاملی روی موبایل جلوی محتوا را نگیرد */
@media (max-width: 640px) {
  .bucket { bottom: 10px; left: 10px; opacity: .92; }
}

/* دسترسی‌پذیری */
@media (max-width: 1180px) {
  .main-nav a, .icon-btn, .btn { -webkit-tap-highlight-color: transparent; }
}

/* گوشی‌ها (≤480px): فشرده‌سازی هدر — باید بعد از بلوک‌های 640/1180 بیاید */
@media (max-width: 480px) {
  .site-header .container.header-inner { padding-inline: 10px; gap: 4px; }
  .header-socials { gap: 3px; }
  .header-socials a { width: 24px; height: 24px; border-radius: 6px; }
  .header-socials a img { width: 14px; height: 14px; }
  .header-right { gap: 5px; }
  .header-left { gap: 4px; }
  .header-actions { gap: 2px; }
  .site-header .header-actions .btn { width: 32px; height: 32px; padding-inline: 6px; }
  .site-header .header-actions .icon-btn { width: 34px; height: 34px; }
  .theme-btn { height: 32px; padding-inline: 7px; }
  .brand-icon, .brand-icon img { width: 30px; height: 30px; }
  .header-designer { padding: 3px 6px; gap: 4px; }
  .header-designer img { width: 18px; height: 18px; }
}

@media (max-width: 380px) {
  .header-designer img { display: none; }
  .header-designer { padding: 4px 8px; }
  .header-socials { gap: 2px; }
  .header-socials a { width: 22px; height: 22px; }
  .header-socials a img { width: 13px; height: 13px; }
  .brand-icon, .brand-icon img { width: 28px; height: 28px; }
  .theme-btn { padding-inline: 6px; }
  .site-header .header-actions .btn { width: 30px; padding-inline: 5px; }
  .site-header .header-actions .icon-btn { width: 32px; }
}

/* گوشی‌های خیلی باریک (زیر 360px): سوشال‌ها جا نمی‌شوند → ردیف آیکون داخل منو */
@media (max-width: 359px) {
  .header-socials { display: none; }
  .nav-socials {
    display: flex; gap: 10px; justify-content: center;
    padding: 12px 0 4px; border-top: 1px solid var(--border); margin-top: 6px;
  }
  .nav-socials a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; padding: 0;
    border: 1px solid var(--border); background: var(--bg-2); border-radius: 10px;
  }
}