/* DZ Voice — RTL Arabic UI */
:root {
    --ink: #161a26; --muted: #667085; --line: #e6e8f0; --bg: #f5f6fb; --card: #ffffff;
    --primary: #5b3cf5; --primary-2: #7b61ff; --primary-soft: #efebff; --accent: #ffb020;
    --ok: #12805c; --ok-soft: #e6f6ef; --warn: #b54708; --warn-soft: #fef4e6; --err: #c0262d; --err-soft: #fdecec;
    --radius: 16px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Tajawal', system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 16px; line-height: 1.7; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; font-weight: 800; }
h2 { font-size: 1.35rem; font-weight: 800; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1em; }
small, .muted { color: var(--muted); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 22px;
    background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.2rem; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.brand-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 11px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-size: 1.1rem; }
.topnav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topnav a { color: var(--muted); padding: 7px 12px; border-radius: 10px; font-weight: 500; font-size: .95rem; white-space: nowrap; }
.topnav a span { margin-left: 5px; }
.topnav a:hover, .topnav a.active { background: var(--primary-soft); color: var(--primary); }
.topbar-end { display: flex; gap: 8px; align-items: center; margin-inline-start: auto; }
.points-pill { background: #fff7e6; color: #8a5a00; border: 1px solid #ffe2a8; padding: 5px 12px; border-radius: 999px; font-weight: 700; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 26px 18px 60px; }
.wrap.wide { max-width: 1280px; }
.footer { text-align: center; color: var(--muted); padding: 26px 16px; border-top: 1px solid var(--line); font-size: .9rem; display: grid; gap: 6px; }

/* cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
/* phones & tablets: the menu is ONE line you swipe, and the bar doesn't eat the screen */
@media (max-width: 860px) {
    .topbar { gap: 8px 10px; padding: 8px 12px; }
    .topnav { order: 3; width: 100%; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .topnav::-webkit-scrollbar { display: none; }
    .topbar-end .btn-ghost { padding: 6px 8px; }
}
@media (max-width: 600px) { .topbar { position: static; } .wrap { padding: 18px 12px 48px; } h1 { font-size: 1.55rem; } }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 180px; }
.stack > * + * { margin-top: 14px; }
.mb { margin-bottom: 16px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px;
    padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer; background: #fff; color: var(--ink); border-color: var(--line); transition: .15s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border: 0; box-shadow: 0 6px 16px rgba(91, 60, 245, .28); }
.btn-accent { background: var(--accent); color: #3d2600; border: 0; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.btn-lg { padding: 14px 26px; font-size: 1.08rem; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
.btn.loading::after { content: ''; width: 16px; height: 16px; border: 2px solid currentColor; border-left-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* forms */
label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .95rem; }
.field { margin-bottom: 14px; }
.field small { display: block; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], select, textarea {
    width: 100%; font: inherit; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
textarea { min-height: 150px; resize: vertical; line-height: 1.9; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.counter { font-size: .85rem; color: var(--muted); text-align: left; }

/* alerts, badges */
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-err { background: var(--err-soft); color: var(--err); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-info { background: var(--primary-soft); color: var(--primary); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .82rem; font-weight: 700; background: #f0f1f5; color: var(--muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--err-soft); color: var(--err); }
.badge-star { background: #fff4d6; color: #8a5a00; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.table th { color: var(--muted); font-weight: 700; font-size: .85rem; }
.table-wrap { overflow-x: auto; }

/* tools */
.tool-card { display: block; color: var(--ink); }
.tool-card .icon { font-size: 2rem; }
.tool-card:hover { border-color: var(--primary); }
.tool-card .cost { color: var(--muted); font-size: .9rem; }
.kpi .kpi-value { font-size: 1.9rem; font-weight: 800; }
.kpi .kpi-label { color: var(--muted); font-weight: 700; }
.result { border: 2px dashed var(--primary-soft); border-radius: var(--radius); padding: 18px; background: #fbfaff; }
audio { width: 100%; margin: 8px 0; }
.script-card { position: relative; }
.script-card .text { white-space: pre-wrap; background: #fafbff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.script-card.top { border-color: #ffd37a; box-shadow: 0 0 0 3px #fff4d6; }
.script-card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.facts td:first-child { width: 42px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; cursor: pointer; background: #fcfcff; }
.drop:hover { border-color: var(--primary); }
.voice-pick { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.voice-gallery-box { margin: 4px 0 14px; }
.voice-gallery-box summary { cursor: pointer; color: var(--primary); font-weight: 700; }
.voice-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; margin-top: 10px; }
.vg-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.vg-item.on { border-color: var(--primary); background: var(--primary-soft); }
.vg-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.vg-name small { color: var(--muted); }
.voice-used { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.playing { background: var(--primary-soft); border-color: var(--primary); }
.fb-box { margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--primary); border-radius: 12px; display: grid; gap: 8px; }
.fb-stars button { font-size: 1.6rem; line-height: 1; background: none; border: 0; color: #d0d4e0; cursor: pointer; padding: 0 2px; }
.fb-stars button.on { color: #f5a623; }
.fb-comment { min-height: 54px; }

/* landing */
.hero { text-align: center; padding: 40px 10px 24px; }
.hero h1 { font-size: 2.4rem; }
.hero .lead { font-size: 1.2rem; color: var(--muted); max-width: 720px; margin: 0 auto 22px; }
.hero .cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.plan { text-align: center; display: flex; flex-direction: column; }
.plan .price { font-size: 1.8rem; font-weight: 800; }
.plan .pts { color: var(--primary); font-weight: 800; }
.plan ul { list-style: none; padding: 0; margin: 12px 0; color: var(--muted); text-align: right; flex: 1; }
.plan ul li::before { content: '✓ '; color: var(--ok); font-weight: 800; }
.plan.featured { border: 2px solid var(--primary); }
.section { margin-top: 44px; }
.section-title { text-align: center; margin-bottom: 20px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px;
    border-radius: 12px; z-index: 50; box-shadow: var(--shadow); max-width: 92vw; }
.hidden { display: none !important; }

/* tabs, pager, script cards with an editable text */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.pager { justify-content: space-between; margin-top: 14px; }
.pager > * { flex: 0 0 auto; }
.script-card textarea.text { min-height: 170px; width: 100%; font: inherit; line-height: 1.9; }
.script-card .actions select { width: auto; padding: 6px 10px; font-size: .9rem; }
.script-card .why { display: block; margin-bottom: 8px; }
.thumbs .thumb { position: relative; }
.thumbs .thumb button { position: absolute; top: -6px; left: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0;
    background: var(--err); color: #fff; cursor: pointer; font-size: .8rem; line-height: 22px; padding: 0; }
.steps { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.steps span { padding: 4px 12px; border-radius: 999px; background: #f0f1f5; color: var(--muted); font-weight: 700; font-size: .9rem; }
.steps span.on { background: var(--primary-soft); color: var(--primary); }
.facts input[type=text] { padding: 7px 10px; }
.facts tr.off td { opacity: .5; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { min-width: 42px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 700; cursor: pointer; font: inherit; }
.chips button.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chips.off button { opacity: .45; }
.engine-chips button small { color: var(--muted); font-weight: 500; }
.angle-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-top: 10px; }
.angle-list label { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 400; }
.angle-list label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.angle-list input { margin-top: 4px; flex: 0 0 auto; }
.angle-list small { display: block; }
.list-item { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1 1 320px; min-width: 0; }
.plus { color: var(--ok); font-weight: 800; }
.minus { color: var(--err); font-weight: 800; }
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.admin-nav a { padding: 7px 12px; border-radius: 10px; color: var(--muted); font-weight: 700; font-size: .93rem; }
.admin-nav a.active, .admin-nav a:hover { background: var(--primary-soft); color: var(--primary); }
.admin-nav .count { background: var(--err); color: #fff; border-radius: 999px; padding: 0 7px; font-size: .78rem; margin-right: 4px; }
.inline { display: inline; }
.table input[type=number], .table input[type=text] { padding: 6px 8px; min-width: 70px; }
.table textarea { min-height: 70px; }
.good { color: var(--ok); font-weight: 700; }
.bad { color: var(--err); font-weight: 700; }
.receipt { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.lang-bar .chips button { font-size: .95em; }
details.spoken { margin-top: 8px; }
