/* OpenClaw CRM — stylesheet (RTL, Arabic-first) */

:root {
  --bg:        #0f1419;
  --bg-2:      #161c24;
  --panel:     #1c242e;
  --panel-2:   #232d39;
  --border:    #2d3845;
  --text:      #e6eaef;
  --muted:     #8a97a6;
  --primary:   #2da44e;
  --primary-d: #25893f;
  --danger:    #d2444a;
  --danger-d:  #b23a3f;
  --accent:    #f0a23c;
  --radius:    12px;
  --shadow:    0 8px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary-d); color: #fff; }
.btn-danger  { background: var(--danger); border-color: var(--danger-d); color: #fff; }
.btn-ghost   { background: transparent; }
.btn-block   { width: 100%; }
.btn-sm      { padding: 6px 12px; font-size: 13px; }

/* ---------- alerts ---------- */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-error { background: rgba(210,68,74,.15); border: 1px solid var(--danger); color: #f3b5b7; }

/* ---------- auth pages ---------- */
body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.auth-card-wide { max-width: 440px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { margin: 8px 0 2px; font-size: 22px; }
.brand-mark { font-size: 34px; }
.auth-foot { text-align: center; margin-top: 18px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; color: var(--muted); }
.field input {
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
.field input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.code-input {
  text-align: center;
  letter-spacing: 8px;
  font-size: 22px;
  font-weight: 700;
}

.steps { padding-inline-start: 20px; color: var(--muted); font-size: 14px; }
.qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  margin: 14px auto;
  width: 268px;
  min-height: 268px;
}
.manual { margin: 6px 0 14px; font-size: 13px; }
.manual summary { cursor: pointer; color: var(--muted); }
.secret {
  display: block;
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-2);
  border-radius: 6px;
  word-break: break-all;
  font-family: monospace;
}

/* ---------- app layout ---------- */
body.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-inline-start: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand .brand-mark { font-size: 26px; }
.brand-name { font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.disabled { opacity: .5; cursor: default; }
.nav-item.disabled:hover { background: transparent; color: var(--muted); }
.nav-icon { font-size: 17px; }
.soon {
  margin-inline-start: auto;
  font-size: 10px;
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 6px;
}

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; }
.who { display: flex; align-items: center; gap: 8px; padding: 4px 8px 12px; font-size: 14px; }

.content { flex: 1; padding: 28px 32px; max-width: 1100px; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 { margin: 0 0 2px; font-size: 22px; }
.page-head p { margin: 0; font-size: 14px; }

/* ---------- card + table ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 13px 16px;
  text-align: start;
  border-bottom: 1px solid var(--border);
}
.table th { font-size: 13px; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--panel-2); }
.label-cell { font-weight: 600; }
.phone-cell { font-family: monospace; color: var(--muted); }
.empty-row td { text-align: center; color: var(--muted); padding: 30px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.status-connected    { background: rgba(45,164,78,.15);  color: #79d99a; }
.status-connected::before    { background: var(--primary); }
.status-disconnected { background: rgba(240,162,60,.15); color: #f0c184; }
.status-disconnected::before { background: var(--accent); }
.status-not_linked, .status-unknown { background: var(--panel-2); color: var(--muted); }
.status-not_linked::before, .status-unknown::before { background: var(--muted); }

.hint { margin-top: 14px; font-size: 13px; }

.placeholder-card { text-align: center; padding: 56px 24px; }
.placeholder-icon { font-size: 52px; opacity: .55; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
  text-align: center;
}
.modal-close {
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.modal-step h2 { margin: 4px 0 12px; font-size: 19px; }
.modal-step .field { text-align: start; margin: 14px 0; }
.modal-step .steps { text-align: start; margin: 12px 0; }
.modal-step .btn + .btn { margin-top: 8px; }

.qr-box { transition: opacity .25s; }
.qr-timer {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
}
.qr-timer span { font-size: 16px; }

.done-mark, .error-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 4px auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
}
.done-mark  { background: rgba(45,164,78,.18);  color: var(--primary); }
.error-mark { background: rgba(210,68,74,.18); color: var(--danger); }

/* spinner */
.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid rgba(0,0,0,.12);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  body.app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .content { padding: 20px 16px; }
}
