/* ===========================
   TurboNews UI (RTL) - v1
   Mobile overflow-proof build
   =========================== */

/* ✅ ریشه‌ای: جلوگیری از بیرون‌زدگی */
*{ box-sizing:border-box; min-width:0; }
html,body{ height:100%; overflow-x:hidden; }
img,svg,video,canvas{ max-width:100%; height:auto; display:block; }

:root{
  --bg:#0b0f19;
  --card:#101827;
  --card2:#0f1626;
  --text:#eef2ff;
  --muted:#a8b3cf;
  --border: rgba(255,255,255,.08);
  --shadow: 0 18px 55px rgba(0,0,0,.38);

  --brand1:#7c3aed;
  --brand2:#06b6d4;

  --radius: 22px;
  --radius2: 16px;

  --max: 1180px;
  --pad: 16px;
  --topbarH: 64px;
}

[data-theme="light"]{
  --bg:#f5f7ff;
  --card:#ffffff;
  --card2:#ffffff;
  --text:#0b1220;
  --muted:#51607a;
  --border: rgba(13,23,44,.10);
  --shadow: 0 18px 55px rgba(16,24,40,.12);
}

body{
  margin:0;
  font-family:"Vazirmatn", system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background:
    radial-gradient(1200px 650px at 80% -10%, rgba(124,58,237,.18), transparent 55%),
    radial-gradient(900px 500px at 10% 10%, rgba(6,182,212,.16), transparent 60%),
    var(--bg);
  color: var(--text);
}

a{ color:inherit; text-decoration:none; }
button,input,select,textarea{ font-family:inherit; }
::selection{ background: rgba(124,58,237,.30); }

/* helpers */
.hide-md{ display:block; }
.show-md{ display:none; }
.divider{ height:1px; background:var(--border); }
.no-scroll{ overflow:hidden; }

/* ========= Topbar ========= */
.topbar{
  position:sticky; top:0; z-index:30;
  border-bottom:1px solid var(--border);
  background: linear-gradient(180deg, rgba(10,15,25,.78), rgba(10,15,25,.35));
  backdrop-filter: blur(10px);
}
[data-theme="light"] .topbar{
  background: linear-gradient(180deg, rgba(245,247,255,.92), rgba(245,247,255,.70));
}
.topbar__in{
  max-width: var(--max);
  margin:0 auto;
  padding: 10px var(--pad);
  display:flex;
  align-items:center;
  gap:10px;
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  flex: 0 0 auto;
}
.brand__logo{
  width:38px; height:38px;
  border-radius: 14px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  box-shadow: 0 18px 35px rgba(124,58,237,.22);
}
.brand__txt{ display:flex; flex-direction:column; line-height:1.15; }
.brand__name{ font-weight:800; letter-spacing:.2px; }
.brand__sub{ font-size:12px; color: var(--muted); font-weight:600; }

.search{
  flex: 1 1 auto;
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 12px;
  border-radius: 16px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  min-width: 0;
}
[data-theme="light"] .search{ background: rgba(13,23,44,.04); }
.search input{
  width:100%;
  border:0;
  outline:0;
  background:transparent;
  color: var(--text);
  font-size:14px;
  min-width:0;
}

.chip{
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 16px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:8px;
  flex: 0 0 auto;
}
[data-theme="light"] .chip{ background: rgba(13,23,44,.04); }
.chip__dot{
  width:8px; height:8px; border-radius:999px;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
}
.chip__txt{ font-size:12px; font-weight:800; }

/* ========= Buttons ========= */
.btn{
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  user-select:none;
}
[data-theme="light"] .btn{ background: rgba(13,23,44,.04); }
.btn--primary{
  border:0;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  box-shadow: 0 18px 35px rgba(124,58,237,.20);
}
.btn--ghost{
  background: transparent;
}

/* ========= Layout ========= */
.wrap{
  max-width: var(--max);
  margin:0 auto;
  padding: 12px var(--pad) 92px;
}
.layout{
  display:grid;
  grid-template-columns: 280px minmax(0,1fr) 330px;
  gap: 14px;
  align-items:start;
  margin-top: 14px;
}
.side{
  position: sticky;
  top: calc(var(--topbarH) + 14px);
  display:flex;
  flex-direction:column;
  gap: 12px;
}
.feed{
  display:flex;
  flex-direction:column;
  gap: 12px;
  min-width: 0;
}

