/* ============================================================
   SMS Portal — Liquid Glass design system (Apple-style, RTL)
   ============================================================ */

:root {
  /* Liquid glass surfaces */
  --glass-bg: rgba(255, 255, 255, 0.10);
  --glass-bg-strong: rgba(255, 255, 255, 0.16);
  --glass-border: rgba(255, 255, 255, 0.22);
  --glass-highlight: rgba(255, 255, 255, 0.55);
  --glass-shadow: 0 10px 40px rgba(0, 0, 0, 0.28);
  --glass-blur: 28px;

  /* Text */
  --text: #f4f6fb;
  --text-dim: rgba(244, 246, 251, 0.66);
  --text-faint: rgba(244, 246, 251, 0.40);

  /* Accents */
  --accent: #0a84ff;      /* iOS blue */
  --accent-2: #5e5ce6;    /* indigo */
  --accent-grad: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 100%);
  --green: #30d158;
  --red: #ff453a;
  --orange: #ff9f0a;
  --pink: #ff375f;

  --radius: 22px;
  --radius-sm: 14px;
  --radius-lg: 30px;

  --font: -apple-system, "SF Pro Display", "SF Pro Text", "Segoe UI",
          "Helvetica Neue", "Assistant", "Rubik", system-ui, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow-x: hidden;
  background: #0b1020;
  position: relative;
}

/* ---------- Animated aurora background ---------- */
.bg-aurora {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background:
    radial-gradient(1200px 900px at 15% 10%, #1c2b6b 0%, transparent 55%),
    radial-gradient(1000px 800px at 90% 20%, #6a1f7a 0%, transparent 50%),
    radial-gradient(1100px 900px at 70% 95%, #0b4a6f 0%, transparent 55%),
    linear-gradient(160deg, #0b1020 0%, #0a0f1e 100%);
}
.bg-aurora::before,
.bg-aurora::after {
  content: "";
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: float 22s var(--ease) infinite alternate;
}
.bg-aurora::before {
  background: radial-gradient(circle, #0a84ff 0%, transparent 60%);
  top: -15%; right: -10%;
}
.bg-aurora::after {
  background: radial-gradient(circle, #ff375f 0%, transparent 60%);
  bottom: -20%; left: -10%;
  animation-duration: 28s;
}
@keyframes float {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(6%, 8%) scale(1.15); }
}

/* Fine noise/grain for realism */
.bg-grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Glass primitive ---------- */
.glass {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow),
              inset 0 1px 0 var(--glass-highlight),
              inset 0 -1px 1px rgba(0,0,0,0.15);
}
/* Specular top highlight — the "liquid" sheen */
.glass::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, transparent 35%);
  pointer-events: none;
  opacity: 0.7;
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 40px 34px;
  animation: rise 0.7s var(--ease);
}
.auth-logo {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  border-radius: 20px;
  background: var(--accent-grad);
  display: grid; place-items: center;
  box-shadow: 0 12px 30px rgba(10,132,255,0.45),
              inset 0 1px 0 rgba(255,255,255,0.5);
}
.auth-logo svg { width: 34px; height: 34px; }
.auth-card h1 { text-align: center; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.auth-card .sub { text-align: center; color: var(--text-dim); margin: 8px 0 28px; font-size: 15px; }

.auth-tabs {
  display: flex;
  background: rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 22px;
  border: 1px solid var(--glass-border);
}
.auth-tabs button {
  flex: 1; padding: 10px; border: 0; background: transparent;
  color: var(--text-dim); font-family: inherit; font-size: 15px; font-weight: 600;
  border-radius: 10px; cursor: pointer; transition: all 0.3s var(--ease);
}
.auth-tabs button.active {
  background: var(--glass-bg-strong); color: var(--text);
  box-shadow: 0 4px 14px rgba(0,0,0,0.25), inset 0 1px 0 var(--glass-highlight);
}

@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- Form controls ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 7px; font-weight: 600; }
.input, textarea, select {
  width: 100%;
  padding: 13px 16px;
  font-family: inherit; font-size: 15px;
  color: var(--text);
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  transition: all 0.25s var(--ease);
  outline: none;
}
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.input::placeholder, textarea::placeholder { color: var(--text-faint); }
.input:focus, textarea:focus, select:focus {
  border-color: rgba(10,132,255,0.7);
  background: rgba(255,255,255,0.11);
  box-shadow: 0 0 0 4px rgba(10,132,255,0.18);
}
select option { color: #111; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px;
  font-family: inherit; font-size: 15px; font-weight: 650;
  color: #fff; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-sm);
  background: var(--glass-bg-strong);
  backdrop-filter: blur(12px);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3), inset 0 1px 0 var(--glass-highlight); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--accent-grad);
  border: 0;
  box-shadow: 0 8px 22px rgba(10,132,255,0.4), inset 0 1px 0 rgba(255,255,255,0.4);
}
.btn-primary:hover { box-shadow: 0 12px 30px rgba(10,132,255,0.55), inset 0 1px 0 rgba(255,255,255,0.4); }
.btn-danger { background: rgba(255,69,58,0.18); border-color: rgba(255,69,58,0.4); color: #ff9a92; }
.btn-danger:hover { background: rgba(255,69,58,0.28); }
.btn-ghost { background: rgba(255,255,255,0.06); }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 11px; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: none; min-height: 100vh; }
.app.active { display: grid; grid-template-columns: 268px 1fr; }

