/* ============ Beeno Admin Dashboard — zero-dependency RTL CSS ============ */
:root {
  --radius: 12px;
  --font: "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
}
[data-theme="dark"] {
  --bg: #0f1420; --bg2: #171e2e; --card: #1b2334; --card2: #222c42;
  --text: #e8edf6; --muted: #93a0b8; --line: #2c3852;
  --accent: #4da3ff; --accent2: #7bd88f; --danger: #ff6b6b; --warn: #ffb454;
  --chip: #243050;
}
[data-theme="light"] {
  --bg: #f2f5fa; --bg2: #e8edf5; --card: #ffffff; --card2: #f6f8fc;
  --text: #1c2434; --muted: #5c6b84; --line: #d6deea;
  --accent: #1a6fd4; --accent2: #1f8a4c; --danger: #d33; --warn: #b26a00;
  --chip: #e2e9f4;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.55; min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
a { color: var(--accent); }
.spacer { flex: 1; }
ltr, .ltr { direction: ltr; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(1200px 600px at 80% -10%, var(--bg2), var(--bg)); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 24px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-card h1 { margin: 6px 0 2px; font-size: 22px; text-align: center; }
.login-card p { margin: 0 0 18px; text-align: center; }
.login-logo { width: 58px; height: 58px; margin: 0 auto 6px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #9b6bff); color: #fff; font-size: 30px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; position: relative; }
.login-logo-dot { position: absolute; inset-inline-end: 4px; bottom: 6px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent2); border: 2px solid var(--card); }
.login-card label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card2); color: var(--text); font-size: 15px; }
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-footer { display: flex; justify-content: space-between; margin-top: 14px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 230px 1fr; grid-template-rows: 56px 1fr auto;
  grid-template-areas: "top top" "nav main" "nav foot"; min-height: 100vh; }
.topbar { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.brand { font-weight: 700; }
.sidenav { grid-area: nav; background: var(--card); border-inline-start: 1px solid var(--line);
  padding: 12px 8px; overflow-y: auto; }
[data-theme="dark"] .sidenav { border-inline-start: none; border-inline-end: 1px solid var(--line); }
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.sidenav a { display: flex; align-items: center; gap: 8px; padding: 10px 14px; margin: 2px 0;
  border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
.sidenav a:hover { background: var(--card2); }
.sidenav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.view { grid-area: main; padding: 20px; max-width: 1280px; width: 100%; margin: 0 auto; }
.footbar { grid-area: foot; text-align: center; padding: 10px; font-size: 12px; border-top: 1px solid var(--line); }
.count-chip { background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px;
  padding: 1px 7px; margin-inline-start: auto; }

/* mobile */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: "top" "main" "foot"; }
  .sidenav { position: fixed; inset-block: 56px auto; inset-inline-start: 0; width: 250px; z-index: 40;
    height: calc(100vh - 56px); transform: translateX(105%); transition: transform .2s ease;
    border-inline-end: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
  html[dir="rtl"] .sidenav { transform: translateX(-105%); }
  .sidenav.open { transform: translateX(0) !important; }
  .nav-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; }
  .view { padding: 12px; }
}

/* ---------- Buttons / inputs ---------- */
.btn { border: 1px solid var(--line); background: var(--card2); color: var(--text); border-radius: 8px;
  padding: 8px 14px; font-size: 14px; cursor: pointer; font-family: inherit; }
.btn:hover { filter: brightness(1.1); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ok { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 18px; padding: 11px; font-size: 16px; }
.btn[disabled] { opacity: .55; cursor: progress; }
.iconbtn { background: transparent; border: none; color: var(--text); font-size: 19px; cursor: pointer;
  padding: 6px 8px; border-radius: 8px; line-height: 1; }
.iconbtn:hover { background: var(--card2); }
.iconbtn:focus-visible { outline: 2px solid var(--accent); }
.linkbtn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 4px; font-family: inherit; }
input[type="text"], input[type="password"], input[type="number"], input[type="datetime-local"],
input[type="date"], select, textarea {
  background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 14px; font-family: inherit; }
textarea { resize: vertical; min-height: 70px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* ---------- Cards & layout helpers ---------- */
.page-title { font-size: 21px; margin: 0 0 4px; }
.section { margin-bottom: 26px; }
.grid { display: grid; gap: 14px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .stat-num { font-size: 26px; font-weight: 700; }
.stat .stat-label { color: var(--muted); font-size: 13px; }
.stat .stat-sub { font-size: 12px; color: var(--accent2); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.toolbar input[type="text"] { min-width: 220px; flex: 1; max-width: 420px; }

/* ---------- Lists / tables ---------- */
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--card2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .sub { font-size: 13px; color: var(--muted); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: start; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl-wrap { overflow-x: auto; }

/* ---------- Badges / chips ---------- */
.badge { display: inline-block; border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.badge-pro { background: linear-gradient(90deg, #c9a227, #f1d26a); color: #201500; }
.badge-ok { background: var(--accent2); color: #04220f; }
.badge-bad { background: var(--danger); color: #fff; }
.badge-warn { background: var(--warn); color: #241503; }
.badge-info { background: var(--accent); color: #fff; }
.badge-muted { background: var(--chip); color: var(--muted); }
.chip { background: var(--chip); border-radius: 8px; padding: 2px 8px; font-size: 12px; color: var(--muted); }

/* ---------- Profile card ---------- */
.profile-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #9b6bff);
  color: #fff; font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.kv { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.actions-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--line); border-radius: 24px; cursor: pointer; transition: .15s; }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; top: 3px; inset-inline-start: 3px; transition: .15s; }
.switch input:checked + .slider { background: var(--accent2); }
.switch input:checked + .slider::before { transform: translateX(-20px); }
html[dir="ltr"] .switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); }
.flag-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.flag-row:last-child { border-bottom: none; }
.flag-row .grow { flex: 1; }
.text-bad { color: var(--danger); font-weight: 700; }

/* ---------- Support ---------- */
.chat-col { display: flex; flex-direction: column; height: 60vh; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 12px; background: var(--card2); font-size: 14px; }
.msg .msg-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg.mine { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.mine .msg-meta { color: #dcecff; }
.chat-input { display: flex; gap: 8px; margin-top: 10px; }
.chat-input textarea { min-height: 44px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tab-btn { background: none; border: none; padding: 8px 14px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; font-size: 14px; font-family: inherit; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-btn:focus-visible { outline: 2px solid var(--accent); }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 18px; }
.modal-body label { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.modal-body input, .modal-body select, .modal-body textarea { width: 100%; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Toasts ---------- */
.toast-root { position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 10px;
  padding: 10px 16px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: tin .2s ease; max-width: 90vw; }
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--accent2); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.empty .empty-ico { font-size: 34px; }
.skeleton { color: var(--muted); text-align: center; padding: 30px; }
.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--muted);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-inline-end: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Charts ---------- */
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-legend { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* preview media box */
.preview-box { background: var(--card2); border: 1px dashed var(--line); border-radius: 8px; padding: 10px;
  font-size: 13px; color: var(--muted); max-height: 160px; overflow: auto; margin: 6px 0; white-space: pre-wrap; }
code, .code { font-family: Consolas, Menlo, monospace; direction: ltr; unicode-bidi: embed; background: var(--chip);
  padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.danger-zone { border-color: var(--danger); }
details.more summary { cursor: pointer; color: var(--accent); margin: 8px 0; }
