/* files/public/assets/theme.css*/
:root{
  --moe-green: #006C35;   /* Saudi green */
  --moe-teal:  #00A28A;

  --bg:    #f5f7f9;
  --card:  #ffffff;
  --text:  #0f172a;
  --muted: #64748b;
  --border: rgba(0,0,0,.12);

  --accent:      var(--moe-green);
  --accent-weak: #bcf0ea;
}

html.dark{
  --bg:    #0e1713;
  --card:  #101a15;
  --text:  #eaf2ee;
  --muted: #a3b3ad;
  --border: rgba(255,255,255,.14);

  --accent:      #10b981;
  --accent-weak: #134e4a;
}

/* ================== العناصر الأساسية ================== */
body{ background:var(--bg); color:var(--text); }
header, .navbar, .site-header{ background:var(--card); color:var(--text); border-bottom:1px solid rgba(0,0,0,.06); }
footer, .site-footer{ background:var(--card); color:var(--text); }
.card{ background:var(--card); color:var(--text); border:1px solid var(--border); border-radius:16px; }

.muted{ color:var(--muted); }
.toolbar{ display:flex; gap:.5rem; align-items:center; }
.sidebar{ position:sticky; top:5rem; }

/* ================== أزرار ================== */
.btn{
  display:inline-flex; align-items:center; gap:.5rem;
  background: var(--accent); color:#fff;
  padding:.55rem .95rem; border-radius:.75rem;
  border:1px solid var(--accent);
  font-weight:600; line-height:1.2;
  transition: background .15s, opacity .15s, box-shadow .15s;
  text-decoration:none;
}
.btn:hover{ opacity:.95; }
.btn:focus{ outline:none; box-shadow:0 0 0 3px rgba(16,185,129,.25); }

.btn-ghost{
  display:inline-flex; align-items:center; gap:.35rem;
  background: transparent; color: var(--text);
  border:1px solid transparent; padding:.45rem .7rem; border-radius:.65rem;
}
.btn-ghost:hover{ background: rgba(0,0,0,.05); }
html.dark .btn-ghost:hover{ background: rgba(255,255,255,.08); }

.btn-outline{ background:transparent; color:var(--text); border:1px solid var(--border); padding:.45rem .7rem; border-radius:10px; }
.btn-outline:hover{ background: rgba(0,0,0,.04); }
html.dark .btn-outline:hover{ background: rgba(255,255,255,.06); }

