/* style.css — ProFlowAI (light/dark, RTL-aware, pipeline flowchart) */
:root {
  --bg: #f1f5f9; --card: #ffffff; --text: #0f172a; --muted: #64748b;
  --border: #e2e8f0; --primary: #2563eb; --primary-soft: #dbeafe;
  --green: #16a34a; --green-soft: #dcfce7; --amber: #b45309; --amber-soft: #fef3c7;
  --red: #dc2626; --red-soft: #fee2e2; --orange: #ea580c; --orange-soft: #ffedd5;
  --purple: #7c3aed; --purple-soft: #ede9fe; --gray-soft: #e2e8f0;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 4px 14px rgba(15,23,42,.05);
  --radius: 14px;
}
html.dark {
  --bg: #0b1220; --card: #111a2e; --text: #e2e8f0; --muted: #94a3b8;
  --border: #1e293b; --primary: #3b82f6; --primary-soft: #172554;
  --green: #22c55e; --green-soft: #052e16; --amber: #f59e0b; --amber-soft: #422006;
  --red: #ef4444; --red-soft: #450a0a; --orange: #fb923c; --orange-soft: #431407;
  --purple: #a78bfa; --purple-soft: #2e1065; --gray-soft: #1e293b;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Vazirmatn", "Segoe UI", Tahoma, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 15px; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: .92rem; }
a { color: var(--primary); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }
.mono { font-family: "Cascadia Code", Consolas, monospace; font-size: .84rem; }
.link { background: none; border: none; color: var(--primary); font-size: .85rem; font-weight: 600; }
.mini { font-size: .74rem; }

/* ── Topbar ── */
.topbar { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 10px 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.brand-logo { font-size: 1.5rem; }
.brand-name { font-weight: 800; font-size: 1.15rem; }
.topnav { display: flex; gap: 6px; flex: 1; }
.nav-btn, .icon-btn { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 7px 12px; border-radius: 10px; font-size: .9rem; transition: .15s; }
.nav-btn:hover, .icon-btn:hover { background: var(--gray-soft); color: var(--text); }
.nav-btn.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 4px; position: relative; }
.user-chip { font-size: .82rem; background: var(--gray-soft); padding: 5px 12px; border-radius: 20px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.role-badge { background: var(--primary-soft); color: var(--primary); font-weight: 700; padding: 1px 8px; border-radius: 12px; font-size: .7rem; }
#bell-btn { position: relative; }
.bell-dot { position: absolute; top: 2px; inset-inline-end: 2px; width: 16px; height: 16px; background: var(--red); color: #fff; border-radius: 50%; font-size: .6rem; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.bell-panel { position: absolute; top: 46px; inset-inline-end: 0; width: 320px; max-height: 380px; overflow: auto; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); z-index: 60; padding: 8px; }
.bell-item { padding: 9px 10px; border-radius: 10px; font-size: .84rem; cursor: pointer; border-bottom: 1px solid var(--border); }
.bell-item:hover { background: var(--gray-soft); }
.bell-item.unread { background: var(--primary-soft); }
.bell-item .t { font-weight: 700; } .bell-item .d { color: var(--muted); font-size: .74rem; margin-top: 2px; }
.notif-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.notif-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: .86rem; cursor: pointer; }
.notif-item.unread { border-inline-start: 4px solid var(--primary); background: var(--primary-soft); }
.notif-item .d { color: var(--muted); font-size: .74rem; margin-top: 4px; }

/* ── Layout ── */
#view { max-width: 1280px; margin: 0 auto; padding: 20px 18px 60px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.dash-head h2 { font-size: 1.4rem; font-weight: 800; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: .9rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* ── Stats ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; }
.stat-icon { font-size: 1.7rem; }
.stat-v { font-size: 1.5rem; font-weight: 800; }
.stat-k { color: var(--muted); font-size: .78rem; }

/* ── Filters ── */
.filters { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filters .input { min-width: 160px; }

/* ── Buttons / inputs ── */
.btn { border: 1px solid var(--border); background: var(--card); color: var(--text); padding: 8px 16px; border-radius: 10px; font-size: .9rem; font-weight: 600; transition: .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); color: #fff; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { filter: brightness(1.12); color: #fff; }
.btn-red, .btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover, .btn-danger:hover { filter: brightness(1.12); color: #fff; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(1.1); color: #fff; }
.green { color: var(--green); }
.red { color: var(--red); }
.sm { font-size: .78rem; }
.btn-ai { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-ai:hover { filter: brightness(1.12); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: .8rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 9px 12px; outline: none; width: 100%; }
.input:focus { border-color: var(--primary); }
label { font-size: .8rem; color: var(--muted); display: block; margin: 10px 0 4px; font-weight: 600; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 140px; }
small { font-size: .76rem; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.b-blue { background: var(--primary-soft); color: var(--primary); }
.b-green { background: var(--green-soft); color: var(--green); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-orange { background: var(--orange-soft); color: var(--orange); }
.b-purple { background: var(--purple-soft); color: var(--purple); }
.b-gray { background: var(--gray-soft); color: var(--muted); }
.banner { border-radius: 12px; padding: 11px 14px; font-size: .88rem; font-weight: 700; margin-top: 12px; }
.banner.b-green { background: var(--green-soft); color: var(--green); }
.banner.b-red { background: var(--red-soft); color: var(--red); }
.banner.b-gray { background: var(--gray-soft); color: var(--muted); }
.banner.b-amber { background: var(--amber-soft); color: var(--amber); }

/* ── Project cards ── */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.proj-card { display: flex; flex-direction: column; gap: 10px; }
.proj-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.proj-title { font-size: 1.05rem; line-height: 1.4; }
.proj-desc { color: var(--muted); font-size: .84rem; line-height: 1.6; }
.proj-meta { display: flex; justify-content: space-between; gap: 8px; font-size: .78rem; flex-wrap: wrap; }
.proj-actions { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.proj-head h2 { font-size: 1.35rem; margin-bottom: 6px; }
.proj-head-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ── Progress ── */
.prog { height: 9px; background: var(--gray-soft); border-radius: 20px; overflow: hidden; }
.prog.big { height: 12px; }
.prog-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #06b6d4); border-radius: 20px; transition: width .5s; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 16px; flex-wrap: wrap; }
.tab { border: none; background: transparent; color: var(--muted); padding: 10px 15px; font-size: .9rem; font-weight: 600; border-bottom: 3px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Lifecycle pipeline flowchart ── */
.flow-wrap { overflow-x: auto; padding-bottom: 6px; }
.flow { display: flex; gap: 4px; min-width: max-content; padding: 10px 4px; }
.f-node { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 5px; width: 106px; cursor: pointer; position: relative; padding: 4px 0; }
.f-circle { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; border: 3px solid var(--border); background: var(--card); transition: .2s; position: relative; }
.f-node.gate .f-circle { border-radius: 14px; }
.f-check { position: absolute; bottom: -5px; inset-inline-end: -5px; background: var(--green); color: #fff; width: 19px; height: 19px; border-radius: 50%; font-size: .72rem; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.f-label { font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.3; min-height: 2.2em; }
.f-num { font-size: .64rem; color: var(--muted); }
.f-gate-badge { font-size: .6rem; font-weight: 800; padding: 1px 7px; border-radius: 10px; }
.f-gate-badge.req { background: var(--amber-soft); color: var(--amber); }
.f-gate-badge.auto { background: var(--primary-soft); color: var(--primary); }
.f-node.done .f-circle { border-color: var(--green); background: var(--green-soft); }
.f-node.cur .f-circle { border-color: var(--primary); background: var(--primary-soft); animation: pulse 1.6s infinite; }
.f-node.cur.at .f-circle { box-shadow: 0 0 0 3px var(--primary-soft); }
.f-node.pending .f-circle { border-color: var(--amber); background: var(--amber-soft); animation: pulseA 1.6s infinite; }
.f-node.rejected .f-circle { border-color: var(--red); background: var(--red-soft); }
.f-node.revision .f-circle { border-color: var(--orange); background: var(--orange-soft); }
.f-node.locked { opacity: .45; }
.f-node:hover .f-circle { transform: scale(1.06); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(37,99,235,.4); } 50% { box-shadow: 0 0 0 9px rgba(37,99,235,0); } }
@keyframes pulseA { 0%,100% { box-shadow: 0 0 0 0 rgba(217,119,6,.4); } 50% { box-shadow: 0 0 0 9px rgba(217,119,6,0); } }
.flow-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: .76rem; color: var(--muted); align-items: center; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 5px; vertical-align: middle; }
.d-green { background: var(--green); } .d-blue { background: var(--primary); } .d-amber { background: var(--amber); }
.d-red { background: var(--red); } .d-gray { background: var(--muted); }

/* ── Stage workspace ── */
.stage-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stage-sel .input { min-width: 240px; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; }
.s-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; }
.s-card.ai { border-top: 3px solid var(--purple); }
.s-title { font-size: .95rem; font-weight: 800; margin-bottom: 10px; display: flex; align-items: center; gap: 7px; }
.item-list { list-style: none; display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.item-list li { background: var(--gray-soft); border-radius: 10px; padding: 8px 11px; font-size: .84rem; line-height: 1.55; }
.item-list li .meta { color: var(--muted); font-size: .7rem; display: block; margin-top: 3px; }
.ai-item { background: var(--purple-soft) !important; border-inline-start: 3px solid var(--purple); }
.human-item { background: var(--primary-soft) !important; border-inline-start: 3px solid var(--primary); }
.out-item { background: var(--green-soft) !important; border-inline-start: 3px solid var(--green); }
.ai-summary { background: var(--purple-soft); border-radius: 12px; padding: 12px; font-size: .83rem; line-height: 1.7; white-space: pre-wrap; margin-top: 10px; border-inline-start: 3px solid var(--purple); }
.stage-complete-bar { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.act-list { list-style: none; display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.act-list li { background: var(--gray-soft); border-radius: 10px; padding: 8px 11px; font-size: .83rem; }

/* ── Gate ── */
.gate-card { border: 2px solid var(--amber); background: var(--amber-soft); border-radius: 14px; padding: 16px; }
.gate-card.approved { border-color: var(--green); background: var(--green-soft); }
.gate-card.rejected { border-color: var(--red); background: var(--red-soft); }
.gate-card.auto { border-color: var(--primary); background: var(--primary-soft); }
.gate-big { display: flex; align-items: center; gap: 10px; font-size: 1.02rem; font-weight: 800; margin-bottom: 8px; flex-wrap: wrap; }
.gate-hist { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }
.gate-pending { color: var(--amber); font-weight: 800; }
.gate-rejected { color: var(--red); font-weight: 800; }
.gate-msg { font-size: .85rem; line-height: 1.6; }
.gate-comment { width: 100%; margin-top: 10px; }
.gate-banner { margin-top: 10px; }

/* ── Table ── */
.tbl-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th, .table td { padding: 9px 10px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .4px; }
.table tr:hover td { background: var(--gray-soft); }
.req-tests { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.test-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; background: var(--gray-soft); padding: 2px 8px; border-radius: 10px; }
.add-test { margin-top: 6px; }

/* ── Timeline ── */
.tl-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.tl-dot { flex: 0 0 12px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); margin-top: 5px; }
.tl-body { flex: 1; }
.tl-msg { font-size: .88rem; line-height: 1.6; }
.tl-meta { color: var(--muted); font-size: .74rem; margin-top: 2px; }

/* ── Auth ── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(1200px 600px at 20% 0%, var(--primary-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 430px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 30px; }
.auth-logo { font-size: 2.4rem; text-align: center; margin-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 1.45rem; }
.auth-tag { text-align: center; color: var(--primary); font-weight: 700; font-size: .88rem; margin-top: 2px; }
.auth-desc { text-align: center; color: var(--muted); font-size: .82rem; margin: 10px 0 16px; line-height: 1.7; }
.auth-tabs { display: flex; background: var(--gray-soft); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.auth-tabs .tab { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 9px; font-weight: 700; color: var(--muted); border-bottom: none; }
.auth-tabs .tab.active { background: var(--card); color: var(--primary); box-shadow: var(--shadow); border-bottom: none; }
.auth-note { margin-top: 14px; font-size: .76rem; color: var(--muted); text-align: center; line-height: 1.7; }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(2,6,23,.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; backdrop-filter: blur(3px); }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; padding: 22px; }
.modal.wide { max-width: 760px; }
.modal h3 { margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ── Toast / spinner ── */
#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: var(--bg); padding: 10px 22px; border-radius: 30px; font-size: .88rem; box-shadow: var(--shadow); animation: slideUp .25s ease; max-width: 90vw; }
.toast.ok { background: var(--green); color: #fff; }
.toast.err { background: var(--red); color: #fff; }
@keyframes slideUp { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
#spinner-root { position: fixed; inset: 0; z-index: 300; background: rgba(2,6,23,.4); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #fff; font-weight: 700; backdrop-filter: blur(2px); }
.spinner { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner-ring { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner-box { display: flex; flex-direction: column; align-items: center; gap: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .topbar-inner { gap: 6px; }
  .brand-name { font-size: 1rem; }
  .f-node { width: 92px; }
  .stage-grid { grid-template-columns: 1fr; }
}
