@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #7C3AED;
  --primary-dark: #5B21B6;
  --primary-light: #A78BFA;
  --primary-glow: rgba(124, 58, 237, 0.3);
  --bg: #0D0D14;
  --bg-2: #13131F;
  --bg-3: #1A1A2E;
  --bg-card: #16162A;
  --bg-input: #1E1E35;
  --border: rgba(124, 58, 237, 0.2);
  --border-light: rgba(255,255,255,0.06);
  --text: #F0EFFF;
  --text-2: #A8A4CC;
  --text-3: #5E5A7A;
  --success: #10B981;
  --error: #EF4444;
  --warning: #F59E0B;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-purple: 0 4px 24px rgba(124,58,237,0.25);
}

[data-theme="light"] {
  --bg: #F5F4FF;
  --bg-2: #EDEEFF;
  --bg-3: #E5E3FF;
  --bg-card: #FFFFFF;
  --bg-input: #F0EEFF;
  --border: rgba(124, 58, 237, 0.2);
  --border-light: rgba(0,0,0,0.06);
  --text: #1A1033;
  --text-2: #4B4570;
  --text-3: #9490B5;
}

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

html { font-size: 16px; }

body {
  font-family: 'Vazirmatn', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: inherit;
  text-align: start;
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'Vazirmatn', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-purple);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-light);
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }

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

.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-full { width: 100%; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* Inputs */
.input-group { margin-bottom: 18px; }
.input-group label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.9rem;
  color: var(--text-2);
  font-weight: 500;
}
.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Vazirmatn', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  direction: inherit;
}
.input[dir="ltr"] { direction: ltr; }
.input[dir="rtl"] { direction: rtl; }
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.input::placeholder { color: var(--text-3); }
textarea.input { resize: vertical; min-height: 90px; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  min-width: 260px;
  animation: slideUp 0.3s ease;
  box-shadow: var(--shadow);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.info { background: var(--primary); }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 440px;
  width: 100%;
  animation: scaleIn 0.2s ease;
}
.modal h3 { font-size: 1.2rem; margin-bottom: 12px; }
.modal p { color: var(--text-2); margin-bottom: 24px; font-size: 0.95rem; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  direction: inherit;
  padding: 0 24px;
  height: 64px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary-light);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.navbar-brand span { color: var(--text); }
.navbar-actions {
  display: flex;
  align-items: center;
  direction: inherit;
  gap: 12px;
  min-width: 0;
}

/* Avatar */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; }
.avatar-lg { width: 52px; height: 52px; }
.avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.85em;
  text-transform: uppercase;
  user-select: none;
}

/* Loading */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 20px 0;
}

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.auth-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center;
  margin-bottom: 30px;
}
.auth-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-light);
}
.auth-logo p { color: var(--text-2); font-size: 0.9rem; margin-top: 5px; }
.auth-footer {
  text-align: center;
  margin-top: 20px;
  color: var(--text-2);
  font-size: 0.9rem;
}
.auth-footer a { color: var(--primary-light); text-decoration: none; }

[dir="ltr"] .auth-box,
[dir="ltr"] .modal,
[dir="ltr"] .card {
  text-align: left;
}

[dir="ltr"] .auth-logo,
[dir="ltr"] .auth-footer {
  text-align: left;
}

/* Alert */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }

/* Theme toggle */
.theme-toggle {
  background: var(--bg-3);
  border: 1px solid var(--border-light);
  color: var(--text-2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s;
}
.theme-toggle:hover { background: var(--bg-input); color: var(--text); }

/* Language switcher (used in navbar across all pages) */
.lang-switcher { display: inline-flex; align-items: center; }
.lang-select {
  background: var(--bg-3);
  border: 1px solid var(--border-light);
  color: var(--text-2);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.lang-select:hover { border-color: var(--primary); }

/* Responsive */
@media (max-width: 600px) {
  .auth-box { padding: 28px 20px; }
  .navbar { padding: 0 16px; }
}