.btn-danger{
  background:#b91c1c; color:#fff; padding:.5rem .8rem; border-radius:10px; border:1px solid #b91c1c;
}
html.dark .btn-danger{ background:#dc2626; border-color:#dc2626; }

/* ================== أيقونات وشارات ================== */
.icon{ width:28px; height:28px; opacity:.9; }
.icon-lg{ width:52px; height:52px; opacity:.9; }

.icon-btn{ display:inline-flex; align-items:center; justify-content:center; width:36px; height:36px; border-radius:999px; border:none; background:transparent; cursor:pointer; }
.icon-btn:hover{ background: rgba(0,0,0,.06); }
html.dark .icon-btn:hover{ background: rgba(255,255,255,.08); }
.icon-btn svg{ width:18px; height:18px; }
.icon-btn-danger{ color:#b91c1c; } 
html.dark .icon-btn-danger{ color:#fecaca; }

.badge{ background:#eef2f7; color:#334155; font-size:.75rem; padding:.15rem .5rem; border-radius:.5rem; }
html.dark .badge{ background:#1f2a25; color:#cbd5e1; }

/* ================== جداول ================== */
.table-list{ width:100%; font-size:.92rem; }
.table-list th, .table-list td{ padding:.65rem .5rem; border-bottom:1px solid var(--border); }
.tr-sel{ background: color-mix(in oklab, var(--card) 88%, var(--accent-weak)); }

/* ================== شبكة الملفات ================== */
.grid-drive{ display:grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap:14px; }
.file-card{ position:relative; border:1px solid var(--border); border-radius:16px; padding:14px; background:var(--card); transition:.15s; }
.file-card:hover{ transform:translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.06); }
.file-title{ font-weight:700; margin-top:.5rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-align:center; }
.file-sub{ font-size:.8rem; color:var(--muted); margin-top:.2rem; text-align:center; }
.file-card.selected{ outline:2px solid var(--accent); outline-offset:2px; background: color-mix(in oklab, var(--card) 88%, var(--accent-weak)); }

/* اختيار متعدد في الشبكة */
.select-chk{ position:absolute; top:10px; inset-inline-start:10px; display:inline-flex; align-items:center; gap:.4rem; z-index:30; }
.select-chk input{ appearance:none; width:20px; height:20px; border:2px solid var(--muted); border-radius:6px; background:transparent; cursor:pointer; }
.select-chk input:checked{ background:var(--accent); border-color:var(--accent); box-shadow: inset 0 0 0 3px #fff; }
.file-card a{ display:block; position:relative; z-index:10; }

/* ================== المصغّرات (مربّع ثابت) ================== */
.thumb-wrap{ display:flex; justify-content:center; margin-bottom:.5rem; }
.thumb, .pdf-canvas, .mini-thumb{
  display:block; overflow:hidden; background: rgba(0,0,0,.05);
  border-radius:12px;
}
html.dark .thumb, html.dark .pdf-canvas, html.dark .mini-thumb{ background: rgba(255,255,255,.08); }

.thumb{ width:120px; height:120px; }
.mini-thumb{ width:44px; height:44px; border-radius:8px; }

.thumb img, .thumb video,
.mini-thumb img, .mini-thumb video{
  width:100%; height:100%; object-fit:cover; display:block;
}

.thumb-icon{ width:100%; height:100%; display:flex; align-items:center; justify-content:center; }

/* ================== عناصر جانبية ================== */
header .brand{ display:flex; align-items:center; gap:.5rem; }
.brand-mark{ width:26px; height:26px; border-radius:.4rem; background:linear-gradient(135deg,var(--moe-green),var(--moe-teal)); }

.switch{ display:inline-flex; align-items:center; gap:.4rem; font-size:.85rem; color:var(--muted); }
.switch input{ accent-color: var(--accent); }

/* ================== حقول في الوضع الداكن ================== */
html.dark input, html.dark textarea, html.dark select{
  background: var(--card) !important; color: var(--text) !important; border-color:#334155 !important;
}
html.dark option{ background: #0f1713; color: #eaf2ee; }

/* ================== dropzone (للصفحات الأخرى) ================== */
.dropzone{ border:2px dashed rgba(0,0,0,.15); border-radius:1rem; padding:1.5rem; text-align:center; background:rgba(0,0,0,.02) }
.dropzone.dragover{ background:rgba(34,197,94,.08) }

/* ================== مودال QR ================== */
.qr-box{ display:flex; align-items:center; justify-content:center; }

/* ============ تحسينات Responsive عامة ============ */

/* اجعل كل الصور/الفيديو/الإطارات تتقلص مع العرض */
img, video, iframe {
  max-width: 100%;
  height: auto;
}

/* التفافات أذكى للنصوص الطويلة (روابط/مسارات) */
.break-anywhere { overflow-wrap: anywhere; word-break: break-word; }

/* جداول قابلة للتمرير أفقياً تلقائياً على الشاشات الصغيرة */
.table-wrap { overflow-x: auto; }
.table-wrap > table { min-width: 600px; }

/* تقليل الحشوات والمسافات على الشاشات الصغيرة */
@media (max-width: 480px){
  .card { border-radius: 12px; }
  .btn { padding: .5rem .75rem; border-radius: .6rem; }
  .btn-ghost, .btn-outline { padding: .45rem .6rem; }
  .icon { width:24px; height:24px; }
  .icon-btn { width:34px; height:34px; }
  .grid-drive { grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 10px; }
  header .max-w-6xl, main .max-w-6xl { padding-inline: .75rem; }
}

/* صفحات تحتوي جداول كثيرة: اجبر عناوين الخلايا على تصغير الخط */
@media (max-width: 640px){
  .table-list th, .table-list td { padding: .5rem .4rem; font-size: .88rem; }
}

/* عناصر داخل الشبكات لا تقفز على الموبايل */
.file-title, .file-sub { text-align: start; }


/* === Helpers لإظهار/إخفاء حسب العرض === */
.desktop-only { display: block; }
.mobile-only { display: none; }
@media (max-width: 1024px){
  .desktop-only { display: none !important; }
  .mobile-only  { display: block !important; }
}

/* منع التمرير الأفقي لجسم الصفحة بالكامل */
html, body { overflow-x: hidden; }

/* ======== Mobile Drawer (Navbar) ======== */
.nav-drawer {
  position: fixed;
  inset-inline: 0;
  top: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  transform: translateY(-100%);
  transition: transform .22s ease-in-out;
  z-index: 60;             /* فوق كل شيء */
  box-sizing: border-box;
  width: 100vw;            /* يمنع بروز العرض */
}
/* عند الفتح */
.nav-drawer.open { transform: translateY(0); }

/* طبقة تغميق الخلفية */
.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease-in-out;
}
.nav-overlay.show { opacity: 1; pointer-events: auto; }

/* شبكة روابط مرنة داخل القائمة */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .5rem;
}
/* تحسينات للجوال الصغير جدًا */
@media (max-width: 480px){
  .link-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* زر الإغلاق يكون فوق أي عناصر */
.nav-drawer .close-btn {
  z-index: 1;
}

