/* ══════════════════════════════════════════════════
   متغيرات Telegram Theme
   ══════════════════════════════════════════════════ */

:root {
  /* ألوان أساسية */
  --bg-primary: var(--tg-theme-bg-color, #0f0f23);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #1a1a3e);
  --text-primary: var(--tg-theme-text-color, #e8e8ff);
  --text-secondary: var(--tg-theme-hint-color, #8888aa);
  --accent: var(--tg-theme-button-color, #6c5ce7);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #a29bfe);

  /* ألوان مخصصة */
  --gradient-1: #6c5ce7;
  --gradient-2: #a29bfe;
  --gradient-3: #fd79a8;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: rgba(0, 0, 0, 0.3);
  --card-hover: rgba(255, 255, 255, 0.1);
  
  /* فضاء */
  --spacing-xs: 6px;
  --spacing-sm: 12px;
  --spacing-md: 18px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* حدود مدورة */
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-full: 50%;

  /* انتقالات */
  --transition-fast: 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-smooth: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-bounce: 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ══════════════════════════════════════════════════
   إعادة ضبط عامة
   ══════════════════════════════════════════════════ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  direction: rtl;
}

/* ══════════════════════════════════════════════════
   حاوية التطبيق
   ══════════════════════════════════════════════════ */

.app-container {
  max-width: 100%;
  min-height: 100vh;
  padding: var(--spacing-md);
  padding-bottom: var(--spacing-xl);
  position: relative;
  overflow: hidden;
}

/* خلفية متحركة */
.app-container::before {
  content: '';
  position: fixed;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle at 30% 40%,
    rgba(108, 92, 231, 0.08) 0%,
    transparent 50%
  ),
  radial-gradient(
    circle at 70% 60%,
    rgba(253, 121, 168, 0.06) 0%,
    transparent 50%
  );
  animation: bgShift 20s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes bgShift {
  0% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-3%, 3%) rotate(1deg); }
  100% { transform: translate(3%, -2%) rotate(-1deg); }
}

/* ══════════════════════════════════════════════════
   شريط الحالة
   ══════════════════════════════════════════════════ */

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: rgba(46, 213, 115, 0.1);
  border: 1px solid rgba(46, 213, 115, 0.2);
  border-radius: var(--radius-lg);
  width: fit-content;
  margin: 0 auto var(--spacing-lg);
  font-size: 0.8rem;
  color: #2ed573;
  position: relative;
  z-index: 1;
  animation: fadeSlideDown 0.6s ease-out;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: #2ed573;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* ══════════════════════════════════════════════════
   قسم البطل (Hero)
   ══════════════════════════════════════════════════ */

.hero-section {
  text-align: center;
  padding: var(--spacing-lg) 0 var(--spacing-xl);
  position: relative;
  z-index: 1;
}

.hero-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 250px;
  height: 250px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(108, 92, 231, 0.2), transparent 70%);
  filter: blur(40px);
  pointer-events: none;
  animation: glowPulse 4s ease-in-out infinite alternate;
}

@keyframes glowPulse {
  0% { opacity: 0.5; transform: translate(-50%, -50%) scale(0.9); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

/* الأفاتار */
.avatar-container {
  position: relative;
  width: 90px;
  height: 90px;
  margin: 0 auto var(--spacing-md);
  animation: fadeScaleIn 0.7s ease-out;
}

.avatar {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-3));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: white;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-3)) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: ringRotate 6s linear infinite;
}

@keyframes ringRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.greeting {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: var(--spacing-xs);
  background: linear-gradient(135deg, var(--text-primary), var(--gradient-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fadeSlideUp 0.7s ease-out 0.2s both;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 300;
  animation: fadeSlideUp 0.7s ease-out 0.3s both;
}

/* ══════════════════════════════════════════════════
   البطاقات
   ══════════════════════════════════════════════════ */

.cards-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  position: relative;
  z-index: 1;
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  transition: all var(--transition-smooth);
  animation: fadeSlideUp 0.6s ease-out both;
}

.glass-card:nth-child(1) { animation-delay: 0.1s; }
.glass-card:nth-child(2) { animation-delay: 0.2s; }
.glass-card:nth-child(3) { animation-delay: 0.3s; }

.glass-card:active {
  transform: scale(0.985);
}

.card-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.card-icon {
  font-size: 1.5rem;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(162, 155, 254, 0.1));
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* صفوف المعلومات */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.info-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  direction: ltr;
  text-align: left;
}

