/* ============================================================================
   HIYRO MANGA — style.css
   التنسيق العام المشترك بين جميع صفحات المستخدم
   ============================================================================ */

:root {
  /* --- الألوان الأساسية --- */
  --bg-primary: #0F0A1E;
  --bg-secondary: #1A1230;
  --bg-elevated: #221A3D;
  --accent-primary: #9D4EDD;
  --accent-secondary: #E05CB8;
  --accent-gradient: linear-gradient(135deg, #9D4EDD 0%, #E05CB8 100%);
  --text-primary: #F0EBFA;
  --text-secondary: #A9A0C0;
  --text-muted: #6E6485;
  --success: #4ADE80;
  --danger: #F25C7E;
  --border-color: rgba(157, 78, 221, 0.18);

  /* --- الخطوط --- */
  --font-display: 'Baloo 2', 'Tajawal', sans-serif;
  --font-body: 'Tajawal', sans-serif;

  /* --- القياسات --- */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --header-height: 68px;
  --max-width: 1320px;

  /* --- ظلال --- */
  --shadow-glow: 0 8px 30px rgba(157, 78, 221, 0.25);
  --shadow-card: 0 4px 18px rgba(0, 0, 0, 0.35);
}

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

/* يضمن أن خاصية hidden تعمل دائما بشكل صحيح، حتى على عناصر تحمل كلاسات
   مثل .btn التي تعرّف display بنفسها (مما يتجاوز السلوك الافتراضي لـ[hidden]) */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  max-width: 100%;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  direction: rtl;
  overflow-x: hidden;
  max-width: 100%;
}

body.lang-en {
  direction: ltr;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(157, 78, 221, 0.18);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

/* تركيز واضح بالكيبورد لإمكانية الوصول */
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent-secondary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14.5px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 16px rgba(157, 78, 221, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(157, 78, 221, 0.45);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--accent-primary);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: rgba(157, 78, 221, 0.12);
}

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(157, 78, 221, 0.1);
}

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

/* ----------------------------------------------------------------------------
   HEADER المشترك
   ---------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(15, 10, 30, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
}

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.site-logo span.dot {
  color: var(--accent-secondary);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.site-nav a {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.15s ease, background 0.15s ease;
}

.site-nav a:hover, .site-nav a.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.site-search {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.site-search input {
  width: 100%;
  padding: 9px 16px 9px 38px;
  border-radius: 999px;
  background: var(--bg-elevated);
  font-size: 14px;
}

.site-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: var(--text-primary);
  background: rgba(157, 78, 221, 0.18);
}

.icon-btn .badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-primary);
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.avatar-banner-wrap {
  position: relative;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.avatar-banner-wrap img.avatar {
  width: 100%;
  height: 100%;
}

.avatar-banner-wrap img.banner-overlay {
  position: absolute;
  inset: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
  pointer-events: none;
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

/* ----------------------------------------------------------------------------
   FOOTER المشترك
   ---------------------------------------------------------------------------- */

.site-footer {
  margin-top: 60px;
  padding: 40px 0 26px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 28px;
}

.footer-col h4 {
  font-family: var(--font-display);
  font-size: 16px;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.footer-col p {
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 320px;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 14px;
  transition: color 0.15s ease;
}

.footer-links a:hover {
  color: var(--accent-secondary);
}

.footer-bottom {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
}

/* ----------------------------------------------------------------------------
   بانرات إعلانية ثابتة (أعلى/أسفل)
   ---------------------------------------------------------------------------- */

.site-ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  background: var(--bg-secondary);
  overflow: hidden;
}

.site-ad-slot:empty {
  display: none;
}

/* ----------------------------------------------------------------------------
   مكونات عامة قابلة لإعادة الاستخدام
   ---------------------------------------------------------------------------- */

.section {
  padding: 46px 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
}

.section-head a {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-secondary);
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, rgba(157,78,221,0.15) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-state {
  grid-column: 1 / -1;
  width: 100%;
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(92vw, 380px);
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 14px;
  box-shadow: var(--shadow-card);
  animation: toast-in 0.25s ease;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* بادج الباقات (يُستخدم في أكثر من صفحة) */
.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}

.plan-badge.free { background: rgba(169,160,192,0.15); color: var(--text-secondary); }
.plan-badge.regular { background: rgba(74,222,128,0.15); color: var(--success); }
.plan-badge.warrior { background: rgba(157,78,221,0.18); color: var(--accent-primary); }
.plan-badge.legend { background: var(--accent-gradient); color: #fff; }

/* ----------------------------------------------------------------------------
   استجابة الموبايل للهيدر/الفوتر
   ---------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 860px) {
  .site-nav, .site-search {
    display: none;
  }

  .menu-toggle {
    display: flex;
  }

  .site-header__inner {
    gap: 10px;
  }

  .header-actions {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 14px;
  }

  .site-logo {
    font-size: 18px;
  }

  .header-actions .btn {
    padding: 8px 12px;
    font-size: 12.5px;
    white-space: nowrap;
  }

  .header-actions .btn-outline {
    display: none; /* "تسجيل الدخول" يُخفى على الشاشات الضيقة جدا، متاح من القائمة المنبثقة */
  }
}

