:root {
  /* الألوان الرئيسية */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary: #64748b; /* تم تعديله ليكون مناسباً للأزرار الثانوية */
  
  /* الخلفيات */
  --bg-body: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --bg-card: rgba(255, 255, 255, 0.95);
  
  /* ألوان المودال (الجديدة) */
  --modal-bg: #ffffff;
  --modal-header-bg: #f8fafc;
  --modal-border: #e2e8f0;
  --input-bg: #ffffff;
  --input-border: #e2e8f0;
  
  /* النصوص */
  --text-main: #1e293b;
  --text-muted: #64748b;
  
  /* تأثيرات */
  --border: #e5e7eb;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.2);
  --transition: all 0.3s ease;
}

* { 
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  margin: 0;
  font-family: 'Cairo', system-ui, sans-serif;
  background: var(--bg-body);
  background-attachment: fixed;
  color: var(--text-main);
  direction: rtl;
  line-height: 1.6;
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: 30px auto;
  padding: 0 20px;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 40px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.2);
}



/* تم إضافة هذا الجزء لإصلاح مشكلة التمرير */
.chat-box {
  flex: 1;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
  padding: 25px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 300px; /* إضافة حد أدنى للارتفاع */
}

/* إصلاح خاصية animation لـ fadeOut */
@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}



.logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  color: white;
  margin-bottom: 10px;
}

.logo-area i {
  font-size: 40px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

h1 {
  margin: 0;
  font-weight: 900;
  font-size: 32px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
  color: rgba(255, 255, 255, 0.9);
  margin: 5px 0 0;
  font-size: 16px;
}

/* Cards Common Style */
section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 25px;
  margin-bottom: 30px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  transition: var(--transition);
}

section:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Controls */
.controls-card {
  display: flex;
  flex-wrap: wrap;
  gap: 25px;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 25px;
}

.controls-card .input-wrapper {
  display: flex;
  align-items: center;
  gap: 15px;
  font-weight: 700;
  font-size: 18px;
}

.controls-card input {
  width: 100px;
  padding: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
}

.action-buttons {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

/* Buttons */
button {
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  background: white;
  border: 2px solid var(--border);
  color: var(--text-main);
  position: relative;
  overflow: hidden;
}

button::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.3s;
}

button:hover::after {
  opacity: 1;
}

button:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

button:active {
  transform: translateY(-1px);
}

button.primary {
  background: var(--primary);
  color: white;
  border-color: transparent;
}

button.primary:hover {
  background: var(--primary-hover);
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
}

button.danger {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

button.danger:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

button.ai-btn {
  background: linear-gradient(135deg, var(--ai-color), #ec4899);
  color: white;
  width: 100%;
  justify-content: center;
  font-size: 18px;
  padding: 16px;
  margin-top: 20px;
  border: none;
}

button.ai-btn:hover {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(139, 92, 246, 0.4);
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: white;
}

th {
  text-align: right;
  padding: 16px;
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 14px;
  border-bottom: 2px solid var(--border);
  font-weight: 700;
}

td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

tr:hover td {
  background: #f9fafb;
}

tr:last-child td {
  border-bottom: none;
}

input.party-name, input.party-votes {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  transition: var(--transition);
}

input.party-name:focus, input.party-votes:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  outline: none;
}

.removeBtn {
  padding: 8px;
  color: var(--danger);
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  border-radius: 8px;
  transition: var(--transition);
}

.removeBtn:hover {
  background: rgba(239, 68, 68, 0.1);
  transform: scale(1.1);
}

/* Results */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-top: 20px;
}

@media (max-width: 768px) {
  .results-grid {
    grid-template-columns: 1fr;
  }

   .chat-box {
    height: auto !important; /* إزالة الارتفاع الثابت */
    max-height: 400px;
    padding: 15px;
  }
  /* 3. منطقة الإدخال: تظهر فوق لوحة المفاتيح وشريط التصفح */
  .chat-input {
    width: 100%;
    background: var(--bg-card); /* لون خلفية صلب لمنع التداخل */
    position: relative;
    z-index: 100;
    
    /* رفع الصندوق للأعلى قليلاً */
    /* env(safe-area-inset-bottom) مخصص للآيفون لرفع الصندوق فوق الخط السفلي للشاشة */
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    
    /* ظل خفيف لفصله عن الرسائل */
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  }
   .container {
    padding: 0 15px;
    margin: 15px auto;
  }
  
  .discussion-forum {
    height: 600px;
  }
  
  /* 1. الحاوية الرئيسية: تأخذ ارتفاع الشاشة الفعلي (تستثني شريط المتصفح) */
  .chat-container {
    height: 100vh; /* للمتصفحات القديمة */
    height: 100dvh; /* Dynamic Height: الحل السحري للموبايل */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* يمنع تمرير الصفحة بأكملها */
  }
  .forum-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }
  
  .header-actions {
    width: 100%;
    justify-content: center;
  }
  
  .results-grid {
    grid-template-columns: 1fr;
  }
  
  .controls-card {
    flex-direction: column;
    align-items: stretch;
  }
  
  .action-buttons {
    justify-content: center;
  }
  
  .action-buttons button {
    flex: 1;
    min-width: 150px;
    justify-content: center;
  }
  
  /* 2. صندوق الرسائل: يتمدد ليملأ الفراغ ويقبل التمرير داخله */
  .chat-box {
    flex: 1; /* يأخذ المساحة المتبقية */
    height: auto !important;
    max-height: none; /* إلغاء الحد الأقصى للسماح بالتمدد */
    overflow-y: auto; /* التمرير هنا فقط */
    padding: 15px;
    padding-bottom: 20px;
  }
  
  .comment {
    max-width: 95%;
  }
  
  .notification {
    min-width: 250px;
    right: 15px;
    left: 15px;
  }
}

.result-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.result-card h3 {
  margin-top: 0;
  font-size: 18px;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 12px;
  margin-bottom: 20px;
  color: var(--primary);
}

.download-btn {
  width: 100%;
  justify-content: center;
  margin-top: 20px;
  background: var(--text-main);
  color: white;
  padding: 14px;
  font-size: 16px;
}

.download-btn:hover {
  background: #374151;
  transform: translateY(-2px);
}

/* ========== قسم المحادثة المطور ========== */
.discussion-forum {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 700px;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow-lg);
}

.forum-header {
  padding: 20px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.forum-header h2 {
  margin: 0;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-status {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 25px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  color: white;
  border: 2px solid white;
}

#logoutBtn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 16px;
  font-size: 14px;
}

#logoutBtn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* المستخدمين النشطين */
.online-users {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.1), rgba(14, 165, 233, 0.1));
  border-radius: 0 0 15px 15px;
  margin: 0 20px;
}

.online-dot {
  width: 10px;
  height: 10px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
}

/* صندوق المحادثة */
.chat-box {
  flex: 1;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
  padding: 25px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* التعليقات */
.comment {
  max-width: 85%;
  padding: 16px 20px;
  border-radius: 20px;
  position: relative;
  font-size: 15px;
  line-height: 1.6;
  animation: fadeIn 0.3s ease;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.comment:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.comment.me {
  align-self: flex-end;
  color: white;
  border-bottom-left-radius: 5px;
}

.comment.other {
  align-self: flex-start;
  background: white;
  border: 1px solid var(--border);
  border-bottom-right-radius: 5px;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}

.comment-time {
  font-size: 11px;
  opacity: 0.8;
  font-weight: normal;
}

.actions {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  justify-content: flex-start;
}

.action-btn {
  background: none;
  border: none;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  border-radius: 15px;
  transition: var(--transition);
  cursor: pointer;
}

.action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

.action-btn.liked {
  color: var(--primary);
  background: rgba(79, 70, 229, 0.1);
}

.action-btn.disliked {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* منطقة الإدخال */
.chat-input-area {
  padding: 20px;
  background: white;
  border-top: 2px solid var(--border);
  display: flex;
  gap: 15px;
  align-items: flex-end;
  position: relative;
}

.chat-input-area textarea {
  flex: 1;
  padding: 16px 20px;
  border: 2px solid var(--border);
  border-radius: 25px;
  resize: none;
  outline: none;
  min-height: 56px;
  max-height: 150px;
  font-family: inherit;
  font-size: 15px;
  transition: var(--transition);
  background: #f9fafb;
}

.chat-input-area textarea:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.input-tools {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.tool-btn {
  background: #f3f4f6;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  cursor: pointer;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.tool-btn:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.1);
}

.send-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.send-btn:hover {
  transform: scale(1.05) rotate(5deg);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Login Overlay */
.login-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  z-index: 10;
  font-weight: bold;
  font-size: 18px;
  border-radius: var(--radius);
}

.login-overlay button {
  padding: 15px 30px;
  font-size: 16px;
}

/* مؤشر الكتابة */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: white;
  border-radius: 25px;
  border: 1px solid var(--border);
  align-self: flex-start;
  margin: 5px 20px;
  box-shadow: var(--shadow-sm);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.typing-dots {
  display: flex;
  gap: 5px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* إشعارات */
.notification {
  position: fixed;
  top: 30px;
  right: 30px;
  background: white;
  border-radius: var(--radius);
  padding: 16px 24px;
  box-shadow: var(--shadow-lg);
  border-left: 5px solid var(--success);
  z-index: 1000;
  animation: slideInRight 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
}

.notification.error {
  border-left-color: var(--danger);
}

.notification.warning {
  border-left-color: var(--warning);
}

.notification.info {
  border-left-color: var(--primary);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Modal */
/* =========================================
   تنسيق النوافذ المنبثقة (عام للدخول والإعدادات)
   ========================================= */

.modal {
    display: none; /* مخفي افتراضياً */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    overflow: auto;
    align-items: center; /* للتوسيط */
    justify-content: center; /* للتوسيط */
}

/* لجعل المودال يظهر بمنتصف الشاشة عند تفعيله بـ flex */
.modal.active {
    display: flex; 
}

.modal-content {
    background: var(--modal-bg);
    width: 90%;
    max-width: 450px;
    margin: auto;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.5);
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* الرأس */
.modal-header {
    background: var(--modal-header-bg);
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--modal-border);
}

.modal-header h3, .modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* زر الإغلاق */
.close-modal {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-modal:hover {
    background-color: #fee2e2;
    color: #ef4444;
}

/* جسم النافذة */
.modal-body {
    padding: 25px;
}

/* التذييل (الأزرار) */
.modal-footer {
    padding: 15px 25px 25px 25px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* عناصر النماذج داخل المودال */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input, 
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--modal-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background-color: var(--input-bg);
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* الأزرار داخل المودال */
.modal-btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.modal-btn.primary {
    background: var(--primary);
    color: white;
}

.modal-btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.modal-btn.secondary {
    background: #f1f5f9;
    color: var(--text-muted);
}

.modal-btn.secondary:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

/* أنيميشن */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.close-modal {
  position: absolute;
  left: 25px;
  top: 25px;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.close-modal:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.input-group {
  position: relative;
  margin-bottom: 20px;
}

.input-group i {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 20px;
}

.input-group input {
  width: 100%;
  padding: 15px 50px 15px 15px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 16px;
  transition: var(--transition);
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  outline: none;
}

.input-group input[type="color"] {
  padding: 5px;
  height: 50px;
  cursor: pointer;
}

.full-width {
  width: 100%;
  justify-content: center;
  margin-top: 20px;
  padding: 16px;
}

/* إعدادات المحادثة */
.settings-group {
  margin-bottom: 25px;
  padding: 20px;
  background: #f9fafb;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.settings-group label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
  cursor: pointer;
  font-weight: 600;
}

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.color-picker {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.color-option {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}

.color-option:hover {
  transform: scale(1.1);
  border-color: var(--border);
}

.color-option.selected {
  border-color: var(--primary);
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* AI Analysis */
#analysisOutput {
  background: #1a1a1a;
  color: #e0e0e0;
  padding: 25px;
  border-radius: 12px;
  margin-top: 20px;
  font-size: 15px;
  border-right: 5px solid var(--ai-color);
  line-height: 1.8;
  font-family: 'Cairo', system-ui;
}

#analysisOutput h3 {
  color: var(--ai-color);
  margin-top: 20px;
  margin-bottom: 10px;
}

#analysisOutput ul, #analysisOutput ol {
  padding-right: 20px;
  margin: 10px 0;
}

#analysisOutput li {
  margin-bottom: 8px;
}

#analysisOutput strong {
  color: #fff;
}

#analysisLoading {
  text-align: center;
  padding: 30px;
  font-size: 18px;
  color: var(--primary);
  animation: pulse 1.5s infinite;
}


/* =========================================
   تنسيق الشاشات الصغيرة جداً (وضع ملء الشاشة)
   ========================================= */
@media (max-width: 480px) {

  /* 1. إزالة الهوامش من الجسم الرئيسي لضمان التلاصق بالحواف */
  body {
    padding: 0 !important;
    margin: 0 !important;
  /*  overflow: hidden;*/   /* لمنع ظهور شريط تمرير للصفحة نفسها */
  }

  /* 2. جعل الحاويات الرئيسية تملأ الشاشة تماماً */
  .container, 
  .chat-container {
    width: 100% !important;
   /* height: 100dvh !important;*/ /* الارتفاع الديناميكي الكامل */
    max-width: none !important;
    margin: 0 !important;
    border-radius: 0 !important; /* إلغاء الزوايا الدائرية */
    border: none !important;     /* إزالة الحدود */
    box-shadow: none !important; /* إزالة الظلال لأنها لم تعد ضرورية */
    
    /* لضمان ترتيب العناصر داخلياً */
    display: flex;
    flex-direction: column;
  }

  /* 3. التأكد من أن صندوق الرسائل يتمدد ويقبل التمرير */
  .chat-box {
    flex: 1; /* يأخذ كل المساحة المتاحة */
    height: auto !important;
    overflow-y: auto;
    padding: 15px;
    padding-bottom: 80px; /* مساحة إضافية كي لا تختفي آخر رسالة */
  }

  /* 4. تثبيت منطقة الكتابة في الأسفل تماماً */
  .chat-input {
    width: 100%;
    position: relative; /* أو fixed إذا واجهت مشاكل */
    bottom: 0;
    left: 0;
    border-radius: 0 !important;
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* تحسينات للواجهة */
.date-separator {
  text-align: center;
  margin: 20px 0;
  position: relative;
}

.date-separator span {
  background: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.hashtag {
  color: var(--primary);
  font-weight: bold;
  cursor: pointer;
}

.hashtag:hover {
  text-decoration: underline;
}

/* Scrollbar Personalization */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
}

/* Footer */
footer {
  text-align: center;
  padding: 25px;
  margin-top: 40px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
}

.footer-content p {
  margin-bottom: 15px;
  font-size: 14px;
  opacity: 0.9;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.social-links a {
  color: white;
  font-size: 24px;
  transition: var(--transition);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
}

.social-links a:hover {
  background: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}