/* ============================================================
   Barcode SaaS 2026 — Shared Styles
   [AR] هوية بصرية مستوحاة من "لفّة": خط Tajawal، RTL، ثيم كحلي + وضع ليلي
   [EN] Visual identity inspired by "Laffa": Tajawal, RTL, navy theme + dark mode
   ============================================================ */

/* ---------- Theme tokens ---------- */
:root {
  --navy:        #1a2347;
  --navy-2:      #232c5a;
  --primary:     #3b4990;
  --primary-600: #4f5ba0;
  --accent:      #d97706;
  --success:     #047857;
  --danger:      #be185d;
  --warning:     #ea580c;

  --bg:          #f4f6fb;
  --surface:     #ffffff;
  --surface-2:   #eef1f8;
  --text:        #1a2347;
  --text-muted:  #5b6480;
  --border:      #e2e6f0;
  --shadow:      0 8px 24px rgba(26, 35, 71, 0.08);
  --radius:      14px;
}

[data-theme="dark"] {
  --bg:         #141a33;
  --surface:    #1a2347;
  --surface-2:  #232c5a;
  --text:       #eef1f8;
  --text-muted: #9aa3c4;
  --border:     #2e3866;
  --shadow:     0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Tajawal', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}

/* ---------- Auth background (login/register) ---------- */
.auth-bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(circle at 20% 20%, rgba(79,91,160,.4) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(59,73,144,.4) 0%, transparent 50%),
    linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
}

/* ---------- Layout ---------- */
.center-screen {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center; padding: 24px;
}
.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card-title { font-weight: 800; font-size: 1.05rem; margin-bottom: 14px; }

/* ---------- Auth card ---------- */
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  padding: 34px 30px;
}
.brand { text-align: center; margin-bottom: 22px; }
.brand-logo {
  width: 76px; height: 76px; margin: 0 auto 12px;
  background: var(--navy); color: #fff;
  border-radius: 18px; display: grid; place-items: center;
  font-size: 34px; font-weight: 900;
}
.brand h1 { font-size: 1.3rem; }
.brand p  { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; font-size: .88rem; margin-bottom: 6px; }
.input, select, textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 11px; background: var(--surface);
  color: var(--text); font-family: inherit; font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,73,144,.15);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border: none; border-radius: 11px;
  font-family: inherit; font-weight: 700; font-size: .95rem;
  cursor: pointer; transition: transform .08s, opacity .15s, background .15s;
  background: var(--surface-2); color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ghost   { background: transparent; border: 1.5px solid var(--border); }
.btn-sm { padding: 7px 12px; font-size: .85rem; border-radius: 9px; }