@media (max-width: 360px) {
  .header-actions .btn-primary {
    padding: 7px 10px;
    font-size: 11.5px;
  }
}

/* ----------------------------------------------------------------------------
   قائمة الموبايل المنبثقة (Drawer)
   ---------------------------------------------------------------------------- */

.mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
  visibility: hidden;
}

.mobile-drawer.open {
  visibility: visible;
}

.mobile-drawer__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mobile-drawer.open .mobile-drawer__overlay {
  opacity: 1;
}

.mobile-drawer__panel {
  position: absolute;
  top: 0;
  right: -100%;
  height: 100%;
  width: min(78vw, 320px);
  background: var(--bg-secondary);
  padding: 24px 20px;
  transition: right 0.3s ease;
  overflow-y: auto;
}

body.lang-en .mobile-drawer__panel {
  right: auto;
  left: -100%;
  transition: left 0.3s ease;
}

.mobile-drawer.open .mobile-drawer__panel {
  right: 0;
}

body.lang-en .mobile-drawer.open .mobile-drawer__panel {
  left: 0;
}

.mobile-drawer__panel a {
  display: block;
  padding: 13px 4px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.mobile-drawer__login-link {
  display: none;
  color: var(--accent-secondary) !important;
}

@media (max-width: 480px) {
  .mobile-drawer__login-link {
    display: block;
  }
}

/* ============================================================================
   مكونات مشتركة إضافية: فورمات، تابات، صفحات بسيطة (auth, profile, لوائح)
   ============================================================================ */

.page-shell {
  min-height: calc(100vh - var(--header-height) - 200px);
  padding: 42px 0 60px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 6px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 14.5px;
  margin-bottom: 28px;
}

/* --- بطاقة فورم (تسجيل دخول/تسجيل/تواصل) --- */

.auth-shell {
  min-height: calc(100vh - var(--header-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  position: relative;
  overflow: hidden;
}

.auth-shell::before {
  content: '';
  position: absolute;
  top: -180px;
  right: -120px;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(157,78,221,0.3) 0%, transparent 70%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  box-shadow: var(--shadow-card);
}

.auth-card__logo {
  display: block;
  text-align: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
}

.auth-card h1 {
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-card .auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13.5px;
  margin-bottom: 26px;
}

.form-field {
  margin-bottom: 16px;
}

.form-field label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.form-field input, .form-field textarea, .form-field select {
  width: 100%;
}

.form-field .field-error {
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 5px;
  display: none;
}

.form-field.has-error input {
  border-color: var(--danger);
}

.form-field.has-error .field-error {
  display: block;
}

.form-actions {
  margin-top: 22px;
}

.form-actions .btn {
  width: 100%;
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--accent-secondary);
  font-weight: 700;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 12.5px;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* --- تابات (تُستخدم في profile.html، notifications.html...) --- */

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  flex-shrink: 0;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tabs button.active {
  color: var(--text-primary);
  border-color: var(--accent-secondary);
}

.tabs button .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--bg-elevated);
  font-size: 11px;
}

/* --- بطاقة عامة (تُستخدم في عدة صفحات: إشعار، طلب، عنصر لائحة) --- */

.list-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid transparent;
  margin-bottom: 10px;
  transition: border-color 0.15s ease;
}

.list-card:hover {
  border-color: var(--border-color);
}

.list-card.unread {
  border-color: var(--accent-primary);
  background: rgba(157,78,221,0.06);
}

.list-card__icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent-secondary);
}

.list-card__icon img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.list-card__body {
  flex: 1;
  min-width: 0;
}

.list-card__title {
  font-size: 14.5px;
  font-weight: 700;
  margin-bottom: 3px;
}

.list-card__desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.list-card__time {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.list-card__action {
  flex-shrink: 0;
}

/* --- زر إجراء دائري صغير (مفضلة، حذف، إلخ) --- */

.icon-action {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-action:hover {
  background: rgba(242, 92, 126, 0.15);
  color: var(--danger);
}

.icon-action.active {
  color: var(--danger);
}

/* --- شبكة المفضلة/السجل (أعمدة متجاوبة بشكل عام) --- */

.simple-works-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

@media (max-width: 1100px) {
  .simple-works-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 640px) {
  .simple-works-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
}
@media (max-width: 420px) {
  .simple-works-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- حالة فاضية مع زر دعوة لإجراء --- */

.empty-state .btn {
  margin-top: 16px;
}

/* --- مؤشر تحميل دائري بسيط (Spinner) --- */

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-secondary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 30px auto;
}

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

@media (max-width: 480px) {
  .auth-card {
    padding: 28px 20px;
  }

  .page-title {
    font-size: 22px;
  }
}

/* ============================================================================
   محتوى قانوني (سياسة الخصوصية، شروط الاستخدام، إخلاء المسؤولية)
   ============================================================================ */

.legal-content section {
  margin-bottom: 26px;
}

.legal-content h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.legal-content p {
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.9;
}
