/* ════════════════════════════════════════════════════════════
   OTTIMA — layout.css
   الهيكل العام: الشريط الجانبي، الشريط العلوي، البطاقات
   جزء من main.css الأصلي، اتقسّم لملفات أصغر للصيانة الأسهل.
   ════════════════════════════════════════════════════════════ */

/* ══════════ SIDEBAR ══════════ */
.sidebar {
  position: fixed; top: 0; right: 0;
  width: var(--sw); height: 100vh; height: 100dvh;
  background: var(--sidebar); color: var(--sidebar-fg);
  display: flex; flex-direction: column; z-index: 100;
  border-left: 1px solid rgba(201,168,76,.12);
  transition: transform .3s;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid rgba(201,168,76,.12);
}
.sidebar-brand img { width: 38px; height: 38px; border-radius: 9px; object-fit: cover; border: 1px solid var(--gold-b); }
.sidebar-brand .name {
  font-size: 16px; font-weight: 800; letter-spacing: .06em;
  background: linear-gradient(120deg, var(--gold-l), var(--gold), var(--gold-d), var(--gold));
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: brandShift 6s ease infinite;
}
@keyframes brandShift { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.sidebar-brand .sub { font-size: 10px; color: var(--sidebar-muted); margin-top: 1px; }

.sidebar-user {
  margin: 10px; padding: 10px 12px;
  background: rgba(201,168,76,.08); border: 1px solid var(--gold-b);
  border-radius: var(--rs); display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold), var(--gold-d));
  color: #1C1A17; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-user .uname { font-size: 12.5px; font-weight: 700; color: var(--gold-l); }
.sidebar-user .urole { font-size: 10.5px; color: var(--sidebar-muted); margin-top: 2px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px; }
.nav-label { font-size: 10px; font-weight: 700; color: rgba(237,232,223,.3); text-transform: uppercase; letter-spacing: .1em; padding: 14px 10px 5px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--rs);
  color: rgba(237,232,223,.55); font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s, transform .1s; cursor: pointer; margin-bottom: 2px;
  border: none; background: none; width: 100%; text-align: right;
}
.nav-link:active { transform: scale(.98); }
.nav-link:hover { background: rgba(201,168,76,.1); color: var(--gold-l); }
.nav-link.active {
  background: linear-gradient(90deg, rgba(201,168,76,.2), rgba(201,168,76,.06));
  color: var(--gold); border-right: 2px solid var(--gold);
}
.nav-link .ico { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer { padding: 10px; border-top: 1px solid rgba(201,168,76,.12); }

.sidebar-backdrop {
  position: fixed; inset: 0; z-index: 99; background: rgba(0,0,0,.45);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}

/* ══════════ TOPBAR ══════════ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  min-height: var(--th); height: calc(var(--th) + env(safe-area-inset-top));
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; padding-top: env(safe-area-inset-top); gap: 12px;
}
[data-theme="dark"] .topbar { background: rgba(30,28,24,.85); }
.topbar .title { font-size: 16px; font-weight: 700; }
.topbar .subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; }
.topbar .actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--hover);
  display: flex; align-items: center; justify-content: center;
  color: var(--sub); transition: .15s;
}
.icon-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.icon-btn:hover { background: var(--gold-s); border-color: var(--gold-b); color: var(--gold); }
.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700; color: var(--success);
  padding: 4px 10px; background: var(--success-bg); border-radius: 20px; border: 1px solid var(--success);
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); position: relative; }
.live-dot::after { content:''; position:absolute; inset:0; border-radius:50%; background:inherit; animation: pulseRing 1.5s ease infinite; }
@keyframes pulseRing { 0% { transform: scale(1); opacity:.7; } 100% { transform: scale(2.6); opacity:0; } }

.menu-btn { display: none; }

/* ══════════ LAYOUT ══════════ */
.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.main-area { margin-right: var(--sw); flex: 1; display: flex; flex-direction: column; }
.main-content { padding: 24px; flex: 1; animation: viewFade .35s cubic-bezier(.22,1,.36,1); }
@keyframes viewFade { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform:none; } }

.app-footer {
  border-top: 1px solid var(--border); background: var(--card);
  padding: 14px 24px; padding-bottom: calc(14px + env(safe-area-inset-bottom));
  text-align: center; font-size: 12px; color: var(--muted);
}
.app-footer .brand { font-weight: 800; color: var(--gold); }

/* ══════════ CARDS ══════════ */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
  animation: cardReveal .4s cubic-bezier(.22,1,.36,1) both; transition: box-shadow .2s, border-color .2s;
}
@keyframes cardReveal { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform:none; } }
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title::before { content:''; width:3px; height:16px; background: linear-gradient(180deg,var(--gold-l),var(--gold-d)); border-radius:2px; }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }

