/* ── صدقة جارية — نمط بسيط نظيف، يدعم الوضع الفاتح والداكن ─────────────── */
:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --border: #e3e6e0;
  --text: #1c2620;
  --muted: #6b7a72;
  --accent: #1f7a52;
  --accent-soft: #e8f3ed;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --ok: #1f7a52;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 30, .05), 0 8px 24px rgba(20, 40, 30, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111613;
    --surface: #19201c;
    --border: #2a332d;
    --text: #e8eeea;
    --muted: #93a19a;
    --accent: #4bbd8a;
    --accent-soft: #16302447;
    --danger: #ff8a80;
    --danger-soft: #3a1c1a;
    --ok: #4bbd8a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Noto Naskh Arabic", "Tahoma", sans-serif;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── الشريط العلوي ─────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 20px; max-width: 720px; width: 100%; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  font-size: 26px; width: 46px; height: 46px; display: grid; place-items: center;
  background: var(--accent-soft); border-radius: 12px;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; }
.sub { margin: 0; font-size: 13px; color: var(--muted); }

main {
  flex: 1; width: 100%; max-width: 720px; margin: 0 auto;
  padding: 0 20px 40px; display: flex; flex-direction: column; gap: 16px;
}

/* ── البطاقات ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 17px; font-weight: 700; }
.center { text-align: center; max-width: 380px; margin: 8vh auto 0; }
.center h2 { margin-bottom: 4px; }
.muted { color: var(--muted); font-size: 13px; }

/* ── الحقول ────────────────────────────────────────────────────────────── */
input[type=password], textarea {
  width: 100%; padding: 12px 14px; font: inherit; font-size: 15px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input[type=password]:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 110px; }
.field { display: block; margin: 18px 0; }
.field > span:first-child { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.counter { display: block; text-align: left; font-size: 12px; color: var(--muted); margin-top: 4px; }

button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px;
  border: 1px solid transparent; padding: 12px 18px; transition: filter .15s, opacity .15s;
}
button:disabled { opacity: .5; cursor: not-allowed; }
button:not(:disabled):hover { filter: brightness(1.06); }
.primary { background: var(--accent); color: #fff; width: 100%; margin-top: 8px; }
.ghost {
  background: transparent; color: var(--muted); border-color: var(--border);
  padding: 8px 14px; font-size: 14px;
}
.small { padding: 5px 10px; font-size: 13px; }
#loginForm { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* ── منطقة الإفلات ─────────────────────────────────────────────────────── */
.drop {
  display: block; border: 2px dashed var(--border); border-radius: 12px;
  padding: 28px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.dragover { border-color: var(--accent); background: var(--accent-soft); }
.drop.filled { padding: 14px; border-style: solid; cursor: default; }
#dropIdle { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.dropIcon { font-size: 34px; }
#preview { width: 100%; max-height: 320px; border-radius: 10px; background: #000; display: block; }
.fileMeta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; text-align: right;
}
.fileMeta strong { font-size: 14px; word-break: break-all; flex: 1; min-width: 0; }

/* ── شريط التقدّم ──────────────────────────────────────────────────────── */
.progress { margin-top: 14px; }
.bar { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.progress .muted { display: block; margin-top: 6px; }

/* ── خطوات الحالة ──────────────────────────────────────────────────────── */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.steps li {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--muted); transition: color .2s;
}
.dot {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  border: 2px solid var(--border); background: transparent; transition: all .2s;
}
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.active .dot {
  border-color: var(--accent); background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pulse 1.4s ease-in-out infinite;
}
.steps li.done { color: var(--text); }
.steps li.done .dot { border-color: var(--ok); background: var(--ok); animation: none; box-shadow: none; }
.steps li.failed .dot { border-color: var(--danger); background: var(--danger); animation: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px transparent; } }
.stepNote { margin: 14px 0 0; }

/* ── النتائج والأخطاء ──────────────────────────────────────────────────── */
.error, .success {
  margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; font-size: 14px;
}
.error { background: var(--danger-soft); color: var(--danger); }
.success { background: var(--accent-soft); color: var(--ok); }
.success a { color: inherit; font-weight: 700; }
.detail { display: block; margin-top: 6px; font-size: 12px; opacity: .8; direction: ltr; text-align: left; }

/* ── السجل ─────────────────────────────────────────────────────────────── */
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.history li {
  display: flex; align-items: center; gap: 10px; padding: 11px 0;
  border-top: 1px solid var(--border); font-size: 14px;
}
.history li:first-child { border-top: none; }
.badge {
  font-size: 12px; padding: 2px 9px; border-radius: 99px; flex: none; font-weight: 600;
}
.badge.done { background: var(--accent-soft); color: var(--ok); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }
.badge.busy { background: var(--border); color: var(--muted); }
.history .text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history time { font-size: 12px; color: var(--muted); flex: none; }

/* ── بطاقة الربط بتيك توك ──────────────────────────────────────────────── */
.connect { padding: 16px 22px; }
.connectHead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.connectHead img {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex: none;
  border: 1px solid var(--border);
}
.connectText { flex: 1; min-width: 140px; display: flex; flex-direction: column; }
.connectText strong { font-size: 15px; }
.btnLink {
  display: inline-block; text-decoration: none; text-align: center;
  width: auto; margin: 0; padding: 10px 16px; font-size: 14px;
}
.notice {
  margin: 12px 0 0; padding: 10px 13px; border-radius: 10px; font-size: 13px;
  background: var(--accent-soft); color: var(--text);
}

/* ── خيارات المنشور ────────────────────────────────────────────────────── */
select {
  width: 100%; padding: 12px 14px; font: inherit; font-size: 15px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; outline: none;
}
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select:disabled { opacity: .5; }
.req { font-style: normal; font-size: 12px; color: var(--danger); font-weight: 500; }

.toggles {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px 14px; margin: 18px 0;
}
.toggles legend { font-size: 13px; font-weight: 600; padding: 0 6px; color: var(--muted); }
.switch {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 0; font-size: 14px; cursor: pointer;
}
.switch input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.switch.off { opacity: .45; cursor: not-allowed; }
.switch.off input { cursor: not-allowed; }

.consent { font-size: 12px; color: var(--muted); text-align: center; margin: 12px 0 0; }
.consent a { color: var(--accent); }

/* النموذج معطّل بصرياً ما دام الحساب غير مربوط */
#publishForm.disabled { opacity: .55; }
#publishForm.disabled .drop { pointer-events: none; }

footer { text-align: center; padding: 20px; font-size: 12px; }

@media (max-width: 480px) {
  .card { padding: 18px; }
  .topbar { padding: 14px; }
  main { padding: 0 14px 30px; }
}