/* ========= Card ========= */
.card{
  border:1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden; /* ✅ مهم برای جلوگیری از بیرون‌زدگی */
  max-width: 100%;
}
.card--pad{ padding: 12px; }

/* ========= Profile ========= */
.profile{
  display:flex;
  align-items:center;
  gap:12px;
  padding: 12px;
}
.avatar{
  width:46px; height:46px;
  border-radius: 18px;
  display:grid; place-items:center;
  font-weight:900;
  color:white;
  background: linear-gradient(135deg, rgba(124,58,237,.9), rgba(6,182,212,.8));
}
.profile__meta{ flex:1; min-width:0; }
.profile__name{ font-weight:800; }
.profile__sub{ font-size:12px; color:var(--muted); }

/* ========= Nav ========= */
.nav{ padding: 10px; }
.nav__item{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 12px;
  border-radius: 16px;
  border:1px solid transparent;
}
.nav__item:hover{ border-color: var(--border); background: rgba(255,255,255,.03); }
[data-theme="light"] .nav__item:hover{ background: rgba(13,23,44,.03); }
.nav__item.is-active{
  border-color: rgba(124,58,237,.35);
  background: rgba(124,58,237,.10);
}
.nav__txt{ font-weight:700; }
.badge{
  margin-inline-start:auto;
  font-size:11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(6,182,212,.28);
  background: rgba(6,182,212,.14);
  color: #b9f6ff;
}
[data-theme="light"] .badge{ color:#046b7c; }
.badge--live{}
.badge--hot{ border-color: rgba(124,58,237,.28); background: rgba(124,58,237,.14); color:#e9d5ff; }
.badge--ok{ border-color: rgba(34,197,94,.28); background: rgba(34,197,94,.14); color:#bbf7d0; }

/* ========= Section ========= */
.section__hd{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}
.section__title{ font-weight:900; }
.section__sub{ font-size:12px; color:var(--muted); margin-top:4px; }
.seg{ display:flex; flex-wrap:wrap; gap:8px; }
.seg__btn{
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 999px;
  cursor:pointer;
}
[data-theme="light"] .seg__btn{ background: rgba(13,23,44,.04); }
.seg__btn.is-active{
  border-color: rgba(124,58,237,.35);
  background: rgba(124,58,237,.10);
}

/* ========= Stories ========= */
.stories{
  display:flex;
  gap:10px;
  padding: 12px;
  overflow:auto;
  -webkit-overflow-scrolling: touch;
}
.stories::-webkit-scrollbar{ height:8px; }
.stories::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.12); border-radius: 999px; }
[data-theme="light"] .stories::-webkit-scrollbar-thumb{ background: rgba(13,23,44,.12); }
.story{
  flex: 0 0 auto;
  width: 82px;
  text-align:center;
}
.story__ring{
  width: 66px; height:66px;
  margin:0 auto 8px;
  border-radius: 22px;
  padding:2px;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  display:block;
}
.story__in{
  width:100%; height:100%;
  border-radius: 20px;
  background: var(--card2);
  border:1px solid var(--border);
  display:grid; place-items:center;
  font-weight:900;
}
.story__txt{ font-size:12px; color:var(--muted); font-weight:700; }

/* ========= Composer ========= */
.composer{
  padding: 12px;
  display:flex;
  align-items:center;
  gap:10px;
}
.miniava{
  width:40px; height:40px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(124,58,237,.9), rgba(6,182,212,.8));
  color:white;
  display:grid; place-items:center;
  font-weight:900;
  flex: 0 0 auto;
}
.composer__in{
  flex: 1 1 auto;
  min-width:0;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  border-radius: 16px;
  padding: 12px 12px;
  outline:0;
  color: var(--text);
}
[data-theme="light"] .composer__in{ background: rgba(13,23,44,.04); }

