/* ── Brand tokens (temporary identity; swap here when the client's identity arrives) ── */
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(../fonts/plex-arabic-400.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(../fonts/plex-arabic-500.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(../fonts/plex-arabic-600.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(../fonts/plex-arabic-700.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(../fonts/plex-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(../fonts/plex-latin-500.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(../fonts/plex-latin-600.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(../fonts/plex-latin-700.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }

:root {
  --brand-900: #2A0721;
  --brand-800: #3A0A2E;
  --brand-700: #5A1A4D;
  --brand-600: #6B1F5C;
  --brand-500: #8A2A76;
  --brand-100: #F3E8F0;
  --brand-50:  #FAF5F8;
  --accent:    #E8552A;
  --accent-600:#CF4519;
  --accent-100:#FDEAE3;
  --ink:       #23192A;
  --muted:     #6E6474;
  --line:      #E9E3EC;
  --surface:   #FFFFFF;
  --canvas:    #F6F3F7;
  --radius:    14px;
  --shadow-sm: 0 1px 2px rgba(42,7,33,.06), 0 1px 1px rgba(42,7,33,.04);
  --shadow:    0 8px 24px -10px rgba(42,7,33,.22);

  --bs-body-font-family: "Plex Arabic", "Segoe UI", Tahoma, sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--canvas);
  --bs-primary: var(--brand-600);
  --bs-primary-rgb: 107,31,92;
  --bs-link-color: var(--brand-600);
  --bs-link-color-rgb: 107,31,92;
  --bs-link-hover-color: var(--brand-800);
  --bs-border-color: var(--line);
  --bs-border-radius: 10px;
  --bs-border-radius-lg: var(--radius);
  --bs-focus-ring-color: rgba(107,31,92,.22);
}

body { font-size: .94rem; -webkit-font-smoothing: antialiased; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.text-muted { color: var(--muted) !important; }
.fw-600 { font-weight: 600; }
.small-caps { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* Buttons */
.btn { font-weight: 500; border-radius: 10px; }
.btn-primary { --bs-btn-bg: var(--brand-600); --bs-btn-border-color: var(--brand-600); --bs-btn-hover-bg: var(--brand-700); --bs-btn-hover-border-color: var(--brand-700); --bs-btn-active-bg: var(--brand-800); --bs-btn-active-border-color: var(--brand-800); --bs-btn-disabled-bg: var(--brand-500); --bs-btn-disabled-border-color: var(--brand-500); }
.btn-accent { --bs-btn-color:#fff; --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-color:#fff; --bs-btn-hover-bg: var(--accent-600); --bs-btn-hover-border-color: var(--accent-600); --bs-btn-active-bg: var(--accent-600); --bs-btn-active-color:#fff; }
.btn-soft { --bs-btn-bg: var(--brand-100); --bs-btn-color: var(--brand-700); --bs-btn-border-color: transparent; --bs-btn-hover-bg: #ead8e4; --bs-btn-hover-color: var(--brand-800); --bs-btn-active-bg:#e2cadb; }
.btn-ghost { --bs-btn-color: var(--ink); --bs-btn-hover-bg: rgba(42,7,33,.06); --bs-btn-border-color: transparent; --bs-btn-hover-border-color: transparent; }
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.form-control, .form-select { border-radius: 10px; border-color: var(--line); }
.form-control:focus, .form-select:focus { border-color: var(--brand-500); box-shadow: 0 0 0 .2rem rgba(107,31,92,.12); }
.form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }
.form-label { font-weight: 500; font-size: .88rem; }

/* ── Shell ───────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--brand-900); color: #E9DCE6;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  background-image: radial-gradient(120% 60% at 100% 0%, rgba(232,85,42,.16), transparent 60%);
}
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.25rem 1.25rem 1rem; color: #fff; text-decoration: none; }
.brand img { width: 40px; height: 40px; }
.brand-name { font-weight: 700; font-size: 1.25rem; line-height: 1; }
.brand-sub { font-size: .66rem; letter-spacing: .14em; color: #C9B3C3; margin-top: .3rem; direction: ltr; text-align: right; }
.nav-side { padding: .5rem .75rem; display: flex; flex-direction: column; gap: 2px; }
.nav-side .label { font-size: .7rem; color: #A88FA1; padding: 1rem .75rem .35rem; letter-spacing: .06em; }
.nav-side a {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 10px;
  color: #E9DCE6; text-decoration: none; font-weight: 500; transition: background .15s;
}
.nav-side a i { font-size: 1.1rem; opacity: .85; }
.nav-side a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-side a.active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset -3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: .65rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #F29A6B); color: #fff; font-weight: 700; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: .78rem; }
.user-chip .name { color: #fff; font-weight: 600; font-size: .9rem; line-height: 1.2; }
.user-chip .role { color: #B9A3B3; font-size: .75rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; display: flex; align-items: center; gap: 1rem; padding: 0 1.75rem;
  background: rgba(246,243,247,.85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 1020;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; margin: 0; }
.content { padding: 1.5rem 1.75rem 3rem; }

.alert-banner { margin: 1rem 1.75rem 0; border-radius: 12px; display: flex; align-items: center; gap: .75rem; }

/* Cards */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: 1rem 1.25rem; font-weight: 600; }
.card.stat { flex-direction: row; }
.stat { padding: 1.15rem 1.25rem; display: flex; gap: 1rem; align-items: center; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.stat-icon.plum { background: var(--brand-100); color: var(--brand-600); }
.stat-icon.orange { background: var(--accent-100); color: var(--accent); }
.stat-icon.teal { background: #E2F4F1; color: #127566; }
.stat-icon.blue { background: #E6EEFB; color: #2F5DB5; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .82rem; }

.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: .75rem 1rem; border-bottom-color: var(--line); vertical-align: middle; }
.table thead th { font-size: .78rem; color: var(--muted); font-weight: 600; background: var(--brand-50); }
.badge-soft { background: var(--brand-100); color: var(--brand-700); font-weight: 500; }
.badge-ok { background: #E2F4EA; color: #19734A; font-weight: 500; }
.badge-off { background: #F1EEF2; color: #7B7280; font-weight: 500; }
.badge-warn { background: var(--accent-100); color: var(--accent-600); font-weight: 500; }

/* ── Library ─────────────────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.toolbar .search { position: relative; flex: 1 1 260px; max-width: 420px; }
.toolbar .search i { position: absolute; right: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input { padding-right: 2.4rem; background: #fff; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem; font-size: .95rem; margin-bottom: 1rem; }
.crumbs a { color: var(--muted); text-decoration: none; padding: .15rem .4rem; border-radius: 6px; }
.crumbs a:hover { background: rgba(42,7,33,.06); color: var(--ink); }
.crumbs .current { font-weight: 700; padding: .15rem .4rem; }
.crumbs .sep { color: #BDB3C1; }

.section-title { font-size: .8rem; font-weight: 600; color: var(--muted); margin: .25rem 0 .75rem; display: flex; align-items: center; gap: .5rem; }

.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.folder-card {
  display: flex; align-items: center; gap: .75rem; padding: .8rem .9rem; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; cursor: pointer; user-select: none; transition: border-color .15s, box-shadow .15s; position: relative;
}
.folder-card:hover { border-color: #D6C5D1; box-shadow: var(--shadow-sm); }
.folder-card.drop-target { border-color: var(--accent); background: var(--accent-100); }
.folder-card .ficon { font-size: 1.6rem; color: #C9A23A; line-height: 1; }
.folder-card .ficon.shared { color: var(--brand-500); }
.folder-card .ficon.public { color: #127566; }
.folder-card .fname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-card .fmeta { font-size: .75rem; color: var(--muted); }
.folder-card .menu-btn { margin-inline-start: auto; opacity: 0; transition: opacity .15s; }
.folder-card:hover .menu-btn, .folder-card .menu-btn[aria-expanded=true] { opacity: 1; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: .9rem; }
.media-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; position: relative; transition: box-shadow .15s, transform .15s; }
.media-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.media-card.selected { outline: 2px solid var(--brand-600); outline-offset: -1px; }
.media-thumb { aspect-ratio: 1 / 1; background: var(--brand-50) center/cover no-repeat; position: relative; display: flex; align-items: center; justify-content: center; }
.media-thumb .ph { font-size: 2.4rem; color: #CBB7C6; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.media-badge { position: absolute; bottom: .5rem; left: .5rem; background: rgba(20,6,17,.72); color: #fff; font-size: .72rem; padding: .15rem .45rem; border-radius: 6px; direction: ltr; }
.media-badge i { margin-inline-end: .2rem; }
.media-public { position: absolute; top: .5rem; left: .5rem; background: rgba(255,255,255,.9); color: #127566; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; }
.media-check { position: absolute; top: .5rem; right: .5rem; width: 24px; height: 24px; border-radius: 7px; background: rgba(255,255,255,.92); border: 1.5px solid #CDBFCA; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .12s; color: #fff; }
.media-card:hover .media-check, .media-card.selected .media-check, .select-mode .media-check { opacity: 1; }
.media-card.selected .media-check { background: var(--brand-600); border-color: var(--brand-600); }
.media-info { padding: .55rem .7rem .65rem; }
.media-name { font-weight: 500; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: auto; }
.media-meta { font-size: .72rem; color: var(--muted); display: flex; justify-content: space-between; gap: .5rem; }

.list-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--brand-50); display: inline-flex; align-items: center; justify-content: center; color: #CBB7C6; overflow: hidden; }
.list-thumb img { width: 100%; height: 100%; object-fit: cover; }

.empty { text-align: center; padding: 3.5rem 1rem; color: var(--muted); }
.empty .em-icon { width: 76px; height: 76px; border-radius: 22px; background: var(--brand-100); color: var(--brand-600); display: inline-flex; align-items: center; justify-content: center; font-size: 2rem; margin-bottom: 1rem; }
.empty h3 { font-size: 1.05rem; color: var(--ink); font-weight: 700; }

.drop-overlay {
  position: fixed; inset: 0; background: rgba(42,7,33,.55); z-index: 2000; display: none; align-items: center; justify-content: center;
}
.drop-overlay.show { display: flex; }
.drop-overlay .box { background: #fff; border-radius: 20px; padding: 2.5rem 3rem; text-align: center; border: 2px dashed var(--accent); }
.drop-overlay .box i { font-size: 2.6rem; color: var(--accent); }

.bulkbar {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(150%); background: var(--brand-900); color: #fff;
  border-radius: 14px; padding: .5rem .5rem .5rem 1rem; display: flex; align-items: center; gap: .5rem; z-index: 1030; box-shadow: var(--shadow);
  transition: transform .2s;
}
.bulkbar.show { transform: translateX(-50%) translateY(0); }
.bulkbar .btn { --bs-btn-color: #fff; --bs-btn-hover-bg: rgba(255,255,255,.12); --bs-btn-hover-color:#fff; }

/* Details / preview */
.offcanvas.details { width: 460px; }
.preview-stage { background: #140611; border-radius: 12px; overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 220px; max-height: 340px; }
.preview-stage img, .preview-stage video { max-width: 100%; max-height: 340px; display: block; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: .35rem .75rem; font-size: .85rem; }
.kv dt { color: var(--muted); font-weight: 400; }
.kv dd { margin: 0; word-break: break-word; }

.lightbox { position: fixed; inset: 0; background: rgba(14,4,12,.97); z-index: 2050; display: none; flex-direction: column; }
.lightbox.show { display: flex; }
.lightbox .lb-top { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem; color: #fff; }
.lightbox .lb-top .t { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox .lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 0 3.5rem 1.5rem; position: relative; }
.lightbox .lb-stage img, .lightbox .lb-stage video { max-width: 100%; max-height: 100%; border-radius: 6px; }
.lightbox .btn { --bs-btn-color: #fff; --bs-btn-hover-bg: rgba(255,255,255,.12); --bs-btn-hover-color: #fff; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; border: 0; font-size: 1.3rem; }
.lb-nav:hover { background: rgba(255,255,255,.2); }
.lb-prev { right: .75rem; } .lb-next { left: .75rem; }

/* ── Upload panel ────────────────────────────────────────── */
.upload-panel {
  position: fixed; bottom: 1rem; left: 1rem; width: 380px; max-width: calc(100vw - 2rem); background: #fff; border-radius: 16px;
  box-shadow: 0 20px 50px -12px rgba(42,7,33,.35); border: 1px solid var(--line); z-index: 1040; display: none; overflow: hidden;
}
.upload-panel.show { display: block; }
.up-head { background: var(--brand-800); color: #fff; padding: .75rem 1rem; display: flex; align-items: center; gap: .5rem; }
.up-head .t { flex: 1; font-weight: 600; font-size: .92rem; }
.up-head .btn { --bs-btn-color: #fff; --bs-btn-hover-bg: rgba(255,255,255,.14); --bs-btn-hover-color: #fff; width: 30px; height: 30px; }
.up-total { height: 3px; background: rgba(255,255,255,.15); }
.up-total > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.up-list { max-height: 340px; overflow-y: auto; }
.upload-panel.collapsed .up-list { display: none; }
.up-item { padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.up-item:last-child { border-bottom: 0; }
.up-row { display: flex; align-items: center; gap: .6rem; }
.up-row .ic { width: 34px; height: 34px; border-radius: 9px; background: var(--brand-50); color: var(--brand-600); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.up-row .nm { font-size: .84rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-row .st { font-size: .74rem; color: var(--muted); }
.up-row .st.err { color: #B42318; }
.up-row .st.ok { color: #19734A; }
.up-row .acts { margin-inline-start: auto; display: flex; gap: 2px; flex-shrink: 0; }
.up-row .acts .btn { width: 28px; height: 28px; font-size: .85rem; }
.up-bar { height: 4px; border-radius: 4px; background: var(--brand-100); margin-top: .45rem; overflow: hidden; }
.up-bar > div { height: 100%; background: var(--brand-600); width: 0; transition: width .25s; }
.up-item.done .up-bar > div { background: #2E9E6A; }
.up-item.failed .up-bar > div { background: #D92D20; }

/* Toasts */
.toast-wrap { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 2100; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast-msg { background: var(--brand-900); color: #fff; padding: .65rem 1rem; border-radius: 12px; box-shadow: var(--shadow); font-size: .9rem; display: flex; gap: .55rem; align-items: center; pointer-events: auto; animation: tin .2s ease-out; max-width: 90vw; }
.toast-msg.error { background: #8E1F16; }
.toast-msg.success i { color: #6EE7A8; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-art {
  background: var(--brand-900); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
  background-image: radial-gradient(80% 60% at 0% 100%, rgba(232,85,42,.35), transparent 60%), radial-gradient(70% 50% at 100% 0%, rgba(138,42,118,.6), transparent 60%);
}
.auth-art .tiles { position: absolute; inset: auto -40px -40px auto; display: grid; grid-template-columns: repeat(4, 90px); gap: 12px; transform: rotate(-12deg); opacity: .14; }
.auth-art .tiles span { height: 90px; border-radius: 16px; background: #fff; }
.auth-art .tiles span:nth-child(3n) { background: var(--accent); }
.auth-art > div:not(.tiles) { position: relative; z-index: 1; }
.auth-art h2 { font-size: 2rem; font-weight: 700; line-height: 1.35; max-width: 420px; }
.auth-art p { color: #D9C6D3; max-width: 420px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.auth-form .inner { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 1.5rem; font-weight: 700; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-art { display: none; } }

/* Share (public) page */
.share-head { background: var(--brand-900); color: #fff; padding: 1rem 1.5rem; display: flex; align-items: center; gap: .75rem; }
.share-head img { width: 34px; height: 34px; }

/* Responsive shell */
.menu-toggle { display: none; }
@media (max-width: 991px) {
  .sidebar { position: fixed; right: 0; z-index: 1045; transform: translateX(100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .menu-toggle { display: inline-flex; }
  .content, .topbar { padding-inline: 1rem; }
  .offcanvas.details { width: 100%; }
}
