/* ==========================================================================
   CONTENT DASHBOARD — premium dark theme (Deep Black + Dark Gold)
   Self-contained, no framework. Rebrand from the :root block ONLY.
   ========================================================================== */

/* ---- 1. Theme tokens — THE single source of truth ----------------------- */
:root {
  /* Brand palette */
  --gold:        #c8a44d;   /* primary dark gold — buttons, icons, accents   */
  --gold-bright: #e9cd7a;   /* highlight gold — gradients, hovers            */
  --gold-deep:   #9c7c2a;   /* pressed / darker gold                         */
  --gold-tint:   rgba(200,164,77,.12);

  /* Deep blacks */
  --bg:          #0a0a0c;   /* page background                               */
  --surface:     #141417;   /* cards                                         */
  --surface-2:   #08080a;   /* sidebar / deepest layer                       */
  --elevate:     #1b1b1f;   /* inputs, hover fills                           */

  /* Ink */
  --text:        #ededf0;
  --muted:       #8a8a93;
  --border:      rgba(255,255,255,.08);
  --danger:      #e5566f;
  --ok:          #4ec98a;

  --radius:      14px;
  --shadow:      0 1px 2px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.45);
  --sidebar-w:   250px;
  --font:        "Tajawal", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

/* ---- 2. Reset ----------------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
::selection { background: var(--gold); color: #0a0a0c; }

/* ---- 3. App shell ------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface-2);
  border-inline-end: 1px solid var(--border);   /* RTL-aware: edge facing main */
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 20px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand b { font-size: 15px; font-weight: 700; letter-spacing: .01em; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a .ico { width: 18px; text-align: center; color: var(--gold); opacity: .75; }
.nav a:hover { background: var(--elevate); color: var(--text); }
.nav a.active { background: var(--gold-tint); color: var(--gold-bright); }
.nav a.active .ico { opacity: 1; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 64px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; font-weight: 700; }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold-deep));
  color: #0a0a0c; display: grid; place-items: center; font-weight: 800;
}
.content { padding: 28px; display: flex; flex-direction: column; gap: 24px; }

/* ---- 4. Cards ----------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 15px; font-weight: 700; }
.card-head p { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 22px; }

/* ---- 5. Forms ----------------------------------------------------------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 7px; }
.field input, .field textarea {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--elevate); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 100px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #5c5c66; }
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-tint);
}
.field .hint { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ---- 6. Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  font-weight: 600; font-size: 13.5px; background: var(--elevate); color: var(--text);
  transition: filter .15s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--gold); }
.btn-primary {
  border: none; color: #0a0a0c;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: rgba(229,86,111,.1); border-color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

/* ---- 7. Tabs ------------------------------------------------------------ */
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 11px; border: 1px solid var(--border); }
.tabs button { flex: 1; padding: 9px 14px; border-radius: 8px; border: none; background: transparent; color: var(--muted); font-weight: 600; }
.tabs button.active { background: var(--elevate); color: var(--gold-bright); }

/* ---- 8. Media manager --------------------------------------------------- */
.dropzone {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 26px; text-align: center; color: var(--muted);
  transition: border-color .15s, background .15s, color .15s; cursor: pointer;
}
.dropzone u { color: var(--gold-bright); }
.dropzone.drag { border-color: var(--gold); background: var(--gold-tint); color: var(--gold-bright); }
.url-add { display: flex; gap: 10px; margin-top: 14px; }
.url-add input {
  flex: 1; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--elevate); color: var(--text); font: inherit;
}
.url-add input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-tint); }

.media-grid { display: grid; gap: 14px; margin-top: 18px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.media-item { position: relative; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface-2); cursor: grab; }
.media-item.dragging { opacity: .4; }
.media-item.over { outline: 2px solid var(--gold); outline-offset: -2px; }
.media-item .thumb { aspect-ratio: 1 / 1; width: 100%; object-fit: cover; background: #000; }
.media-item .meta { padding: 8px 10px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.media-item .del { position: absolute; top: 8px; inset-inline-end: 8px; width: 28px; height: 28px; border-radius: 8px; border: none; background: rgba(0,0,0,.65); color: #fff; display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.media-item:hover .del { opacity: 1; }
.media-item .del:hover { color: var(--gold-bright); }
.drag-badge { position: absolute; top: 8px; inset-inline-start: 8px; background: rgba(0,0,0,.7); color: var(--gold-bright); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.empty { color: var(--muted); text-align: center; padding: 30px; font-size: 13px; }

/* ---- 9. Toast ----------------------------------------------------------- */
.toast-wrap { position: fixed; inset-inline-end: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 50; }
.toast { background: var(--elevate); border: 1px solid var(--border); color: var(--text); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; }
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }

/* ---- 10. Responsive ----------------------------------------------------- */
.mobile-close-btn { display: none; position: absolute; top: 12px; left: 12px; font-size: 18px; padding: 4px; color: var(--muted); background: transparent; border: none; z-index: 101; cursor: pointer; }
.mobile-close-btn:hover { color: var(--text); }

@media (max-width: 860px) {
  .sidebar { display: none; position: fixed; inset: 0 0 0 auto; z-index: 100; box-shadow: 0 0 40px rgba(0,0,0,0.8); }
  .sidebar.mobile-open { display: flex; }
  
  .mobile-menu-btn { 
    display: flex !important; 
    align-items: center; 
    justify-content: center;
    position: fixed; 
    top: 12px; 
    right: 12px;
    width: 46px; 
    height: 46px; 
    border-radius: 50%; 
    background: linear-gradient(135deg, var(--gold-bright), var(--gold)); 
    color: #0a0a0c !important;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    z-index: 99;
    font-size: 24px !important;
    padding: 0 !important;
  }
  
  .topbar { padding-right: 70px; padding-left: 16px; } /* Prevent overlap */
  
  .mobile-close-btn { display: block !important; }
  .content { padding: 18px; }
  body.sidebar-open::before { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 90; }
}

/* ---- 11. Content editor sections --------------------------------------- */
.content-section { border: 1px solid var(--border); border-radius: 12px; padding: 18px 18px 4px; margin-bottom: 20px; }
.content-section legend { padding: 0 8px; color: var(--gold-bright); font-weight: 700; font-size: 13.5px; }

/* ---- 12. Media slots ---------------------------------------------------- */
.slot-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.slot { position: relative; aspect-ratio: 4 / 5; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.slot.filled .slot-img { width: 100%; height: 100%; object-fit: cover; }
.slot-actions { position: absolute; inset-inline: 0; bottom: 0; display: flex; gap: 8px; padding: 8px; background: linear-gradient(to top, rgba(0,0,0,.78), transparent); }
.slot-actions .btn { flex: 1; justify-content: center; }
.slot-empty { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: transparent; border: none; color: var(--muted); font-weight: 600; }
.slot-empty:hover { color: var(--gold-bright); background: var(--gold-tint); }
.slot-plus { font-size: 28px; line-height: 1; color: var(--gold); }

.media-rules { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.media-rules b { color: var(--text); }
.media-counter { margin-top: 8px; font-size: 14px; color: var(--text); }
.media-counter b { color: var(--gold-bright); font-size: 16px; }

.gallery-cat { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.gallery-cat select { padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--elevate); color: var(--text); font: inherit; }
.gallery-cat select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-tint); }
