/*
 * platform-theme.css — بوابة الجود
 * نظام الهوية البصرية الذكية
 * المؤلف: منيرة المري — شهادة حق المؤلف 1614-2026
 */

/* ============================================
   1. CSS VARIABLES — الثيم الافتراضي
   ============================================ */
:root {
  /* الألوان الأساسية */
  --primary:       #d4a843;
  --primary-light: #e8c96a;
  --primary-dark:  #c9a84c;
  --secondary:     #7c3aed;
  --accent:        #f59e0b;

  /* الخلفيات */
  --bg-main:       #f8fafc;
  --bg-card:       #ffffff;
  --bg-sidebar:    #1e293b;
  --bg-header:     #1e293b;

  /* النصوص */
  --text-primary:   #1e293b;
  --text-secondary: #64748b;
  --text-on-dark:   #f1f5f9;
  --text-on-primary:#ffffff;

  /* الحالات */
  --success:  #10b981;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --info:     #3b82f6;

  /* الحدود والظلال */
  --border:        #e2e8f0;
  --border-radius: 12px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.15);

  /* الخطوط */
  --font-main:     'Tajawal', 'Segoe UI', sans-serif;
  --font-size-base: 15px;

  /* الحركة */
  --transition: 0.2s ease;

  /* الثيم النشط */
  --theme-name: 'default';
  --theme-banner-bg: transparent;
  --theme-banner-text: transparent;
  --theme-icon: '';
  --theme-overlay: none;
}

/* ============================================
   2. ثيم سماء العين (افتراضي)
   ============================================ */
[data-theme="sky"] {
  --primary:       #0ea5e9;
  --primary-dark:  #0284c7;
  --bg-main:       #f0f9ff;
  --bg-sidebar:    #0c4a6e;
  --bg-header:     #0c4a6e;
}

/* ============================================
   3. ثيم نخيل
   ============================================ */
[data-theme="palm"] {
  --primary:       #16a34a;
  --primary-dark:  #15803d;
  --bg-main:       #f0fdf4;
  --bg-sidebar:    #14532d;
  --bg-header:     #14532d;
}

/* ============================================
   4. ثيم فجر وردي
   ============================================ */
[data-theme="rose"] {
  --primary:       #e11d48;
  --primary-dark:  #be123c;
  --bg-main:       #fff1f2;
  --bg-sidebar:    #881337;
  --bg-header:     #881337;
}

/* ============================================
   5. ثيم ذهب الصحراء
   ============================================ */
[data-theme="gold"] {
  --primary:       #d97706;
  --primary-dark:  #b45309;
  --bg-main:       #fffbeb;
  --bg-sidebar:    #78350f;
  --bg-header:     #78350f;
}

/* ============================================
   6. ثيم ليلي
   ============================================ */
[data-theme="dark"] {
  --primary:       #818cf8;
  --primary-dark:  #6366f1;
  --bg-main:       #0f172a;
  --bg-card:       #1e293b;
  --bg-sidebar:    #020617;
  --bg-header:     #020617;
  --text-primary:  #e2e8f0;
  --text-secondary:#94a3b8;
  --border:        #334155;
}

/* ============================================
   7. ثيم كلاسيك
   ============================================ */
[data-theme="classic"] {
  --primary:       #d4a843;
  --primary-dark:  #c9a84c;
  --bg-main:       #f1f5f9;
  --bg-sidebar:    #1e293b;
  --bg-header:     #1e293b;
}

/* ============================================
   8. ثيم رمضاني 🌙 (أولوية قصوى — من المديرة فقط)
   ============================================ */