/* Sidebar */
.sidebar {
  margin: 16px;
  padding: 22px 16px;
  display: flex; flex-direction: column;
  position: sticky; top: 16px;
  height: calc(100vh - 32px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 22px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 13px;
  background: var(--accent-grad); display: grid; place-items: center;
  box-shadow: 0 8px 20px rgba(10,132,255,0.4), inset 0 1px 0 rgba(255,255,255,0.5);
  flex-shrink: 0;
}
.brand-logo svg { width: 24px; height: 24px; }
.brand-text b { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text span { display: block; font-size: 12px; color: var(--text-dim); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav::-webkit-scrollbar { width: 0; }
.nav-item {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 14px; border-radius: 13px;
  color: var(--text-dim); cursor: pointer; font-size: 15px; font-weight: 550;
  border: 1px solid transparent;
  transition: all 0.25s var(--ease);
  text-align: right; background: transparent; font-family: inherit; width: 100%;
}
.nav-item svg { width: 21px; height: 21px; flex-shrink: 0; opacity: 0.9; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.nav-item.active {
  background: var(--glass-bg-strong); color: #fff;
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 6px 18px rgba(0,0,0,0.22);
}
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); padding: 16px 14px 6px; font-weight: 700; }

.sidebar-footer { padding-top: 14px; }
.user-chip {
  display: flex; align-items: center; gap: 11px; padding: 11px;
  border-radius: 14px; background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #ff375f, #ff9f0a);
  display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff;
}
.user-chip .info { flex: 1; min-width: 0; }
.user-chip .info b { font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .info span { font-size: 12px; color: var(--text-dim); }

/* Main */
.main { padding: 24px 30px 60px; overflow-x: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; gap: 16px; flex-wrap: wrap; }
.topbar h2 { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; }
.topbar .muted { color: var(--text-dim); font-size: 14px; margin-top: 3px; }

.view { display: none; animation: fade 0.45s var(--ease); }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Cards / grids */
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { padding: 22px 24px; }
.card h3 { font-size: 17px; font-weight: 680; margin-bottom: 4px; }
.card .card-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 18px; }

/* Stat tiles */
.stat { padding: 22px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; position: relative; }
.stat .icon {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  margin-bottom: 8px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}
.stat .icon svg { width: 23px; height: 23px; }
.stat .value { font-size: 34px; font-weight: 760; letter-spacing: -0.03em; line-height: 1; }
.stat .label { color: var(--text-dim); font-size: 14px; }
.i-blue { background: rgba(10,132,255,0.25); color: #6bb6ff; }
.i-green { background: rgba(48,209,88,0.22); color: #6ee38a; }
.i-orange { background: rgba(255,159,10,0.22); color: #ffc165; }
.i-pink { background: rgba(255,55,95,0.22); color: #ff7a9a; }
.i-indigo { background: rgba(94,92,230,0.28); color: #9d9bff; }

/* Segmented control */
.segmented {
  display: inline-flex; background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border); border-radius: 14px; padding: 4px; margin-bottom: 22px;
}
.segmented button {
  padding: 9px 18px; border: 0; background: transparent; color: var(--text-dim);
  font-family: inherit; font-size: 14px; font-weight: 600; border-radius: 10px; cursor: pointer;
  transition: all 0.3s var(--ease);
}
.segmented button.active {
  background: var(--glass-bg-strong); color: #fff;
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 4px 12px rgba(0,0,0,0.2);
}

.segmented.mini { margin-bottom: 0; padding: 3px; border-radius: 11px; }
.segmented.mini button { padding: 6px 14px; font-size: 13px; border-radius: 8px; }

/* Composer: form + live phone preview side by side */
.composer-grid { display: grid; grid-template-columns: 1fr auto; gap: 26px; align-items: start; }
.composer-grid > .card { max-width: 640px; }
.composer-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  font-size: 13px; color: var(--text-dim); margin-top: 4px;
  padding: 10px 14px; background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border); border-radius: 12px; min-height: 42px;
}
.composer-meta:empty { display: none; }

/* iPhone-style live preview */
.phone-wrap { position: sticky; top: 20px; display: flex; justify-content: center; }
.phone {
  position: relative; width: 300px; height: 600px; border-radius: 46px;
  background: linear-gradient(160deg, #1c1c22, #0c0c10);
  border: 1px solid rgba(255,255,255,0.14); padding: 12px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.14);
}
.phone-notch {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  width: 130px; height: 26px; background: #000; border-radius: 0 0 16px 16px; z-index: 3;
}
.phone-screen {
  width: 100%; height: 100%; border-radius: 36px; overflow: hidden;
  background: linear-gradient(180deg, #0b141a 0%, #0e1a12 100%);
  display: flex; flex-direction: column;
}
.phone-top {
  padding: 40px 14px 14px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(30,32,38,0.72); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.phone-av {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-grad); color: #fff; font-weight: 700; font-size: 20px;
}
.phone-name { font-size: 13px; font-weight: 600; color: #fff; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-body { flex: 1; padding: 18px 14px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.phone-time { text-align: center; font-size: 11px; color: rgba(255,255,255,0.4); margin-bottom: 4px; }
.phone-bubble {
  align-self: flex-start; max-width: 82%; padding: 10px 14px;
  background: #26282e; color: #f0f0f2; border-radius: 18px 18px 18px 5px;
  font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
@media (max-width: 900px) {
  .composer-grid { grid-template-columns: 1fr; }
  .phone-wrap { position: static; margin-top: 8px; }
  .composer-grid > .card { max-width: none; }
}

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 13px 14px; border-bottom: 1px solid rgba(255,255,255,0.08); white-space: nowrap; }
th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.2s; }
tbody tr:hover { background: rgba(255,255,255,0.04); }

/* Badges & pills */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px;
  border-radius: 999px; font-size: 12px; font-weight: 650; border: 1px solid transparent;
}
.badge-green { background: rgba(48,209,88,0.16); color: #6ee38a; border-color: rgba(48,209,88,0.3); }
.badge-red { background: rgba(255,69,58,0.16); color: #ff8a82; border-color: rgba(255,69,58,0.3); }
.badge-blue { background: rgba(10,132,255,0.16); color: #6bb6ff; border-color: rgba(10,132,255,0.3); }
.badge-gray { background: rgba(255,255,255,0.08); color: var(--text-dim); }
.badge-orange { background: rgba(255,159,10,0.16); color: #ffc165; border-color: rgba(255,159,10,0.3); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: rgba(255,255,255,0.06); border: 1px solid var(--glass-border);
  color: var(--text-dim); transition: all 0.2s var(--ease); user-select: none;
}
.chip.on { background: var(--accent-grad); color: #fff; border-color: transparent; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--text-dim); }
.hidden { display: none !important; }

/* Result box */
.result {
  margin-top: 18px; padding: 16px 18px; border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1.6; border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.05); white-space: pre-wrap;
}
.result.ok { border-color: rgba(48,209,88,0.4); background: rgba(48,209,88,0.08); }
.result.err { border-color: rgba(255,69,58,0.4); background: rgba(255,69,58,0.08); }

/* Balance hero */
.balance-hero { text-align: center; padding: 40px; }
.balance-hero .amount { font-size: 58px; font-weight: 800; letter-spacing: -0.04em;
  background: linear-gradient(135deg, #6ee38a, #30d158); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent; line-height: 1; }
.balance-hero .cur { font-size: 15px; color: var(--text-dim); margin-top: 10px; }

/* Progress (quota) */
.progress { height: 9px; border-radius: 999px; background: rgba(255,255,255,0.1); overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; border-radius: 999px; background: var(--accent-grad); transition: width 0.6s var(--ease); }

/* Toast */
.toasts { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  padding: 13px 20px; border-radius: 14px; font-size: 14px; font-weight: 600; color: #fff;
  background: var(--glass-bg-strong); backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 12px 34px rgba(0,0,0,0.4), inset 0 1px 0 var(--glass-highlight);
  animation: toastIn 0.4s var(--ease); max-width: 90vw;
}
.toast.ok { border-color: rgba(48,209,88,0.5); }
.toast.err { border-color: rgba(255,69,58,0.5); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(0.95); } to { opacity: 1; transform: none; } }

/* Modal */
.modal-back {
  position: fixed; inset: 0; z-index: 500; display: none;
  place-items: center; padding: 20px;
  background: rgba(5,8,18,0.6); backdrop-filter: blur(8px);
}
.modal-back.open { display: grid; animation: fade 0.3s var(--ease); }
.modal { width: 100%; max-width: 480px; padding: 28px; animation: rise 0.4s var(--ease); max-height: 90vh; overflow-y: auto; }
.modal h3 { font-size: 20px; font-weight: 720; margin-bottom: 18px; }

/* Empty state */
.empty { text-align: center; padding: 44px 20px; color: var(--text-dim); }
.empty svg { width: 48px; height: 48px; opacity: 0.4; margin-bottom: 12px; }

/* Mobile */
.menu-btn { display: none; }
@media (max-width: 900px) {
  .app.active { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 200; right: 0; top: 0; margin: 0; height: 100vh;
    width: 280px; border-radius: 0 24px 24px 0;
    transform: translateX(100%); transition: transform 0.4s var(--ease);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; }
  .main { padding: 18px 16px 50px; }
  .topbar h2 { font-size: 24px; }
  .balance-hero .amount { font-size: 44px; }
}

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