/* ── Variables ──────────────────────────────────────────── */
:root {
  --primary:       #25D366;
  --primary-dark:  #128C7E;
  --primary-light: #d1fae5;
  --sidebar-bg:    #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-text:  #94a3b8;
  --sidebar-active:#25D366;
  --body-bg:       #f1f5f9;
  --card-bg:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --success:       #22c55e;
  --success-light: #dcfce7;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,.1);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.12);
  --radius:        10px;
  --radius-sm:     6px;
  --sidebar-width: 240px;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--body-bg);
  -webkit-font-smoothing: antialiased;
}

body { overflow-y: auto; }

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Auth pages ─────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  padding: 24px;
}

.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .logo-icon {
  width: 52px;
  height: 52px;
  background: var(--primary);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.auth-logo .logo-icon svg { width: 28px; height: 28px; fill: #fff; }

.auth-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.auth-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--primary-dark);
  font-weight: 500;
}

/* ── Auth page language switcher ───────────────────────────── */
.auth-card { position: relative; }

.auth-lang {
  position: absolute;
  top: 14px;
  right: 14px;
}

.auth-lang-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}

.auth-lang-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}

.auth-lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 155px;
  z-index: 200;
  overflow: hidden;
}

.auth-lang-menu.open { display: block; }

.auth-lang-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 13px;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background .1s;
}

.auth-lang-menu button:hover { background: var(--hover); }
.auth-lang-menu button.active { color: var(--primary); font-weight: 600; }

/* ── Password strength meter ─────────────────────────────── */
.pw-meter {
  display: none;
  margin-top: 10px;
}
.pw-meter.visible { display: block; }

.pw-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.pw-segs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.pw-seg {
  height: 4px;
  flex: 1;
  border-radius: 2px;
  background: #e2e8f0;
  transition: background .25s;
}

.pw-seg.s-weak    { background: #ef4444; }
.pw-seg.s-fair    { background: #f59e0b; }
.pw-seg.s-good    { background: #3b82f6; }
.pw-seg.s-strong  { background: #22c55e; }

.pw-strength-label {
  font-size: 12px;
  font-weight: 600;
  width: 46px;
  text-align: right;
  flex-shrink: 0;
  transition: color .25s;
}

.pw-rules {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  margin: 0;
  padding: 0;
}

.pw-rule {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #94a3b8;
  transition: color .2s;
}

.pw-rule .pw-ic-circle { display: block; }
.pw-rule .pw-ic-check  { display: none; }

.pw-rule.ok {
  color: #22c55e;
}
.pw-rule.ok .pw-ic-circle { display: none; }
.pw-rule.ok .pw-ic-check  { display: block; }

.pw-rule svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.auth-footer a:hover { text-decoration: underline; }

/* ── Dashboard layout ───────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo .logo-icon svg { width: 40px; height: 40px; fill: #fff; }

.sidebar-logo span {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.nav-item.active {
  background: rgba(37,211,102,.15);
  color: var(--sidebar-active);
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: .7;
}

.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13px;
}

.sidebar-user .avatar {
  width: 32px;
  height: 32px;
  background: var(--primary-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 11px; color: #475569; margin-top: 1px; }

.logout-btn {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  width: 100%;
  margin-top: 4px;
  transition: background .15s, color .15s, border-color .15s;
  cursor: pointer;
}

.logout-btn:hover { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.3); color: #ef4444; }
.logout-btn svg { width: 15px; height: 15px; }

.lang-switcher {
  position: relative;
  padding: 0 8px;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid rgba(255,255,255,.1);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.lang-btn:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
  border-color: rgba(255,255,255,.2);
}

.lang-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 8px;
  right: 8px;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  padding: 4px;
  box-shadow: 0 -8px 24px rgba(0,0,0,.4);
  z-index: 200;
}

.lang-menu.open { display: block; }

.lang-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65);
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, color .12s;
}

.lang-menu button:hover { background: rgba(255,255,255,.07); color: #e2e8f0; }
.lang-menu button.active { color: var(--sidebar-active); font-weight: 600; }

/* RTL: move sidebar to right side */
[dir="rtl"] .sidebar { left: auto; right: 0; }
[dir="rtl"] .main   { margin-left: 0; margin-right: var(--sidebar-width); }

/* ── Main content ───────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.topbar-plan {
  display: flex;
  align-items: center;
  gap: 8px;
}

.plan-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1.5px solid;
  white-space: nowrap;
  line-height: 1;
}
.plan-pill svg { flex-shrink: 0; }
.plan-pill.pp-trial    { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.plan-pill.pp-expiring { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.plan-pill.pp-expired  { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.plan-pill.pp-active   { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

.plan-pill-action {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-dark);
  text-decoration: none;
  white-space: nowrap;
}
.plan-pill-action:hover { text-decoration: underline; }

/* ── Account context switcher ─────────────────────────────── */
.ctx-switcher {
  position: relative;
}

.ctx-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s;
}

.ctx-btn:hover { border-color: var(--primary); }

.ctx-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 300;
  overflow: hidden;
}

.ctx-menu.open { display: block; }

.ctx-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background .1s;
}

.ctx-menu button:hover { background: var(--hover); }
.ctx-menu button.active { color: var(--primary); font-weight: 700; }

.content {
  padding: 32px;
  flex: 1;
}

/* ── Stat cards ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.green  { background: var(--primary-light); color: var(--primary-dark); }
.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-info .stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-info .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.card-body { padding: 24px; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

tbody td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

tbody tr.clickable { cursor: pointer; }

.table-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.table-empty svg { width: 40px; height: 40px; opacity: .3; margin-bottom: 10px; }
.table-empty p { font-size: 14px; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

label .required { color: var(--danger); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,211,102,.15);
}

input::placeholder, textarea::placeholder { color: #c0cad8; }

textarea { resize: vertical; min-height: 90px; }

select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.error-msg {
  display: none;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid #fca5a5;
}

.success-msg {
  display: none;
  background: var(--success-light);
  color: #15803d;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid #86efac;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1.5px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  outline: none;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }

.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-green   { background: var(--primary-light); color: var(--primary-dark); }
.badge-red     { background: var(--danger-light);  color: #b91c1c; }
.badge-orange  { background: var(--warning-light); color: #92400e; }
.badge-blue    { background: #dbeafe; color: #1d4ed8; }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-purple  { background: #ede9fe; color: #6d28d9; }

/* ── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in .2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  max-width: 340px;
}

.toast.toast-visible { opacity: 1; transform: translateY(0); }
.toast-success { background: #0f172a; color: #fff; }
.toast-error   { background: var(--danger); color: #fff; }
.toast-info    { background: #1d4ed8; color: #fff; }

/* ── Copy snippet ───────────────────────────────────────── */
.snippet-box {
  background: #0f172a;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: 'Courier New', monospace;
  font-size: 12.5px;
  color: #7dd3fc;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.6;
}

/* ── Utilities ──────────────────────────────────────────── */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 12.5px; }
.text-right  { text-align: right; }
.font-mono   { font-family: 'Courier New', monospace; }
.truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .content { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