/* ---------- Links / helpers ---------- */
.link { color: var(--primary); cursor: pointer; font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 24px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hidden { display: none !important; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700;
}
.badge-trial   { background: #fef3c7; color: #92400e; }
.badge-active  { background: #d1fae5; color: #065f46; }
.badge-expired { background: #fee2e2; color: #991b1b; }
.badge-on      { background: #d1fae5; color: #065f46; }
.badge-off     { background: #fee2e2; color: #991b1b; }

/* ---------- Stat cards (KPIs) ---------- */
.stat { text-align: center; }
.stat .num { font-size: 2rem; font-weight: 900; color: var(--primary); }
.stat .label { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }

/* ---------- Top nav ---------- */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar .logo { display: flex; align-items: center; gap: 10px; font-weight: 900; }
.topbar .logo .mark {
  width: 36px; height: 36px; background: var(--navy); color: #fff;
  border-radius: 10px; display: grid; place-items: center; font-weight: 900;
}
.nav-links { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-links a {
  padding: 8px 14px; border-radius: 10px; text-decoration: none;
  color: var(--text-muted); font-weight: 700; font-size: .9rem;
}
.nav-links a.active, .nav-links a:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 22px;
  border-radius: 12px; box-shadow: var(--shadow); z-index: 999;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ---------- Spinner ---------- */
.spinner {
  width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  background: var(--surface-2); border: 1px solid var(--border);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  display: grid; place-items: center; font-size: 1.05rem;
}

/* ---------- QR preview ---------- */
.qr-preview {
  display: grid; place-items: center; padding: 18px;
  background: var(--surface-2); border-radius: var(--radius); min-height: 240px;
}

/* ============================================================
   Sidebar layout (Laffa-style) — sticky right card + content panels
   ============================================================ */
.layout { display: flex; gap: 18px; max-width: 1300px; margin: 0 auto; padding: 18px; align-items: flex-start; }

.sidebar {
  position: sticky; top: 82px; align-self: flex-start; width: 250px; flex-shrink: 0;
  background: linear-gradient(170deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border); border-radius: 20px; padding: 14px 12px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 3px;
  max-height: calc(100vh - 100px); overflow-y: auto;
}
.sidebar .brand-row {
  display: flex; align-items: center; gap: 9px; font-weight: 900; font-size: .98rem;
  color: var(--text); padding: 4px 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.sidebar .brand-row .mark {
  width: 36px; height: 36px; background: var(--navy); color: #fff; border-radius: 10px;
  display: grid; place-items: center; font-weight: 900; overflow: hidden; flex-shrink: 0;
}

.profile {
  display: flex; align-items: center; gap: 11px; padding: 11px; border-radius: 14px; margin-bottom: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color: #fff; box-shadow: 0 6px 16px rgba(59,73,144,.3);
}
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  font-size: 1.25rem; font-weight: 900; background: rgba(255,255,255,.22); color: #fff; overflow: hidden;
}
.profile .pinfo { min-width: 0; }
.profile .pname { font-weight: 800; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile .prole { font-size: .76rem; opacity: .85; }

.nav-group-label {
  font-size: .7rem; font-weight: 800; color: var(--text-muted); opacity: .7;
  letter-spacing: .4px; padding: 10px 12px 4px;
}
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  text-align: right; padding: 11px 13px; border: none; border-radius: 12px; width: 100%;
  background: transparent; color: var(--text); font-family: inherit; font-weight: 700; font-size: .9rem;
  cursor: pointer; transition: all .18s; display: flex; align-items: center; gap: 10px;
  border-right: 3px solid transparent;
}
.nav-item .nav-ic { font-size: 1rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); border-right-color: var(--primary); transform: translateX(-3px); }
.nav-item.active {
  background: linear-gradient(90deg, var(--primary), var(--primary-600));
  color: #fff; border-right-color: #fde68a; box-shadow: 0 4px 14px rgba(59,73,144,.35);
}

.side-bottom {
  margin-top: 12px; display: flex; gap: 8px; align-items: center;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.side-bottom .btn { flex: 1; }

.content { flex: 1; min-width: 0; }
.content .container { padding: 0; max-width: none; }

/* tab panels */
/* [AR] إخفاء الأقسام غير النشطة فقط — يحافظ على تخطيط grid عند التفعيل */
.panel:not(.active) { display: none; }

@media (max-width: 820px) {
  .layout { flex-direction: column; padding: 12px; gap: 12px; }
  .sidebar {
    position: sticky; top: 6px; z-index: 50; width: 100%; max-height: none;
    flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
  }
  .sidebar .brand-row { display: none; }
  .profile { flex: 0 0 auto; margin-bottom: 0; padding: 8px 12px; }
  .profile .pinfo { display: none; }
  .nav-group-label { display: none; }
  .side-nav { flex-direction: row; flex-wrap: nowrap; }
  .nav-item { flex: 0 0 auto; border-right: none; border-bottom: 3px solid transparent; }
  .nav-item:hover { transform: none; }
  .side-bottom { margin-top: 0; border-top: none; padding-top: 0; }
}

/* ============================================================
   Top header (Laffa-style)
   ============================================================ */
.app-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff;
  padding: 10px 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  position: sticky; top: 0; z-index: 80; box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.hbrand { display: flex; align-items: center; gap: 12px; }
.hlogo {
  width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,.12);
  display: grid; place-items: center; font-weight: 900; font-size: 17px; overflow: hidden; flex-shrink: 0;
}
.hlogo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.htitle { font-size: 1.02rem; font-weight: 900; }
.hsub { font-size: .72rem; color: rgba(255,255,255,.7); }
.hactions { display: flex; gap: 10px; align-items: center; }
.gsearch {
  width: 240px; max-width: 38vw; padding: 9px 14px; border-radius: 11px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
  color: #fff; font-family: inherit; font-size: .9rem; transition: width .15s, background .15s;
}
.gsearch::placeholder { color: rgba(255,255,255,.6); }
.gsearch:focus { outline: none; background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.4); }
.h-icon-btn {
  width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2); color: #fff; cursor: pointer; display: grid; place-items: center; font-size: 1rem;
}
.live-ind { font-size: .72rem; color: rgba(255,255,255,.75); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.btn-logout {
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.2);
  padding: 8px 16px; border-radius: 10px; font-family: inherit; font-weight: 700; cursor: pointer;
}
.btn-logout:hover { background: rgba(239,68,68,.25); border-color: rgba(239,68,68,.5); }
@media (max-width: 720px) { .hsub { display: none; } .gsearch { width: 130px; } .live-ind span:last-child { display: none; } }

/* sidebar title (لوحة التحكم) */
.sidebar-title {
  font-weight: 800; font-size: .8rem; color: var(--text-muted); padding: 4px 10px 9px;
  margin-bottom: 4px; border-bottom: 1px solid var(--border); display: flex; gap: 6px; align-items: center;
}

/* ============================================================
   Footer (developer credit)
   ============================================================ */
.app-footer {
  text-align: center; padding: 22px 16px; margin-top: 28px; border-top: 1px solid var(--border);
  font-size: .78rem; color: var(--text-muted);
}
.app-footer .fcredit { margin-top: 6px; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.app-footer .fdev { font-weight: 800; color: var(--text); }
.app-footer a { color: var(--primary); }

/* ============================================================
   Overview + client cards
   ============================================================ */
.overview-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.overview-head h2 { font-size: 1.18rem; }

.client-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cc-name { font-weight: 800; font-size: 1.02rem; }
.cc-url { font-size: .76rem; color: var(--text-muted); }
.cc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cc-detail { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.copy-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.copy-row code { background: var(--surface-2); padding: 4px 8px; border-radius: 8px; font-size: .8rem; word-break: break-all; }

.ann-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--surface); }

/* ===== Marketing occasions ticker ===== */
.ticker { overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 10px 0; }
.ticker-track { display: inline-flex; white-space: nowrap; gap: 10px; animation: ticker 32s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.ticker-item { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: var(--surface-2); font-weight: 700; font-size: .9rem; }
.tk-badge { background: #fef3c7; color: #92400e; padding: 2px 9px; border-radius: 999px; font-size: .76rem; }

/* ===== type hint ===== */
.type-hint { font-size: .8rem; color: var(--text-muted); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; line-height: 1.7; }