[data-theme="ramadan"] {
  --primary:       #7c3aed;
  --primary-dark:  #6d28d9;
  --accent:        #f59e0b;
  --bg-main:       #1a0a2e;
  --bg-card:       #2d1657;
  --bg-sidebar:    #0d0520;
  --bg-header:     #0d0520;
  --text-primary:  #f3e8ff;
  --text-secondary:#c4b5fd;
  --border:        #4c1d95;
  --theme-banner-bg: linear-gradient(135deg, #1a0a2e, #2d1657);
  --theme-banner-text: #f59e0b;
}

/* ============================================
   9. ثيم تعلم عن بُعد 🏠
   ============================================ */
[data-theme="remote"] {
  --primary:       #0369a1;
  --primary-dark:  #075985;
  --bg-main:       #e0f2fe;
  --bg-card:       #f0f9ff;
  --bg-sidebar:    #0c4a6e;
  --bg-header:     #0c4a6e;
  --theme-banner-bg: linear-gradient(135deg, #0369a1, #0ea5e9);
  --theme-banner-text: #ffffff;
}

/* ============================================
   10. ثيم طوارئ 🚨
   ============================================ */
[data-theme="emergency"] {
  --primary:       #dc2626;
  --primary-dark:  #b91c1c;
  --accent:        #f97316;
  --bg-main:       #fff7ed;
  --bg-card:       #ffedd5;
  --bg-sidebar:    #7c2d12;
  --bg-header:     #7c2d12;
  --border:        #fed7aa;
  --theme-banner-bg: linear-gradient(135deg, #dc2626, #f97316);
  --theme-banner-text: #ffffff;
}

/* ============================================
   11. ثيم صحي 💧
   ============================================ */
[data-theme="health"] {
  --primary:       #059669;
  --primary-dark:  #047857;
  --bg-main:       #ecfdf5;
  --bg-card:       #f0fdf4;
  --bg-sidebar:    #064e3b;
  --bg-header:     #064e3b;
  --theme-banner-bg: linear-gradient(135deg, #059669, #34d399);
  --theme-banner-text: #ffffff;
}

/* ============================================
   12. شريط الثيم العلوي (للثيمات الخاصة)
   ============================================ */
#theme-banner {
  display: none;
  width: 100%;
  padding: 8px 20px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font-main);
  background: var(--theme-banner-bg);
  color: var(--theme-banner-text);
  letter-spacing: 0.5px;
  animation: themeBannerPulse 3s ease-in-out infinite;
}
[data-theme="ramadan"] #theme-banner,
[data-theme="remote"] #theme-banner,
[data-theme="emergency"] #theme-banner,
[data-theme="health"] #theme-banner {
  display: block;
}

@keyframes themeBannerPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.85; }
}

/* ============================================
   13. منتقي الثيم الشخصي (الويدجت)
   ============================================ */
#theme-picker {
  position: fixed;
  bottom: 80px;
  left: 16px;
  z-index: 9000;
  direction: rtl;
}

#theme-picker-toggle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
#theme-picker-toggle:hover { transform: scale(1.1); }

#theme-picker-panel {
  display: none;
  position: absolute;
  bottom: 52px;
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
}
#theme-picker-panel.open { display: block; }

#theme-picker-panel h4 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-main);
  text-align: center;
}

.theme-swatch-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.theme-swatch:hover { transform: scale(1.1); }
.theme-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.theme-swatch span {
  position: absolute;
  bottom: 2px;
  font-size: 0.6rem;
  color: white;
  background: rgba(0,0,0,0.5);
  padding: 1px 4px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ============================================
   14. النوافذ المنبثقة للثيمات الخاصة
   ============================================ */
#theme-popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
#theme-popup-overlay.show { display: flex; }

#theme-popup-box {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  font-family: var(--font-main);
  position: relative;
  animation: popupIn 0.3s ease;
}
@keyframes popupIn {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

#theme-popup-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}
#theme-popup-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}
#theme-popup-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 20px;
}
#theme-popup-close {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px 28px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-main);
}

/* رمضان — تزيين خاص */
[data-theme="ramadan"] #theme-popup-box {
  background: linear-gradient(135deg, #2d1657, #1a0a2e);
  color: #f3e8ff;
  border: 1px solid #4c1d95;
}
[data-theme="ramadan"] #theme-popup-title { color: #f59e0b; }
[data-theme="ramadan"] #theme-popup-text  { color: #c4b5fd; }

/* ============================================
   15. أصحاب الهمم — شارة عالمية
   ============================================ */
.hmma-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-main);
  white-space: nowrap;
}

/* ============================================
   16. مؤشر الحالة (أون لاين / أوف لاين)
   ============================================ */
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 4px;
}
.status-dot.online  { background: #10b981; box-shadow: 0 0 0 2px #d1fae5; }
.status-dot.offline { background: #94a3b8; }
.status-dot.absent  { background: #ef4444; box-shadow: 0 0 0 2px #fee2e2; }

/* ============================================
   17. Animations عامة
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease forwards; }

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, #f1f5f9 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

/* ============================================
   18. Responsive
   ============================================ */
@media (max-width: 768px) {
  #theme-picker { bottom: 70px; left: 10px; }
  #theme-picker-panel { left: 0; min-width: 180px; }
}
