/* =====================================================================
   core.css — الأنماط المشتركة بين كل شاشات النظام
   - لوحات الألوان (Palettes) عبر data-palette
   - التهيئة العامة والخلفيات
   - الشريط العلوي + محدّد الثيم + نافذة دليل الشاشة
   مستخرج من التصاميم الأصلية للحفاظ على نفس المظهر بدقة.
   ===================================================================== */

/* ========================================================
   1) لوحات الألوان - يتم تبديلها عبر data-palette
   ======================================================== */
[data-palette="sky"] {
  --bg: #eef5fa; --bg-2: #e0eef7; --bg-3: #cee3f0;
  --ink: #0c2340; --ink-soft: #2f4a6a; --muted: #6b8199;
  --primary: #0369a1; --primary-hover: #025282; --primary-soft: #d3e7f2;
  --accent: #f59e0b; --accent-soft: #fdecc8;
  --line: #b8cfe0; --line-soft: #d3e0ea; --card: #ffffff;
}
[data-palette="navy"] {
  --bg: #eef2f7; --bg-2: #dde5ef; --bg-3: #c5d2e3;
  --ink: #0f1e3a; --ink-soft: #2a3b5e; --muted: #657389;
  --primary: #1e3a8a; --primary-hover: #152a6b; --primary-soft: #d5ddee;
  --accent: #c2410c; --accent-soft: #f0d1c3;
  --line: #b9c4d6; --line-soft: #d0d8e3; --card: #ffffff;
}
[data-palette="forest"] {
  --bg: #f0f9f4; --bg-2: #dcefe3; --bg-3: #bfdcc9;
  --ink: #0c2e1b; --ink-soft: #2b5236; --muted: #6b7d73;
  --primary: #14532d; --primary-hover: #0d3f20; --primary-soft: #c8ded1;
  --accent: #b45309; --accent-soft: #f0dcc0;
  --line: #b9d1bf; --line-soft: #cfdfd1; --card: #ffffff;
}
[data-palette="plum"] {
  --bg: #faf3fa; --bg-2: #f0e1f0; --bg-3: #e2c8e4;
  --ink: #3a0f3e; --ink-soft: #5c2b63; --muted: #8d6d91;
  --primary: #86198f; --primary-hover: #6b1471; --primary-soft: #efd6f0;
  --accent: #ca8a04; --accent-soft: #f3e3b8;
  --line: #d5bcd8; --line-soft: #e3cee5; --card: #ffffff;
}
[data-palette="slate"] {
  --bg: #f4f5f7; --bg-2: #e6e8ed; --bg-3: #d4d7e0;
  --ink: #0f172a; --ink-soft: #334155; --muted: #64748b;
  --primary: #334155; --primary-hover: #1f2937; --primary-soft: #dde1e8;
  --accent: #0d9488; --accent-soft: #c8e6e2;
  --line: #cdd2dc; --line-soft: #dde1e8; --card: #ffffff;
}
[data-palette="amber"] {
  --bg: #fefce8; --bg-2: #faf5cc; --bg-3: #efe3a6;
  --ink: #3d2e0a; --ink-soft: #63481c; --muted: #8b7742;
  --primary: #a16207; --primary-hover: #7d4b05; --primary-soft: #f3e3b8;
  --accent: #9a3412; --accent-soft: #f0cec3;
  --line: #d9cc9a; --line-soft: #e5dcb4; --card: #ffffff;
}
[data-palette="mint"] {
  --bg: #edfdf4; --bg-2: #d8f3e4; --bg-3: #bbe3ce;
  --ink: #0c3a2e; --ink-soft: #2b5a4c; --muted: #6a8478;
  --primary: #047857; --primary-hover: #035e45; --primary-soft: #c5e5d7;
  --accent: #7c3aed; --accent-soft: #e0d2fa;
  --line: #b8d4c6; --line-soft: #cce0d5; --card: #ffffff;
}
[data-palette="coral"] {
  --bg: #fdf2f1; --bg-2: #f7e2df; --bg-3: #efccc6;
  --ink: #3f1918; --ink-soft: #6b2e2b; --muted: #8b6763;
  --primary: #c44536; --primary-hover: #9d3528; --primary-soft: #f0d1cc;
  --accent: #1e3a5f; --accent-soft: #ccd6e3;
  --line: #d9bfbb; --line-soft: #e5d1cd; --card: #ffffff;
}