/* ══════════════════════════════════════════════════
   الأزرار
   ══════════════════════════════════════════════════ */

.action-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  width: 100%;
  padding: 14px var(--spacing-md);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  text-align: right;
  direction: rtl;
}

.action-btn::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05));
  transition: width var(--transition-smooth);
}

.action-btn:active {
  transform: scale(0.97);
}

.action-btn:active::before {
  width: 100%;
}

.btn-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.btn-text {
  flex: 1;
}

.btn-arrow {
  font-size: 0.8rem;
  opacity: 0.4;
  transition: all var(--transition-fast);
}

.action-btn:active .btn-arrow {
  opacity: 1;
  transform: translateX(-4px);
}

/* أنواع الأزرار */
.primary-btn {
  border-color: rgba(108, 92, 231, 0.3);
  background: rgba(108, 92, 231, 0.1);
}

.secondary-btn {
  border-color: rgba(46, 213, 115, 0.3);
  background: rgba(46, 213, 115, 0.08);
}

.accent-btn {
  border-color: rgba(253, 121, 168, 0.3);
  background: rgba(253, 121, 168, 0.08);
}

.send-btn {
  border-color: rgba(0, 168, 255, 0.3);
  background: rgba(0, 168, 255, 0.08);
}

/* ══════════════════════════════════════════════════
   الفوتر
   ══════════════════════════════════════════════════ */

.app-footer {
  text-align: center;
  padding: var(--spacing-xl) 0 var(--spacing-md);
  position: relative;
  z-index: 1;
  animation: fadeSlideUp 0.6s ease-out 0.4s both;
}

.app-footer p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

.close-btn {
  padding: 12px var(--spacing-xl);
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-radius: var(--radius-lg);
  background: rgba(255, 71, 87, 0.08);
  color: #ff4757;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.close-btn:active {
  background: rgba(255, 71, 87, 0.2);
  transform: scale(0.95);
}

/* ══════════════════════════════════════════════════
   حركات الظهور
   ══════════════════════════════════════════════════ */

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

@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translateY(-15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeScaleIn {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ══════════════════════════════════════════════════
   تأثير النقر (Ripple)
   ══════════════════════════════════════════════════ */

.ripple {
  position: absolute;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0);
  animation: rippleEffect 0.6s ease-out;
  pointer-events: none;
}

@keyframes rippleEffect {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ══════════════════════════════════════════════════
   تنبيه النجاح
   ══════════════════════════════════════════════════ */

.toast {
  position: fixed;
  top: var(--spacing-md);
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: 12px var(--spacing-lg);
  background: rgba(46, 213, 115, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(46, 213, 115, 0.3);
  border-radius: var(--radius-lg);
  color: #2ed573;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 1000;
  transition: transform var(--transition-bounce);
  direction: rtl;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════════════════
   متجاوب
   ══════════════════════════════════════════════════ */

@media (max-width: 360px) {
  :root {
    --spacing-md: 14px;
    --spacing-lg: 20px;
  }
  
  .greeting {
    font-size: 1.5rem;
  }
  
  .avatar-container {
    width: 75px;
    height: 75px;
  }
  
  .avatar {
    width: 75px;
    height: 75px;
    font-size: 1.8rem;
  }
}

/* دعم الوضع الفاتح */
@media (prefers-color-scheme: light) {
  :root {
    --glass-bg: rgba(0, 0, 0, 0.03);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-shadow: rgba(0, 0, 0, 0.08);
  }
}

/* ══════════════════════════════════════════════════
   شريط التمرير المخصص
   ══════════════════════════════════════════════════ */

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}
