/* Finora - Modern Arabic RTL fintech dashboard */
:root {
  color-scheme: dark;
  font-family: 'Cairo', sans-serif;
  --bg: #090b14;
  --panel: rgba(14, 18, 31, 0.92);
  --panel-strong: rgba(20, 27, 48, 0.95);
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef2ff;
  --muted: #8b96af;
  --primary: #00ffb2;
  --secondary: #8e6cff;
  --accent: #00c2ff;
  --danger: #ff4d4d;
  --success: #22c55e;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  --transition: all 0.25s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  background: radial-gradient(circle at top left, rgba(0, 255, 178, 0.08), transparent 28%),
              linear-gradient(180deg, #0c0f1d 0%, #080a12 100%);
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}
button, input { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 300px) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  padding: 2rem 1.4rem;
  background: rgba(10, 13, 28, 0.88);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  font-size: 1.35rem;
  color: #06101c;
  font-weight: 800;
}
.sidebar-brand h1 {
  font-size: 1.2rem;
  margin-bottom: 0.15rem;
}
.sidebar-brand p {
  color: var(--muted);
  font-size: 0.85rem;
}

.sidebar-nav {
  display: grid;
  gap: 0.5rem;
}
.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  transition: var(--transition);
}
.nav-link i {
  width: 24px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--primary);
}
.nav-link span { font-weight: 600; }
.nav-link:hover,
.nav-link.active {
  background: rgba(0, 255, 178, 0.1);
  border-color: rgba(0, 255, 178, 0.18);
  color: var(--primary);
}

.sidebar-footer {
  margin-top: auto;
}
.profile-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
}
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--secondary), var(--accent));
  color: #081017;
  font-weight: 700;
}
.profile-card strong {
  display: block;
  margin-bottom: 0.2rem;
}
.profile-card p {
  color: var(--muted);
  font-size: 0.9rem;
}

.main-area {
  padding: 2rem 2.2rem;
  position: relative;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.8rem;
}
.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.search-box i { color: var(--muted); }
.search-box input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.icon-btn,
.avatar-btn {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  display: grid;
  place-items: center;
  transition: var(--transition);
}
.icon-btn:hover,
.avatar-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(0, 255, 178, 0.12);
}
.avatar-btn {
  padding: 0 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  justify-content: center;
}
.badge-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.page {
  display: none;
}
.page.active {
  display: block;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.8rem;
}
.page-header h2 {
  font-size: 2rem;
}
.page-description,
.eyebrow {
  color: var(--muted);
}
.eyebrow {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
}
.status-chip {
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.stats-grid,
.dashboard-grid,
.settings-grid {
  display: grid;
  gap: 1.25rem;
}
.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1.5rem;
}
.dashboard-grid {
  grid-template-columns: 1.5fr 1fr;
  margin-bottom: 1.5rem;
}
.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}
.chart-card,
.allocation-card,
.asset-table-card,
.watchlist-card,
.setting-card {
  min-height: 300px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}
.stat-card strong {
  font-size: 1.6rem;
}
.stat-title {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.card-header h3 {
  margin-bottom: 0.3rem;
}
.card-header p {
  color: var(--muted);
}
.filter-group,
.toggle-group {
  display: inline-flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.filter-btn,
.toggle-btn,
.btn,
.btn-secondary,
.btn-ghost {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  background: transparent;
  color: var(--text);
  transition: var(--transition);
}
.filter-btn.active,
.toggle-btn.active,
.btn:hover,
.btn-secondary:hover,
.btn-ghost:hover {
  background: rgba(0, 255, 178, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}
.btn {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #081017;
  border-color: transparent;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
}
.btn-ghost {
  background: none;
}
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--muted) !important; }
.badge { display: inline-flex; align-items: center; gap: 0.4rem; border-radius: 999px; padding: 0.35rem 0.75rem; font-size: 0.8rem; background: rgba(255,255,255,0.06); color: var(--text); }
.badge-accent { background: rgba(0, 255, 178, 0.12); color: var(--primary); }

.chart-card canvas {
  width: 100%;
  height: 320px;
  border-radius: 24px;
}
.allocation-content {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1.4rem;
  align-items: center;
}
.allocation-legend {
  display: grid;
  gap: 1rem;
}
.allocation-legend .legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}
.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
}
table.data-table th,
table.data-table td {
  text-align: left;
  padding: 1rem 0.75rem;
  font-size: 0.95rem;
}
table.data-table thead th {
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
table.data-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.table-wrap {
  overflow-x: auto;
}
.watchlist-grid,
.asset-card-grid {
  display: grid;
  gap: 1rem;
}
.watchlist-item,
.asset-card {
  padding: 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.watchlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.watchlist-item strong {
  font-size: 1rem;
}
.asset-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}
.asset-card .asset-info { display: flex; flex-direction: column; gap: 0.25rem; }
.asset-card .asset-price { text-align: left; }
.asset-card span { color: var(--muted); }
.asset-card strong {
  font-size: 1.25rem;
}
.asset-card small {
  color: var(--muted);
}
.assets-card .trend {
  font-weight: 700;
}

.fund-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.fund-controls input {
  flex: 1;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}
.fund-controls input::placeholder { color: var(--muted); }
.funds-view {
  display: grid;
  gap: 1rem;
}
.fund-card {
  padding: 1.25rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.fund-card-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.fund-card-header strong {
  font-size: 1rem;
}
.fund-card-chart {
  height: 50px;
}
.fund-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.setting-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.switch {
  position: relative;
  width: 56px;
  height: 30px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  transition: var(--transition);
}
.slider::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: var(--transition);
}
input:checked + .slider { background: linear-gradient(135deg, var(--primary), var(--accent)); }
input:checked + .slider::after { right: auto; left: 4px; }

.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 0.75rem;
  z-index: 2000;
}
.toast {
  min-width: 280px;
  padding: 0.95rem 1.2rem;
  border-radius: 18px;
  background: rgba(10, 15, 26, 0.96);
  border: 1px solid rgba(0, 255, 178, 0.15);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 18, 0.8);
  display: grid;
  place-items: center;
  gap: 1rem;
  color: var(--text);
  z-index: 3000;
}
.loading-overlay.hidden { display: none; }
.loader {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; width: 100%; }
  .stats-grid,
  .dashboard-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .allocation-content { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .main-area { padding: 1.2rem; }
  .topbar { flex-wrap: wrap; }
  .search-box { width: 100%; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .asset-card-grid,
  .watchlist-grid,
  .funds-view { grid-template-columns: 1fr; }
  .sidebar { position: relative; }
}