/* ========================================================
   2) التهيئة العامة والخلفيات
   ======================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'IBM Plex Sans Arabic', 'Readex Pro', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.35s ease;
}
body::before {
  content: ''; position: fixed; inset: 0;
  background-image:
    radial-gradient(circle at 20% 10%, var(--accent-soft) 0%, transparent 35%),
    radial-gradient(circle at 85% 90%, var(--primary-soft) 0%, transparent 40%);
  opacity: 0.45; pointer-events: none; z-index: 0;
  transition: all 0.35s ease;
}
body::after {
  content: ''; position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.1  0 0 0 0 0.1  0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.35; pointer-events: none; z-index: 0; mix-blend-mode: multiply;
}
.app { position: relative; z-index: 1; }

a { color: inherit; }

/* ========================================================
   3) الشريط العلوي
   ======================================================== */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 48px; border-bottom: 1px solid var(--line-soft);
}
.brand-mini {
  display: flex; align-items: center; gap: 10px;
  font-weight: 500; color: var(--ink-soft); font-size: 13px;
}
.brand-mini .dot {
  width: 7px; height: 7px; background: var(--primary); border-radius: 50%;
  box-shadow: 0 0 0 3px var(--primary-soft); animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--primary-soft); }
  50% { box-shadow: 0 0 0 6px var(--primary-soft); }
}
.top-actions { display: flex; align-items: center; gap: 20px; }
.lang-toggle {
  display: flex; background: var(--bg-2);
  border: 1px solid var(--line-soft); border-radius: 999px; padding: 3px;
}
.lang-toggle button {
  background: transparent; border: none; color: var(--muted);
  padding: 5px 14px; border-radius: 999px; font-family: inherit;
  font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.lang-toggle button.active { background: var(--ink); color: var(--bg); }
.support-link {
  display: flex; align-items: center; gap: 6px; color: var(--ink-soft);
  text-decoration: none; font-size: 13px; font-weight: 500; transition: color 0.2s;
}
.support-link:hover { color: var(--accent); }

/* ========================================================
   4) زر دليل الشاشة + النافذة المنبثقة
   ======================================================== */
.guide-trigger {
  display: flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--line-soft); color: var(--ink-soft);
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500;
  transition: all 0.2s; position: relative;
}
.guide-trigger svg { width: 16px; height: 16px; color: var(--primary); }
.guide-trigger:hover { border-color: var(--primary); color: var(--ink); background: var(--primary-soft); }
.guide-trigger::after {
  content: ''; position: absolute; top: 6px; left: 6px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 2px var(--card); animation: pulse 2.4s ease-in-out infinite;
}
.guide-trigger.seen::after { display: none; }

.guide-modal {
  position: fixed; inset: 0; z-index: 500; display: none;
  align-items: center; justify-content: center; padding: 24px;
}
.guide-modal.open { display: flex; animation: fadeBg 0.25s ease; }
@keyframes fadeBg { from { opacity: 0; } to { opacity: 1; } }
.guide-backdrop {
  position: absolute; inset: 0; background: rgba(12, 35, 64, 0.45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.guide-dialog {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 32px 32px 26px; width: 100%; max-width: 580px;
  max-height: calc(100vh - 48px); overflow-y: auto;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.4);
  animation: dialogIn 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.guide-dialog::before {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--primary), var(--accent)); border-radius: 0 0 0 22px;
}
@keyframes dialogIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.guide-close {
  position: absolute; top: 14px; left: 14px; width: 34px; height: 34px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 10px;
  color: var(--ink-soft); cursor: pointer; display: grid; place-items: center; transition: all 0.2s;
}
.guide-close:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.guide-close svg { width: 16px; height: 16px; }
.guide-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; padding-left: 40px; }
.guide-icon {
  width: 50px; height: 50px; border-radius: 12px; background: var(--primary-soft);
  color: var(--primary); display: grid; place-items: center; flex-shrink: 0;
}
.guide-icon svg { width: 24px; height: 24px; }
.guide-tag {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  padding: 3px 10px; border-radius: 999px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; margin-bottom: 6px;
}
.guide-title { font-size: 19px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.guide-desc { font-size: 14px; color: var(--ink-soft); line-height: 1.9; margin-bottom: 18px; }
.guide-points {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; list-style: none; margin-bottom: 22px;
}
.guide-points li {
  display: flex; align-items: flex-start; gap: 10px; font-size: 12.5px;
  color: var(--ink-soft); line-height: 1.6; padding: 12px 14px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 10px;
}
.guide-points li .num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 6px;
  background: var(--primary); color: var(--card); display: grid; place-items: center;
  font-size: 11px; font-weight: 700; font-family: 'Readex Pro', sans-serif;
}
.guide-points li strong { color: var(--ink); font-weight: 700; display: block; margin-bottom: 2px; }
.guide-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 16px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; gap: 12px;
}
.kbd-hint { font-size: 12px; color: var(--muted); }
.kbd-hint kbd {
  display: inline-block; padding: 2px 8px; background: var(--bg);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  font-family: 'Readex Pro', monospace; font-size: 11px; color: var(--ink-soft); margin: 0 2px;
}
.guide-foot-btn {
  background: var(--ink); color: var(--bg); border: none; padding: 10px 20px;
  border-radius: 10px; font-family: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all 0.22s;
}
.guide-foot-btn:hover { background: var(--primary); transform: translateY(-1px); }