/* ========= Post ========= */
.post{ max-width:100%; }
.post__hd{
  padding: 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.post__who{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
  flex: 1 1 auto;
}
.ava{
  width:42px; height:42px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(124,58,237,.9), rgba(6,182,212,.75));
  color:white;
  display:grid; place-items:center;
  font-weight:900;
  flex: 0 0 auto;
}
.post__meta{ min-width:0; }
.post__name{ font-weight:900; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.post__sub{ font-size:12px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.iconbtn{
  width:40px; height:40px;
  border-radius: 16px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  display:grid; place-items:center;
  cursor:pointer;
  flex: 0 0 auto;
}
[data-theme="light"] .iconbtn{ background: rgba(13,23,44,.04); }

.post__media{
  position:relative;
  display:grid;
  place-items:center;
  text-align:center;
  padding: 20px 14px;
  aspect-ratio: 1 / 1;          /* ✅ موبایل-پسند */
  border-top:1px solid var(--border);
  border-bottom:1px solid var(--border);
  background:
    radial-gradient(650px 220px at 20% 20%, rgba(124,58,237,.20), transparent 55%),
    radial-gradient(650px 220px at 80% 70%, rgba(6,182,212,.18), transparent 55%),
    linear-gradient(135deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
}
.post__media--tall{ aspect-ratio: 4 / 5; } /* شبیه اینستاگرام */
.tag{
  position:absolute;
  top:12px;
  inset-inline-start:12px;
  padding: 7px 10px;
  font-size:12px;
  border-radius: 999px;
  border:1px solid var(--border);
  background: rgba(0,0,0,.28);
  backdrop-filter: blur(10px);
}
[data-theme="light"] .tag{ background: rgba(255,255,255,.80); }

.post__title{
  font-size: 16px;
  font-weight: 900;
  line-height: 1.6;
  padding: 0 10px;
  max-width: 100%;
  overflow-wrap: anywhere; /* ✅ */
}

.post__body{ padding: 12px; max-width:100%; }
.pills{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:10px; }
.pill{
  padding: 7px 10px;
  border-radius: 999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  font-size:12px;
}
[data-theme="light"] .pill{ background: rgba(13,23,44,.04); }
.post__txt{
  margin:0;
  color: var(--muted);
  line-height: 1.9;
  overflow-wrap:anywhere; /* ✅ لینک/متن طولانی */
  word-break: break-word;
}

/* actions */
.post__actions{
  padding: 10px 12px 12px;
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap; /* ✅ موبایل */
}
.post__cta{
  margin-inline-start:auto;
  display:flex;
  gap:8px;
  flex: 1 1 220px; /* ✅ اجازه جمع شدن */
  justify-content:flex-end;
  min-width: 0;
}
.post__cta .btn{ flex: 1 1 0; }

.post__stats{
  padding: 0 12px 12px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  color: var(--muted);
  font-size:12px;
  flex-wrap:wrap;
}

/* comment */
.post__comment{
  padding: 0 12px 14px;
  display:flex;
  gap:10px;
  align-items:center;
}
.post__commentIn{
  flex: 1 1 auto;
  min-width:0;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  border-radius: 16px;
  padding: 11px 12px;
  outline:0;
  color: var(--text);
}
[data-theme="light"] .post__commentIn{ background: rgba(13,23,44,.04); }
.sendbtn{
  width:46px; height:46px;
  border-radius: 16px;
  border:0;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  cursor:pointer;
  display:grid; place-items:center;
  flex: 0 0 auto;
  box-shadow: 0 18px 40px rgba(124,58,237,.18);
}

/* right widgets */
.list{ display:flex; flex-direction:column; gap:8px; }
.trend{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 10px 12px;
  border-radius: 16px;
  border:1px solid transparent;
}
.trend:hover{ border-color: var(--border); background: rgba(255,255,255,.03); }
[data-theme="light"] .trend:hover{ background: rgba(13,23,44,.03); }
.trend__name{ font-weight:900; }
.trend__sub{ font-size:12px; color: var(--muted); margin-top:4px; }
.spark{
  width:46px; height:28px;
  border-radius: 12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  display:grid; place-items:center;
  flex: 0 0 auto;
}
[data-theme="light"] .spark{ background: rgba(13,23,44,.04); }

.who{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 10px 12px;
  border-radius: 16px;
  border:1px solid transparent;
}
.who:hover{ border-color: var(--border); background: rgba(255,255,255,.03); }
[data-theme="light"] .who:hover{ background: rgba(13,23,44,.03); }
.who__left{ display:flex; align-items:center; gap:10px; min-width:0; }
.mini{
  width:38px; height:38px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(124,58,237,.9), rgba(6,182,212,.75));
  color:white;
  display:grid; place-items:center;
  font-weight:900;
  flex: 0 0 auto;
}
.who__txt{ min-width:0; }
.who__name{ font-weight:900; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.who__sub{ font-size:12px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ========= Bottom nav (Mobile) ========= */
.bottomnav{
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(var(--max), calc(100% - 18px));
  border-radius: 22px;
  border: 1px solid var(--border);
  background: rgba(10,15,25,.72);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  padding: 8px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  z-index: 40;
}
[data-theme="light"] .bottomnav{ background: rgba(255,255,255,.88); }
.bbtn{
  flex: 1 1 0;
  height: 48px;
  border-radius: 16px;
  border:1px solid transparent;
  background: transparent;
  color: var(--text);
  display:grid; place-items:center;
  cursor:pointer;
}
.bbtn:hover{ border-color: var(--border); background: rgba(255,255,255,.06); }
[data-theme="light"] .bbtn:hover{ background: rgba(13,23,44,.04); }
.cbtn{
  flex: 0 0 64px;
  height: 54px;
  border-radius: 20px;
  border:0;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  display:grid; place-items:center;
  cursor:pointer;
  box-shadow: 0 18px 40px rgba(124,58,237,.24);
}

/* ========= Modals ========= */
.modal{
  position: fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  padding: 12px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(8px);
  z-index: 60;
}
[data-theme="light"] .modal{ background: rgba(13,23,44,.35); }
.modal.open{ display:flex; }
.sheet{
  width: min(720px, 100%);
  max-height: 88vh;
  border-radius: 22px;
  border:1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.sheet--sm{ width: min(640px, 100%); }
.sheet__hd{
  padding: 12px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  border-bottom:1px solid var(--border);
}
.sheet__title{ font-weight:900; }
.sheet__sub{ font-size:12px; color:var(--muted); margin-top:4px; }
.sheet__bd{
  padding: 14px;
  overflow:auto;
  max-height: calc(88vh - 64px);
}

/* forms */
.form{ display:flex; flex-direction:column; gap:10px; }
.form__grid{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
.field{ display:flex; flex-direction:column; gap:8px; }
.field__lbl{ font-size:12px; color:var(--muted); font-weight:700; }
.field__in{
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 12px;
  outline:0;
  width: 100%;
}
[data-theme="light"] .field__in{ background: rgba(13,23,44,.04); }
.field__in--ta{ min-height: 120px; resize: vertical; }
.form__actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  justify-content:flex-end;
}

/* comments */
.comment{
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
}
[data-theme="light"] .comment{ background: rgba(13,23,44,.03); }
.comment p{
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.8;
  overflow-wrap:anywhere;
}
.comment__send{
  display:flex;
  gap:10px;
  align-items:center;
}

/* settings */
.settingsGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.btnrow{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:10px;
}

/* ========= Responsive ========= */
@media (max-width: 1080px){
  .layout{ grid-template-columns: 260px minmax(0,1fr) 300px; }
}

@media (max-width: 980px){
  :root{ --pad: 12px; --radius: 18px; --radius2: 14px; }

  .hide-md{ display:none !important; }
  .show-md{ display:flex !important; }

  .wrap{ padding: 10px var(--pad) 110px; }
  .layout{ grid-template-columns: minmax(0,1fr); } /* ✅ فقط یک ستون */
  .side{ position: static; }

  /* مهم: در موبایل همه چیز تمام عرض */
  .card, .post, .feed{ width:100%; max-width:100%; }

  /* composer button */
  .composer{ gap:8px; }
  .btn{ padding: 10px 10px; }

  /* actions: دکمه‌های CTA زیر هم یا گریدی */
  .post__cta{
    width:100%;
    margin-inline-start:0;
    justify-content:stretch;
    flex: 1 1 100%;
  }

  /* forms in modal */
  .form__grid{ grid-template-columns: 1fr; }
  .settingsGrid{ grid-template-columns: 1fr; }

  /* bottom nav always */
  .bottomnav{ display:flex; }
}
/* تصویر خبر */
.news-card img,
.post-card img,
.article-card img {
    width: 100%;
    height: 220px;        /* ارتفاع ثابت */
    object-fit: contain; /* کل تصویر دیده می‌شود */
    background: #111;    /* بک‌گراند تیره برای فضای خالی */
    border-radius: 12px;
}
