/* ============================================================
   واجهة مساحات الملفات (workspace-item.php) — تنسيق مستقل
   جميع الأصناف تبدأ بـ wsx- فلا تتعارض مع أي صفحة أخرى.
   يعتمد ألوان المنظومة (platform.css) مع صقل بأسلوب التطبيق.
   ============================================================ */

.wsx {
  --wsx-navy: var(--navy-primary, #13243E);
  --wsx-teal: var(--teal-accent, #4F8C89);
  --wsx-teal-soft: var(--teal-soft, #E8EEEE);
  --wsx-gold: var(--gold-accent, #B9975B);
  --wsx-gold-soft: var(--gold-soft, #F4EEE3);
  --wsx-muted: #6b7280;
  --wsx-line: #E9EBEA;
  --wsx-bounce: cubic-bezier(.34, 1.56, .64, 1);
}

.wsx-i { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- شريط المعلومات والإجراءات ---------- */
.wsx-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin: 4px 0 20px;
}
.wsx-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wsx-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
  background: #fff; color: var(--wsx-navy); border: 1px solid var(--wsx-line);
}
.wsx-chip .wsx-i { color: var(--wsx-gold); }
.wsx-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.wsx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px; border: 1px solid #d3d6dc;
  background: #fff; color: var(--wsx-navy); font: inherit; font-size: 0.88rem; font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: transform .22s var(--wsx-bounce), box-shadow .22s var(--wsx-bounce), background .2s;
}
.wsx-btn:hover { background: #f7f8f7; }
.wsx-btn:active { transform: scale(.94); }
.wsx-btn-primary {
  background: var(--wsx-teal); border-color: var(--wsx-teal); color: #fff;
  box-shadow: 0 8px 18px -8px rgba(79, 140, 137, .75);
}
.wsx-btn-primary:hover { background: #447b78; }
.wsx-btn:focus-visible { outline: 2px solid var(--wsx-gold); outline-offset: 2px; }

/* ---------- عناوين الأقسام ---------- */
.wsx-sec {
  display: flex; align-items: center; gap: 8px; margin: 22px 0 10px;
  font-size: 0.95rem; font-weight: 800; color: var(--wsx-navy);
}
.wsx-sec::before {
  content: ""; width: 3px; height: 16px; border-radius: 2px; background: var(--wsx-gold);
}

/* ---------- مربع الأيقونة الملوّن ---------- */
.wsx-tile {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem;
}
.wsx-tile-gold  { background: var(--wsx-gold-soft); color: var(--wsx-gold); }
.wsx-tile-teal  { background: var(--wsx-teal-soft); color: #3d7673; }
.wsx-tile-red   { background: #F7EAE9; color: #B3413B; }
.wsx-tile-green { background: #E7F2ED; color: #2E7D5B; }
.wsx-tile-amber { background: #F6EFE1; color: #96691d; }
.wsx-tile-navy  { background: #E6E9EF; color: var(--wsx-navy); }
.wsx-tile-gray  { background: #EEF0EE; color: #5b6470; }
.wsx-tile svg { width: 1em; height: 1em; }

/* ---------- بطاقات المجلدات ---------- */
.wsx-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.wsx-card {
  position: relative; background: #fff; border-radius: 16px;
  box-shadow: 0 1px 6px rgba(19, 36, 62, .07);
  transition: transform .22s var(--wsx-bounce), box-shadow .22s var(--wsx-bounce);
  animation: wsx-in .45s var(--wsx-bounce) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.wsx-card:hover { box-shadow: 0 10px 22px -8px rgba(19, 36, 62, .18); transform: translateY(-2px); }
.wsx-card:active { transform: scale(.97); }
.wsx-card-link {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  color: inherit; text-decoration: none; border-radius: 16px;
}
.wsx-card-link:focus-visible { outline: 2px solid var(--wsx-gold); outline-offset: 2px; }
.wsx-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wsx-card-name {
  font-size: 0.95rem; font-weight: 800; color: var(--wsx-navy);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wsx-card-sub { font-size: 0.76rem; color: var(--wsx-muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.wsx-badge {
  font-size: 0.68rem; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: var(--wsx-teal-soft); color: #3d7673;
}
.wsx-go { color: #aab0b8; }
.wsx-card.has-menu .wsx-card-link { padding-inline-end: 52px; }

/* ---------- قائمة ⋯ (details) ---------- */
.wsx-menu { position: absolute; top: 50%; inset-inline-end: 10px; transform: translateY(-50%); }
.wsx-menu > summary {
  list-style: none; cursor: pointer; width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; color: var(--wsx-muted);
  border: 1px solid var(--wsx-line); background: #fff; transition: background .2s;
}
.wsx-menu > summary::-webkit-details-marker { display: none; }
.wsx-menu > summary:hover { background: #f3f4f3; }
.wsx-menu[open] > summary { background: var(--wsx-teal-soft); }
.wsx-pop {
  position: absolute; z-index: 20; inset-inline-end: 0; top: 40px; min-width: 250px;
  background: #fff; border: 1px solid var(--wsx-line); border-radius: 14px; padding: 8px;
  box-shadow: 0 16px 34px -10px rgba(19, 36, 62, .28);
  display: flex; flex-direction: column; gap: 6px;
}
.wsx-pop form { display: flex; gap: 6px; align-items: center; margin: 0; }
.wsx-pop form.wsx-stack { flex-direction: column; align-items: stretch; }
.wsx-pop form.wsx-stack input[type="file"] { width: 100%; }
.wsx-pop input[type="text"], .wsx-pop input[type="file"] {
  flex: 1; min-width: 0; font: inherit; font-size: 0.8rem; padding: 7px 9px;
  border: 1px solid #d3d6dc; border-radius: 9px; background: #fff;
}
.wsx-pop-btn {
  font: inherit; font-size: 0.8rem; font-weight: 700; padding: 7px 12px; border-radius: 9px;
  border: 1px solid #d3d6dc; background: #fff; color: var(--wsx-navy); cursor: pointer; white-space: nowrap;
}
.wsx-pop-btn:hover { background: #f3f4f3; }
.wsx-pop-danger { color: #B3413B; border-color: #ecc9c6; }
.wsx-pop-danger:hover { background: #F7EAE9; }
.wsx-pop-label { font-size: 0.72rem; color: var(--wsx-muted); margin: 0 2px; }

/* ---------- جدول الملفات ---------- */
.wsx-table { background: #fff; border-radius: 16px; box-shadow: 0 1px 6px rgba(19, 36, 62, .07); }
.wsx-trow {
  display: grid; gap: 12px; align-items: center; padding: 11px 16px;
  grid-template-columns: minmax(0, 2.4fr) 0.8fr 0.8fr 1fr auto;
  border-top: 1px solid var(--wsx-line);
  animation: wsx-in .4s var(--wsx-bounce) backwards; animation-delay: calc(var(--i, 0) * 35ms);
}
.wsx-trow:first-child { border-top: 0; }
.wsx-thead {
  background: #F3F4F3; color: var(--wsx-muted); font-size: 0.74rem; font-weight: 700;
  border-radius: 16px 16px 0 0; animation: none;
}
.wsx-fcell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.wsx-fcell .wsx-tile { width: 36px; height: 36px; font-size: 1.1rem; border-radius: 10px; }
.wsx-fname {
  font-size: 0.88rem; font-weight: 700; color: var(--wsx-navy); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.wsx-fname:hover { color: var(--wsx-teal); }
.wsx-kind { font-size: 0.7rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; justify-self: start; }
.wsx-kind-red   { background: #F7EAE9; color: #B3413B; }
.wsx-kind-teal  { background: var(--wsx-teal-soft); color: #2f5f5c; }
.wsx-kind-green { background: #E7F2ED; color: #2E7D5B; }
.wsx-kind-amber { background: #F6EFE1; color: #96691d; }
.wsx-kind-gold  { background: var(--wsx-gold-soft); color: #8a6b34; }
.wsx-kind-navy  { background: #E6E9EF; color: var(--wsx-navy); }
.wsx-kind-gray  { background: #EEF0EE; color: #5b6470; }
.wsx-cell { font-size: 0.8rem; color: #4b5563; }
.wsx-rowact { display: flex; gap: 6px; align-items: center; position: relative; }
.wsx-ib {
  width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--wsx-muted); border: 1px solid var(--wsx-line); background: #fff; text-decoration: none; cursor: pointer;
  transition: transform .2s var(--wsx-bounce), background .2s;
}
.wsx-ib:hover { background: var(--wsx-teal-soft); color: #3d7673; }
.wsx-ib:active { transform: scale(.9); }
.wsx-rowact .wsx-menu { position: relative; inset: auto; transform: none; }

/* ---------- حالة فارغة ---------- */
.wsx-empty {
  background: #fff; border: 1.5px dashed var(--wsx-gold); border-radius: 18px;
  padding: 44px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.wsx-empty .wsx-i { width: 44px; height: 44px; color: var(--wsx-gold); }
.wsx-empty h3 { margin: 4px 0 0; font-size: 1.05rem; font-weight: 800; color: var(--wsx-navy); }
.wsx-empty p { margin: 0 0 8px; font-size: 0.85rem; color: var(--wsx-muted); max-width: 420px; }

/* ---------- الفصول الدراسية (مساحة شخصية) ---------- */
.wsx-sem-title { margin: 18px 0 8px; font-size: 0.9rem; font-weight: 800; color: var(--wsx-navy); }

/* ---------- النوافذ (dialog) ---------- */
.wsx-dialog {
  border: 0; padding: 0; border-radius: 20px; width: min(560px, calc(100vw - 28px));
  box-shadow: 0 30px 70px -20px rgba(19, 36, 62, .5); color: var(--wsx-navy);
}
.wsx-dialog::backdrop { background: rgba(19, 36, 62, .5); }
.wsx-dialog[open] { animation: wsx-in .35s var(--wsx-bounce) both; }
.wsx-dhead { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 6px; }
.wsx-dhead h3 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.wsx-dbody { padding: 8px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.wsx-input {
  width: 100%; font: inherit; padding: 11px 13px; border: 1px solid #d3d6dc; border-radius: 12px; background: #fff;
}
.wsx-input:focus { outline: 2px solid var(--wsx-teal); outline-offset: 1px; }
.wsx-drop {
  position: relative; border: 1.5px dashed var(--wsx-gold); background: #FBF8F1; border-radius: 16px;
  padding: 28px 16px; text-align: center; color: var(--wsx-muted); font-size: 0.84rem;
  display: flex; flex-direction: column; align-items: center; gap: 4px; transition: background .2s;
}
.wsx-drop:hover, .wsx-drop:focus-within { background: #F7F0E2; }
.wsx-drop .wsx-i { width: 34px; height: 34px; color: var(--wsx-gold); }
.wsx-drop strong { color: var(--wsx-navy); font-size: 0.95rem; }
.wsx-drop input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.wsx-dialog .mu-panel { font-size: 0.82rem; }

/* ---------- حركة الدخول ---------- */
@keyframes wsx-in {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .wsx-card, .wsx-trow, .wsx-dialog[open] { animation: none; }
  .wsx-btn, .wsx-card, .wsx-ib { transition: none; }
}

/* ---------- متجاوب ---------- */
@media (max-width: 900px) {
  .wsx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .wsx-grid { grid-template-columns: 1fr; }
  .wsx-bar { flex-direction: column; align-items: stretch; }
  .wsx-actions .wsx-btn { flex: 1; }
  .wsx-thead { display: none; }
  .wsx-trow {
    grid-template-columns: auto auto 1fr auto; row-gap: 8px; column-gap: 10px;
  }
  .wsx-trow .wsx-fcell { grid-column: 1 / 4; grid-row: 1; }
  .wsx-trow .wsx-rowact { grid-column: 4; grid-row: 1; }
  .wsx-trow .wsx-kind { grid-row: 2; grid-column: 1; }
  .wsx-trow .wsx-cell:nth-of-type(2) { grid-row: 2; grid-column: 2; }
  .wsx-trow .wsx-cell:nth-of-type(3) { grid-row: 2; grid-column: 3; }
  .wsx-trow .wsx-kind, .wsx-trow .wsx-cell { font-size: 0.74rem; }
  .wsx-pop { min-width: 210px; }
}

/* بدون JavaScript: تُعرض النوافذ مضمَّنة في الصفحة */
.no-js .wsx-dialog { display: block; position: static; margin: 16px 0; box-shadow: none; border: 1px solid var(--wsx-line); }
.no-js .wsx-dhead button { display: none; }
