/* ============================================================
   css/vote.css  —  صفحة التصويت العامة (نسخة محسّنة)
   ============================================================ */

/* ── متغيرات خاصة بالتصويت ─────────────────────────────── */
:root {
  --vote-primary: var(--primary-color, #a855ff);
  --vote-primary-glow: rgba(var(--primary-rgb), 0.25);
  --vote-gold: #f59e0b;
  --vote-gold-glow: rgba(245, 158, 11, 0.2);
  --vote-green: #4ade80;
  --vote-red: #f87171;
  --vote-surface: rgba(255, 255, 255, 0.04);
  --vote-surface-hover: rgba(var(--primary-rgb), 0.1);
  --vote-border: rgba(255, 255, 255, 0.08);
  --vote-border-hover: rgba(var(--primary-rgb), 0.4);
  --vote-text: #fff;
  --vote-muted: rgba(255, 255, 255, 0.45);
  --vote-radius-card: 24px;
  --vote-radius-btn: 14px;
  --vote-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  /* حجم صورة خيار التصويت (متوسط ومتجاوب) */
  --vote-option-avatar-size: clamp(76px, 52%, 96px);
}

/* ── الصفحة الكاملة ────────────────────────────────────── */
.vote-page {
  min-height: 100vh;
  padding-top: 20px; /* تم تقليلها لأن الـ body لديه padding-top بالفعل */
}

/* ── الغلاف الرئيسي ────────────────────────────────────── */
/* تم توحيد هيدر الصفحة عبر includes/page_header.php */

/* ── حاوية المحتوى ─────────────────────────────────────── */
.vote-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* ── زر العودة ─────────────────────────────────────────── */
.vote-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--vote-surface);
  border: 1px solid var(--vote-border);
  border-radius: var(--vote-radius-btn);
  color: var(--vote-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: var(--vote-transition);
  margin-bottom: 28px;
}

.vote-back-btn:hover {
  background: var(--vote-surface-hover);
  border-color: var(--vote-border-hover);
  color: var(--vote-text);
  transform: translateX(4px);
}

/* ── كارت التصويت ────────────────────────────────────── */
.vote-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--vote-border);
  border-radius: var(--vote-radius-card);
  padding: 36px;
  margin-bottom: 20px;
  animation: fadeUp 0.4s ease both;
  transition: var(--vote-transition);
  position: relative;
  overflow: hidden;
}

.vote-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(var(--primary-rgb), 0.5),
    transparent);
}

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

.vote-card--list {
  cursor: pointer;
}

.vote-card--list:hover {
  background: rgba(var(--primary-rgb), 0.05);
  border-color: rgba(168, 85, 255, 0.25);
  border-color: rgba(168, 85, 255, 0.25);
}

.vote-card--list:hover .vote-card__title {
  color: var(--vote-primary);
}

.vote-card--detail {
  animation: scaleIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ── محتويات الكارت ───────────────────────────────────── */
.vote-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

/* ── حالة التصويت ─────────────────────────────────────── */
.vote-card__live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--vote-green);
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.2);
  padding: 5px 14px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.live-dot {
  width: 7px; height: 7px;
  background: var(--vote-green);
  border-radius: 50%;
  animation: livePulse 1.6s ease infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  50%       { opacity: 0.6; transform: scale(0.85); }
  70%       { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
}

.vote-card__ended {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--vote-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 5px 14px;
  border-radius: 999px;
}

/* عداد الوقت */
.vote-card__timer {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--vote-muted);
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.15);
  padding: 5px 14px;
  border-radius: 999px;
}

.timer-val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--vote-gold);
  font-size: 0.88rem;
}

/* ── عنوان ووصف الكارت ─────────────────────────────────── */
.vote-card__title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--vote-text);
  margin: 0 0 8px;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.vote-card__desc {
  font-size: 0.9rem;
  color: var(--vote-muted);
  margin: 0 0 24px;
  line-height: 1.7;
}

/* تلميح النقر في قائمة الاستطلاعات */
.vote-card__action-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--vote-primary);
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0.7;
  transition: var(--vote-transition);
}

.vote-card--list:hover .vote-card__action-hint {
  opacity: 1;
  gap: 12px;
}

/* ── تحميل الخيارات ────────────────────────────────────── */
.vote-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  gap: 12px;
  color: var(--vote-muted);
  font-size: 0.9rem;
}

.vote-loading__spinner {
  width: 32px; height: 32px;
  border: 2.5px solid rgba(168, 85, 255, 0.15);
  border-top-color: #a855ff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── شبكة الخيارات ─────────────────────────────────────── */
.vote-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 16px;
  margin-top: 28px;
  width: 100%;
  align-items: stretch;
}

/* ── زر الخيار ─────────────────────────────────────────── */
.vote-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 11px;
  aspect-ratio: 1 / 1;
  background: var(--vote-surface);
  border: 1px solid var(--vote-border);
  border-radius: 20px;
  padding: 16px 12px;
  cursor: pointer;
  transition: var(--vote-transition);
  color: var(--vote-text);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
}

.vote-option::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 120%, var(--vote-primary-glow), transparent 65%);
  opacity: 0;
  transition: opacity 0.3s;
}

.vote-option:hover:not(:disabled) {
  border-color: var(--vote-border-hover);
  background: var(--vote-surface-hover);
  transform: translateY(-4px) scale(1.02);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(168, 85, 255, 0.2) inset;
}

.vote-option:hover::after { opacity: 1; }

.vote-option:active:not(:disabled) {
  transform: scale(0.97);
}

.vote-option:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.vote-option.loading {
  border-color: rgba(168, 85, 255, 0.5);
  animation: optPulse 0.9s ease infinite;
}

@keyframes optPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* صورة الخيار */
.vote-option__avatar {
  width: var(--vote-option-avatar-size);
  height: var(--vote-option-avatar-size);
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  transition: transform 0.3s;
  border: 2px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.vote-option:hover .vote-option__avatar {
  transform: scale(1.07);
  border-color: rgba(168, 85, 255, 0.4);
}

.vote-option__avatar--placeholder {
  width: var(--vote-option-avatar-size);
  height: var(--vote-option-avatar-size);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.6rem;
  background: linear-gradient(135deg, rgba(168, 85, 255, 0.4), rgba(124, 58, 237, 0.6));
  color: #fff;
  flex-shrink: 0;
  border: 2px solid rgba(168, 85, 255, 0.2);
}

.vote-option__label {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  position: relative;
  z-index: 1;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.vote-option:focus-visible {
  outline: 2px solid rgba(var(--primary-rgb), 0.7);
  outline-offset: 3px;
}

/* ── عرض النتائج ───────────────────────────────────────── */
.vote-options--results {
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
}

.vote-result-square {
  display: flex;
  flex-direction: column;
  gap: 0;
  animation: fadeUp 0.4s ease both;
}

.vote-option-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--vote-surface);
  border: 1px solid var(--vote-border);
  border-radius: 20px 20px 0 0;
  padding: 16px 12px;
  position: relative;
  text-align: center;
  transition: var(--vote-transition);
}

/* قسم المعلومات تحت المربع */
.vote-result-info-below {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--vote-border);
  border-top: none;
  border-radius: 0 0 16px 16px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* الفائز */
.vote-result-square.winner .vote-option-box {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.3);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.1);
}

.vote-result-square.winner .vote-result-info-below {
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.05);
}

.vote-result-square.winner .vote-option__label {
  color: #fcd34d;
}

/* تاج الفائز */
.winner-crown {
  position: absolute;
  top: -14px;
  right: 50%;
  transform: translateX(50%);
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 8px rgba(245, 158, 11, 0.6));
  animation: crownFloat 2.5s ease-in-out infinite;
}

@keyframes crownFloat {
  0%, 100% { transform: translateX(50%) translateY(0); }
  50%       { transform: translateX(50%) translateY(-5px); }
}

/* شريط التقدم */
.vote-bar-mini-wrap {
  background: rgba(0, 0, 0, 0.3);
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
}

.vote-bar-mini {
  height: 100%;
  background: linear-gradient(90deg, #a855ff, #c084fc);
  border-radius: 999px;
  transition: width 0.9s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 4px;
}

.vote-result-square.winner .vote-bar-mini {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

/* أرقام النتيجة */
.vote-result-nums-below {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pct-val {
  font-size: 0.82rem;
  font-weight: 800;
  color: #c084fc;
}

.vote-result-square.winner .pct-val { color: #fbbf24; }

.votes-val {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--vote-muted);
}

/* ── تذييل الكارت ──────────────────────────────────────── */
.vote-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--vote-border);
}

.vote-total {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #c084fc;
  background: rgba(168, 85, 255, 0.1);
  border: 1px solid rgba(168, 85, 255, 0.2);
  padding: 6px 16px;
  border-radius: 10px;
}

.vote-guests-note {
  font-size: 0.82rem;
  color: var(--vote-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── قسم النتائج السابقة ───────────────────────────────── */
.vote-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--vote-muted);
  margin: 48px 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.vote-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--vote-border);
}

.vote-ended-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vote-ended-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--vote-surface);
  border: 1px solid var(--vote-border);
  border-radius: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: var(--vote-transition);
}

.vote-ended-card:hover {
  border-color: rgba(168, 85, 255, 0.3);
  background: var(--vote-surface-hover);
  transform: translateX(-4px);
}

.vote-ended-card__icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.vote-ended-card__title {
  flex: 1;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--vote-text);
}

.vote-ended-card__count {
  font-size: 0.78rem;
  color: var(--vote-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 10px;
  border-radius: 999px;
}

.vote-ended-card__arrow {
  color: var(--vote-muted);
  font-size: 0.9rem;
  transition: var(--vote-transition);
}

.vote-ended-card:hover .vote-ended-card__arrow {
  color: #a855ff;
  transform: translateX(-3px);
}

/* ── الحالة الفارغة ────────────────────────────────────── */
.vote-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--vote-muted);
}

.vote-empty__icon {
  font-size: 4.5rem;
  margin-bottom: 20px;
  display: block;
  filter: drop-shadow(0 0 20px rgba(168, 85, 255, 0.3));
}

.vote-empty h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--vote-text);
  margin-bottom: 10px;
}

.vote-empty p {
  font-size: 0.95rem;
}

.vote-err {
  color: var(--vote-red);
  font-size: 0.88rem;
  text-align: center;
  padding: 20px 0;
}

/* ── Modal النتائج المنتهية ─────────────────────────────── */
.va-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.va-modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.va-modal {
  background: #1a1025;
  border: 1px solid rgba(168, 85, 255, 0.25);
  border-radius: 24px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.25s;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.va-modal-overlay.active .va-modal {
  transform: scale(1);
}

.va-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 0;
  margin-bottom: 20px;
}

.va-modal__header h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--vote-text);
  margin: 0;
}

.va-modal__close {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--vote-border);
  background: var(--vote-surface);
  color: var(--vote-muted);
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--vote-transition);
}

.va-modal__close:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--vote-red);
}

.va-modal__body {
  padding: 0 28px 28px;
}

.va-loader {
  text-align: center;
  color: var(--vote-muted);
  padding: 40px;
  font-size: 0.9rem;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 600px) {
  .vote-card { padding: 24px 18px; }
  .vote-options { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .vote-card__header { flex-direction: column; align-items: flex-start; }
  .vote-card__title { font-size: 1.2rem; }
  .va-modal__body { padding: 0 18px 20px; }
  .va-modal__header { padding: 20px 18px 0; }
  :root { --vote-option-avatar-size: clamp(72px, 56%, 92px); }
}

@media (max-width: 380px) {
  .vote-options { grid-template-columns: repeat(2, 1fr); }
}