/* ========================================================
   5) محدّد الثيم
   ======================================================== */
.theme-selector { position: relative; }
.theme-btn {
  display: flex; align-items: center; gap: 8px; background: var(--card);
  border: 1px solid var(--line-soft); color: var(--ink-soft);
  padding: 7px 14px 7px 10px; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; transition: all 0.2s;
}
.theme-btn:hover { border-color: var(--primary); color: var(--ink); background: var(--bg-2); }
.theme-btn .theme-preview {
  width: 16px; height: 16px; border-radius: 50%;
  background: conic-gradient(var(--primary) 0 50%, var(--accent) 50% 100%);
  border: 1.5px solid var(--card); box-shadow: 0 0 0 1px var(--line); flex-shrink: 0;
}
.theme-btn .chevron { width: 12px; height: 12px; color: var(--muted); transition: transform 0.2s; }
.theme-btn.open .chevron { transform: rotate(180deg); }
.theme-dropdown {
  position: absolute; top: calc(100% + 10px); left: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px; padding: 18px; width: 320px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15); z-index: 200;
  opacity: 0; visibility: hidden; transform: translateY(-8px); transition: all 0.22s ease;
}
.theme-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }
.theme-dropdown-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft);
}
.theme-dropdown-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.theme-dropdown-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.theme-current-name {
  font-size: 11px; color: var(--primary); font-weight: 600;
  background: var(--primary-soft); padding: 4px 10px; border-radius: 999px;
}
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.theme-cell { cursor: pointer; padding: 4px; border-radius: 12px; transition: all 0.15s; }
.theme-cell:hover { background: var(--bg-2); }
.theme-cell.active { background: var(--primary-soft); }
.theme-swatch {
  width: 100%; aspect-ratio: 1; border-radius: 10px; border: 2px solid var(--card);
  box-shadow: 0 0 0 1px var(--line), 0 2px 4px rgba(0,0,0,0.08); transition: all 0.15s;
}
.theme-cell:hover .theme-swatch { transform: scale(1.06); }
.theme-cell.active .theme-swatch { box-shadow: 0 0 0 2px var(--primary), 0 4px 8px rgba(0,0,0,0.12); }
.theme-cell-label {
  display: block; font-size: 10px; text-align: center; margin-top: 5px;
  color: var(--ink-soft); font-weight: 500; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.theme-cell.active .theme-cell-label { color: var(--primary); font-weight: 700; }
.theme-swatch.sky    { background: linear-gradient(135deg, #0369a1 50%, #f59e0b 50%); }
.theme-swatch.navy   { background: linear-gradient(135deg, #1e3a8a 50%, #c2410c 50%); }
.theme-swatch.forest { background: linear-gradient(135deg, #14532d 50%, #b45309 50%); }
.theme-swatch.plum   { background: linear-gradient(135deg, #86198f 50%, #ca8a04 50%); }
.theme-swatch.slate  { background: linear-gradient(135deg, #334155 50%, #0d9488 50%); }
.theme-swatch.amber  { background: linear-gradient(135deg, #a16207 50%, #9a3412 50%); }
.theme-swatch.mint   { background: linear-gradient(135deg, #047857 50%, #7c3aed 50%); }
.theme-swatch.coral  { background: linear-gradient(135deg, #c44536 50%, #1e3a5f 50%); }

/* ========================================================
   6) رسائل (flash) عامة
   ======================================================== */
.alert {
  padding: 12px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; }
.alert-error { background: #fee2e2; border: 1px solid #fca5a5; color: #b91c1c; }
.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #15803d; }

/* ========================================================
   7) حركات مشتركة
   ======================================================== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.shake { animation: shake 0.4s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ========================================================
   8) تجاوب الأجزاء المشتركة
   ======================================================== */
@media (max-width: 500px) {
  .theme-dropdown { width: calc(100vw - 40px); right: auto; left: -20px; }
  .theme-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 960px) {
  .topbar { padding: 16px 20px; flex-wrap: wrap; gap: 12px; }
  .guide-trigger span { display: none; }
  .guide-trigger { padding: 7px; }
  .guide-dialog { padding: 26px 22px 22px; }
  .guide-points { grid-template-columns: 1fr; }
  .guide-head { padding-left: 36px; }
}
