/* ============================================================
   AEHI Control Center — v6 MOTION & POLISH LAYER (2.10.1)
   انیمیشن ورود، hover سه‌بعدی کارت‌ها، ripple دکمه‌ها،
   میزکار محتوای سریع، اسکلتون لودینگ و ماتریس دسترسی جدید
   ============================================================ */

/* ---------- ۱) متغیرها و پایه ---------- */
:root {
  --v6-ease: cubic-bezier(.22, .9, .3, 1);
  --v6-ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
  --v6-fast: .18s;
  --v6-med: .32s;
  --v6-slow: .5s;
}

/* ---------- ۲) انیمیشن ورود صفحه‌ها ---------- */
@keyframes v6ViewIn {
  from { opacity: 0; transform: translateY(14px) scale(.994); }
  to { opacity: 1; transform: none; }
}
.view.active { animation: v6ViewIn var(--v6-med) var(--v6-ease) both; }
@keyframes v6Stagger {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.view.active .metric-card,
.view.active .center-card,
.view.active .panel > .data-row,
.view.active .fleet-row,
.view.active .content-media-card,
.view.active .v4-file-card { animation: v6Stagger .42s var(--v6-ease) both; }
.view.active .metric-card:nth-child(1) { animation-delay: .02s; }
.view.active .metric-card:nth-child(2) { animation-delay: .06s; }
.view.active .metric-card:nth-child(3) { animation-delay: .1s; }
.view.active .metric-card:nth-child(4) { animation-delay: .14s; }
.view.active .metric-card:nth-child(5) { animation-delay: .18s; }
.view.active .metric-card:nth-child(6) { animation-delay: .22s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- ۳) hover سه‌بعدی کارت‌ها ---------- */
.metric-card,
.center-card,
.content-media-card,
.v4-file-card,
.v4-folder-tile,
.operation-tile,
.package-card {
  transition: transform var(--v6-fast) var(--v6-ease), box-shadow var(--v6-fast) var(--v6-ease);
  will-change: transform;
}
.metric-card:hover,
.center-card:hover,
.operation-tile:hover,
.package-card:hover {
  transform: translateY(-3px) perspective(600px) rotateX(2deg);
  box-shadow: 0 14px 34px -12px rgba(0, 0, 0, .35);
}
.content-media-card:hover,
.v4-file-card:hover {
  transform: translateY(-4px) scale(1.012);
  box-shadow: 0 18px 40px -14px rgba(80, 90, 255, .4);
  z-index: 2;
}
.content-media-card.selected,
.v4-file-card.selected {
  border-color: var(--accent, #6f7cff);
  box-shadow: 0 0 0 2px var(--accent, #6f7cff), 0 12px 28px -12px rgba(111, 124, 255, .5);
}

/* ---------- ۴) ripple دکمه‌ها ---------- */
.primary-button, .secondary-button, .danger-button, .v5-icon-btn {
  position: relative;
  overflow: hidden;
}
@keyframes v6Ripple {
  from { transform: scale(0); opacity: .5; }
  to { transform: scale(2.6); opacity: 0; }
}
.v6-ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
  pointer-events: none;
  animation: v6Ripple .55s ease-out forwards;
}

/* ---------- ۵) اسکلتون هوشمند ---------- */
@keyframes v6Shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.skeleton-card, .v6-skeleton {
  background: linear-gradient(100deg, rgba(120,130,160,.12) 40%, rgba(120,130,160,.22) 50%, rgba(120,130,160,.12) 60%);
  background-size: 200% 100%;
  animation: v6Shimmer 1.4s linear infinite;
  border-radius: 14px;
}

/* ---------- ۶) میزکار محتوا (content desk) — ریدیزاین سریع ---------- */
.content-desk { display: flex; flex-direction: column; gap: 14px; }
.content-desk-hero {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap;
  padding: 16px 18px; border-radius: 18px;
  background: linear-gradient(135deg, rgba(111,124,255,.14), rgba(42,216,212,.08));
  border: 1px solid rgba(111,124,255,.25);
}
.content-desk-hero h3 { font-size: 1.15rem; margin: 2px 0; }
.content-desk-hero h3 small { margin-inline-start: 8px; opacity: .65; font-weight: 500; }
.content-sync-card {
  display: flex; flex-direction: column; gap: 4px; min-width: 260px; max-width: 340px;
  padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}
.content-desk-settings { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.content-setting-group { display: flex; align-items: center; gap: 10px; }
.content-setting-group > span { font-size: .8rem; opacity: .7; font-weight: 600; }
.desk-segment {
  border: 1px solid rgba(255,255,255,.14); background: transparent; color: inherit;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: .82rem;
  transition: all var(--v6-fast) var(--v6-ease);
}
.desk-segment:hover { border-color: var(--accent, #6f7cff); transform: translateY(-1px); }
.desk-segment.active {
  background: var(--accent, #6f7cff); border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 6px 16px -6px rgba(111,124,255,.6);
}
.content-desk-tabs {
  display: flex; gap: 6px; padding: 4px; border-radius: 12px;
  background: rgba(255,255,255,.05); width: fit-content;
}
.content-desk-tabs button {
  border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; font-size: .85rem;
  padding: 8px 16px; border-radius: 9px; transition: all var(--v6-fast) var(--v6-ease);
  display: inline-flex; align-items: center; gap: 6px;
}
.content-desk-tabs button small { opacity: .6; }
.content-desk-tabs button:hover { background: rgba(255,255,255,.08); }
.content-desk-tabs button.active { background: var(--accent, #6f7cff); color: #fff; font-weight: 600; box-shadow: 0 4px 14px -6px rgba(111,124,255,.55); }

/* گرید فشرده و سریع رسانه */
.content-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}
.content-media-card {
  position: relative; display: flex; flex-direction: column; gap: 0; overflow: hidden;
  border-radius: 14px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.035);
  transition: transform var(--v6-fast) var(--v6-ease), box-shadow var(--v6-fast) var(--v6-ease), border-color var(--v6-fast);
}
.content-media-select {
  position: absolute; top: 8px; inset-inline-start: 8px; z-index: 3;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px; font-size: .68rem; font-weight: 600;
  background: rgba(10,14,25,.72); backdrop-filter: blur(6px);
  cursor: pointer; transition: background var(--v6-fast);
}
.content-media-select:hover { background: rgba(10,14,25,.92); }
.content-media-select input { accent-color: var(--accent, #6f7cff); }
.content-media-thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 16/9; border: 0; padding: 0;
  background: rgba(0,0,0,.3); cursor: zoom-in; overflow: hidden;
}
.content-media-thumb img, .content-media-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.content-media-thumb em {
  position: absolute; bottom: 6px; inset-inline-end: 6px; z-index: 2;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: .7rem; font-style: normal;
  background: rgba(10,14,25,.75); color: #fff;
}
.content-media-card.processing .content-media-thumb { opacity: .45; filter: grayscale(.5); }
.content-media-caption { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 3px; }
.content-media-caption b { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content-media-caption small { opacity: .6; font-size: .7rem; }
.content-ready-state { font-size: .68rem; font-weight: 700; }
.content-ready-state.ready { color: #43d692; }
.content-ready-state.waiting { color: #ffc36b; }

/* نوار پوشه‌ها به‌صورت چیپ فشرده */
.content-folder-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.content-folder-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(255,255,255,.14); background: transparent; color: inherit;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: .78rem;
  transition: all var(--v6-fast) var(--v6-ease);
}
.content-folder-chip small { opacity: .55; }
.content-folder-chip:hover { border-color: var(--accent, #6f7cff); transform: translateY(-1px); }
.content-folder-chip.active { background: var(--accent, #6f7cff); border-color: transparent; color: #fff; font-weight: 600; }

/* صف پخش فشرده */
.content-queue-pane { display: grid; grid-template-columns: 1fr 240px; gap: 14px; }
@media (max-width: 900px) { .content-queue-pane { grid-template-columns: 1fr; } }
.content-queue-list { display: flex; flex-direction: column; gap: 6px; }
.content-queue-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.09); background: rgba(255,255,255,.03);
  transition: border-color var(--v6-fast), background var(--v6-fast);
}
.content-queue-row:hover { border-color: rgba(111,124,255,.4); }
.content-queue-row.drop-target { border-color: var(--accent, #6f7cff); background: rgba(111,124,255,.1); }
.content-queue-number { font-weight: 700; opacity: .5; min-width: 22px; text-align: center; }
.content-queue-thumb { width: 52px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; border: 0; padding: 0; background: rgba(0,0,0,.3); cursor: zoom-in; flex-shrink: 0; }
.content-queue-thumb img, .content-queue-thumb video { width: 100%; height: 100%; object-fit: cover; }
.content-live-preview {
  border-radius: 14px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.03);
  padding: 12px; text-align: center; align-self: start; position: sticky; top: 12px;
}
.content-preview-thumb { aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.content-preview-thumb img, .content-preview-thumb video { width: 100%; height: 100%; object-fit: contain; }

/* ---------- ۷) دکمه‌های آیکونی ردیف ناوگان ---------- */
.v5-actions { display: inline-flex; align-items: center; gap: 6px; }
.v5-icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.05); color: inherit;
  cursor: pointer; transition: all var(--v6-fast) var(--v6-ease);
}
.v5-icon-btn svg { width: 16px; height: 16px; }
.v5-icon-btn:hover { border-color: var(--accent, #6f7cff); background: rgba(111,124,255,.14); transform: translateY(-1px); box-shadow: 0 4px 12px -4px rgba(111,124,255,.4); }
.v5-icon-btn.accent { border-color: rgba(111,124,255,.45); color: var(--accent, #6f7cff); }
.v5-icon-btn.accent:hover { background: var(--accent, #6f7cff); color: #fff; }
.row-button.open-device {
  display: inline-flex; align-items: center; gap: 6px;
}
.row-button.open-device svg { width: 14px; height: 14px; }

/* ---------- ۸) ماتریس دسترسی جدید ---------- */
.permission-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px; padding: 10px; border-radius: 12px; border: 1px solid rgba(255,255,255,.1);
}
.permission-grid legend { font-size: .8rem; font-weight: 700; padding: 0 8px; opacity: .8; }
.permission-bulk-actions { flex-wrap: wrap; margin-bottom: 8px; }
.permission-scroll { max-height: 46vh; overflow: auto; padding-inline-end: 4px; }

/* ---------- ۹) نوتیفیکیشن و مودال بهتر ---------- */
.toast { animation: v6Stagger .3s var(--v6-ease-bounce) both; }
.modal { animation: v6ViewIn .28s var(--v6-ease) both; }
@keyframes v6ViewIn { from { opacity: 0; transform: translateY(14px) scale(.994); } to { opacity: 1; transform: none; } }

/* ---------- ۱۰) ناوبری سایدبار با نشانگر ---------- */
.nav-item { position: relative; transition: background var(--v6-fast) var(--v6-ease), transform var(--v6-fast); }
.nav-item:hover { transform: translateX(-2px); }
[dir="ltr"] .nav-item:hover { transform: translateX(2px); }
.nav-item.active::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 18%; height: 64%;
  width: 3px; border-radius: 3px; background: var(--accent, #6f7cff);
  animation: v6NavIn .25s var(--v6-ease) both;
}
@keyframes v6NavIn { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ---------- ۱۱) تم روشن ---------- */
[data-theme="light"] .content-sync-card { background: rgba(0,0,0,.03); border-color: rgba(0,0,0,.08); }
[data-theme="light"] .content-media-card { background: #fff; border-color: rgba(0,0,0,.09); }
[data-theme="light"] .content-media-select { background: rgba(255,255,255,.85); color: #1a2233; }
[data-theme="light"] .content-desk-hero { background: linear-gradient(135deg, rgba(111,124,255,.1), rgba(42,216,212,.06)); }
[data-theme="light"] .v5-icon-btn { background: rgba(0,0,0,.04); border-color: rgba(0,0,0,.12); }
[data-theme="light"] .content-desk-tabs { background: rgba(0,0,0,.05); }
[data-theme="light"] .content-queue-row,
[data-theme="light"] .content-live-preview { background: #fff; border-color: rgba(0,0,0,.09); }
[data-theme="light"] .permission-grid { border-color: rgba(0,0,0,.1); }

/* ============================================================
   AEHI THEME BRIDGE  —  2026-09-17 (css-theme-audit)
   The light layer below was written only for [data-theme="light"].
   applyTheme() also toggles body.theme-dark, so both selectors must
   resolve to the SAME light appearance. Same rules, same values.
   ============================================================ */
:is(body:not(.theme-dark), html[data-theme="light"]) .content-sync-card { background: rgba(0, 0, 0, .03); border-color: rgba(0, 0, 0, .08); }
:is(body:not(.theme-dark), html[data-theme="light"]) .content-media-card { background: #fff; border-color: rgba(0, 0, 0, .09); }
:is(body:not(.theme-dark), html[data-theme="light"]) .content-media-select { background: rgba(255, 255, 255, .85); color: #1a2233; }
:is(body:not(.theme-dark), html[data-theme="light"]) .content-desk-hero { background: linear-gradient(135deg, rgba(111, 124, 255, .1), rgba(42, 216, 212, .06)); }
:is(body:not(.theme-dark), html[data-theme="light"]) .v5-icon-btn { background: rgba(0, 0, 0, .04); border-color: rgba(0, 0, 0, .12); }
:is(body:not(.theme-dark), html[data-theme="light"]) .content-desk-tabs { background: rgba(0, 0, 0, .05); }
:is(body:not(.theme-dark), html[data-theme="light"]) .content-queue-row,
:is(body:not(.theme-dark), html[data-theme="light"]) .content-live-preview { background: #fff; border-color: rgba(0, 0, 0, .09); }
:is(body:not(.theme-dark), html[data-theme="light"]) .permission-grid { border-color: rgba(0, 0, 0, .1); }

/* Dark counterparts of the same components (they default to the dark palette
   in bundle.css; re-stated here so every mechanism resolves identically). */
:is(body.theme-dark, html[data-theme="dark"]) .content-sync-card { background: rgba(255, 255, 255, .04); border-color: rgba(255, 255, 255, .08); }
:is(body.theme-dark, html[data-theme="dark"]) .content-media-card { background: #171a22; border-color: rgba(255, 255, 255, .09); }
:is(body.theme-dark, html[data-theme="dark"]) .content-media-select { background: rgba(10, 14, 25, .75); color: #eaf2ff; }
:is(body.theme-dark, html[data-theme="dark"]) .content-desk-hero { background: linear-gradient(135deg, rgba(111, 124, 255, .12), rgba(42, 216, 212, .07)); }
:is(body.theme-dark, html[data-theme="dark"]) .v5-icon-btn { background: rgba(255, 255, 255, .04); border-color: rgba(255, 255, 255, .12); }
:is(body.theme-dark, html[data-theme="dark"]) .content-desk-tabs { background: rgba(255, 255, 255, .05); }
:is(body.theme-dark, html[data-theme="dark"]) .content-queue-row,
:is(body.theme-dark, html[data-theme="dark"]) .content-live-preview { background: #171a22; border-color: rgba(255, 255, 255, .09); }
:is(body.theme-dark, html[data-theme="dark"]) .permission-grid { border-color: rgba(255, 255, 255, .1); }
