/* ============================================================
   Al-Banna Courses — Admin Dashboard CSS
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --primary:      #7c3aed;
  --primary-dark: #5b21b6;
  --primary-lt:   #f5f3ff;
  --secondary:    #4f46e5;
  --sidebar-bg:   #0f0a2e;
  --sidebar-text: #94a3b8;
  --sidebar-w:    260px;
  --header-h:     64px;
  --surface:      #ffffff;
  --bg:           #f8f7ff;
  --border:       #e5e7eb;
  --text:         #1e1b4b;
  --text-muted:   #6b7280;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #3b82f6;
  --radius:       12px;
  --radius-lg:    18px;
  --shadow:       0 4px 24px rgba(124,58,237,.1);
  --shadow-lg:    0 10px 50px rgba(124,58,237,.15);
  --transition:   .2s ease;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'Outfit', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Auth Screen ─────────────────────────────────────────── */
#loginScreen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f0a2e 0%, #1e1060 50%, #2d1b69 100%);
  padding: 2rem;
}
.login-card {
  background: white; border-radius: 24px; padding: 3rem 2.5rem;
  width: 100%; max-width: 420px;
  box-shadow: 0 30px 80px rgba(0,0,0,.4);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo-icon {
  width: 64px; height: 64px; border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 900; font-size: 1.3rem;
  margin: 0 auto .75rem;
}
.login-logo h2 { font-size: 1.4rem; font-weight: 900; }
.login-logo p  { font-size: .82rem; color: var(--text-muted); }
.form-group  { margin-bottom: 1.1rem; }
.form-label  { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .4rem; color: var(--text); }
.form-control {
  width: 100%; padding: .75rem 1rem; border: 2px solid var(--border);
  border-radius: var(--radius); font-family: inherit; font-size: .88rem;
  background: #fafafa; outline: none; transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(124,58,237,.1); background: white; }
.error-msg { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: var(--radius); padding: .75rem 1rem; font-size: .82rem; margin-bottom: 1rem; display: none; }
.error-msg.show { display: block; }

/* ── App Layout ──────────────────────────────────────────── */
#appScreen { display: none; min-height: 100vh; }
#appScreen.show { display: flex; flex-direction: column; }
.app-body { display: flex; min-height: calc(100vh - var(--header-h)); }

/* ── Topbar ──────────────────────────────────────────────── */
#topbar {
  height: var(--header-h); background: white; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.topbar-brand { display: flex; align-items: center; gap: .75rem; min-width: var(--sidebar-w); padding-right: 1rem; }
.topbar-icon {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 900; font-size: .75rem;
}
.topbar-brand span { font-weight: 800; font-size: .9rem; }
#sidebar-toggle { background: none; border: none; color: var(--text-muted); display: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.topbar-page-title { font-weight: 700; font-size: .95rem; color: var(--text); }
.topbar-user { font-size: .82rem; color: var(--text-muted); }
.topbar-user strong { color: var(--text); }

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); flex-shrink: 0;
  display: flex; flex-direction: column; overflow-y: auto;
  transition: width var(--transition);
}
.sidebar-nav { padding: 1rem .75rem; flex: 1; }
.sidebar-section-label {
  font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em;
  color: rgba(148,163,184,.5); padding: 1rem .75rem .5rem;
}
.sidebar-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: .2rem;
  color: var(--sidebar-text); font-size: .85rem; font-weight: 500;
  cursor: pointer; transition: all var(--transition); user-select: none;
}
.sidebar-item:hover { background: rgba(255,255,255,.07); color: white; }
.sidebar-item.active { background: rgba(124,58,237,.25); color: #a78bfa; font-weight: 700; }
.sidebar-item svg { flex-shrink: 0; }
.sidebar-badge { margin-left: auto; background: var(--primary); color: white; font-size: .62rem; font-weight: 700; padding: .1rem .45rem; border-radius: 50px; }
.sidebar-footer { padding: 1rem .75rem 1.5rem; border-top: 1px solid rgba(255,255,255,.07); margin-top: auto; }
.sidebar-logout {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1rem; border-radius: var(--radius);
  color: #f87171; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  background: none; border: none; width: 100%; text-align: left;
}
.sidebar-logout:hover { background: rgba(239,68,68,.1); }

/* ── Subtab Navigation (Modern Segmented Control) ────────── */
.subtab-nav {
  display: inline-flex; align-items: center; gap: 4px; background: #f1f5f9;
  padding: 4px; border-radius: 12px; border: 1px solid #e2e8f0;
  margin-bottom: 1.5rem; flex-wrap: wrap; box-shadow: inset 0 1px 2px rgba(0,0,0,.03);
}
.subtab-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 18px; border-radius: 8px;
  border: none !important; outline: none !important;
  background: transparent; color: #64748b;
  font-family: inherit; font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: all .2s ease; user-select: none;
  -webkit-appearance: none; appearance: none;
}
.subtab-btn:hover { color: #0f172a; background: rgba(255,255,255,.6); }
.subtab-btn.active {
  background: #ffffff !important; color: var(--primary) !important;
  font-weight: 800 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04) !important;
}
.subtab-btn.active svg { stroke: var(--primary) !important; }

/* ── Main Content ────────────────────────────────────────── */
#mainContent { flex: 1; overflow-x: hidden; }
.page { display: none; padding: 1.5rem 2rem; }
.page.active { display: block; }

/* ── Page Header ─────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 800; }
.page-header p  { font-size: .82rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  background: white; border-radius: var(--radius-lg); padding: 1.5rem;
  border: 1px solid var(--border); display: flex; align-items: flex-start; gap: 1rem;
  transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); border-color: #c4b5fd; }
.stat-card-icon { width: 44px; height: 44px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card-value { font-size: 1.8rem; font-weight: 900; }
.stat-card-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-top: .2rem; }
.stat-card-sub   { font-size: .75rem; color: var(--text-muted); margin-top: .3rem; }
.icon-violet { background: #f5f3ff; color: var(--primary); }
.icon-amber  { background: #fffbeb; color: #d97706; }
.icon-green  { background: #ecfdf5; color: #059669; }
.icon-blue   { background: #eff6ff; color: #2563eb; }
.icon-red    { background: #fef2f2; color: #dc2626; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrapper { background: white; border-radius: var(--radius-lg); border: 1px solid var(--border); overflow-x: auto; box-shadow: 0 4px 20px rgba(0,0,0,.03); }
.table-toolbar { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.table-toolbar .search-box { display: flex; align-items: center; gap: .5rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; flex: 1; min-width: 180px; }
.table-toolbar input[type="text"], .table-toolbar input[type="search"] { border: none; background: transparent; font-family: inherit; font-size: .82rem; outline: none; width: 100%; }
.table-toolbar select { border: 1px solid var(--border); background: white; border-radius: var(--radius); padding: .5rem .75rem; font-family: inherit; font-size: .82rem; outline: none; }
table { width: 100%; min-width: 880px; border-collapse: collapse; }
th { padding: .85rem 1.1rem; text-align: left; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); background: #fafafa; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 1rem 1.1rem; font-size: .83rem; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--primary-lt); }
.td-name   { font-weight: 700; min-width: 250px; }
.td-muted  { color: var(--text-muted); font-size: .78rem; }
.td-link   { color: var(--primary); }
.td-link:hover { text-decoration: underline; }

/* ── Badges / Status ─────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .7rem; border-radius: 50px; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; }
.badge-pending   { background: #fffbeb; color: #92400e; }
.badge-confirmed { background: #ede9fe; color: #5b21b6; }
.badge-completed { background: #ecfdf5; color: #065f46; }
.badge-cancelled { background: #fef2f2; color: #991b1b; }
.badge-published { background: #ecfdf5; color: #065f46; }
.badge-draft     { background: #f3f4f6; color: #6b7280; }
.badge-website   { background: #ede9fe; color: var(--primary); }
.badge-ai        { background: #eff6ff; color: #1d4ed8; }
.badge-admin     { background: #f3f4f6; color: #374151; }
.badge-upcoming  { background: #ede9fe; color: #5b21b6; }
.badge-ongoing   { background: #ecfdf5; color: #065f46; }
.badge-done      { background: #f3f4f6; color: #6b7280; }

/* ── Action Buttons (Table) ──────────────────────────────── */
.action-btn { padding: .35rem .75rem; border-radius: 8px; border: none; font-family: inherit; font-size: .75rem; font-weight: 700; cursor: pointer; transition: all var(--transition); display: inline-flex; align-items: center; justify-content: center; gap: .3rem; white-space: nowrap; text-decoration: none; }
.action-btn-view     { background: #f5f3ff; color: var(--primary); }
.action-btn-edit     { background: #fffbeb; color: #92400e; }
.action-btn-delete   { background: #fef2f2; color: #991b1b; }
.action-btn-download { background: #eff6ff; color: #1d4ed8; }
.action-btn:hover    { opacity: .85; transform: translateY(-1px); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .65rem 1.25rem; border-radius: var(--radius); font-family: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; border: none; transition: all var(--transition); white-space: nowrap; text-decoration: none; }
.btn-primary  { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; box-shadow: 0 4px 14px rgba(124,58,237,.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,58,237,.4); }
.btn-secondary{ background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success  { background: #059669; color: white; }
.btn-danger   { background: #dc2626; color: white; }
.btn-warning  { background: #d97706; color: white; }
.btn-sm       { padding: .4rem .9rem; font-size: .75rem; }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.3); animation: modalIn .25s ease;
}
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 980px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-header { padding: 1.5rem 1.75rem 0; display: flex; align-items: flex-start; justify-content: space-between; }
.modal-header h3 { font-size: 1.1rem; font-weight: 800; }
.modal-header p  { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; }
.modal-close { background: none; border: none; font-size: 1.4rem; color: var(--text-muted); cursor: pointer; padding: .25rem; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 1.5rem 1.75rem; }
.modal-footer { padding: 1rem 1.75rem 1.5rem; display: flex; gap: .75rem; justify-content: flex-end; border-top: 1px solid var(--border); }

/* ── Gallery Manager ─────────────────────────────────────── */
.gallery-upload-zone {
  border: 2px dashed #c4b5fd; border-radius: var(--radius-lg); padding: 2.5rem;
  text-align: center; cursor: pointer; transition: all var(--transition);
  background: var(--primary-lt);
}
.gallery-upload-zone:hover, .gallery-upload-zone.drag-over { border-color: var(--primary); background: #ede9fe; }
.gallery-upload-zone svg { color: var(--primary); opacity: .5; margin-bottom: .75rem; }
.gallery-upload-zone p { font-size: .85rem; color: var(--text-muted); }
.gallery-upload-zone strong { color: var(--primary); }
.gallery-grid-admin {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-top: 1.5rem;
}
.gallery-card-admin {
  background: white; border-radius: var(--radius); border: 1px solid var(--border);
  overflow: hidden; transition: all var(--transition);
}
.gallery-card-admin:hover { box-shadow: var(--shadow); border-color: #c4b5fd; }
.gallery-card-admin .gca-img { aspect-ratio: 4/3; overflow: hidden; position: relative; }
.gallery-card-admin img { width: 100%; height: 100%; object-fit: cover; }
.gallery-card-admin .gca-status {
  position: absolute; top: .4rem; left: .4rem; background: rgba(0,0,0,.5); color: white;
  font-size: .6rem; font-weight: 700; padding: .15rem .45rem; border-radius: 50px;
}
.gallery-card-admin .gca-body { padding: .75rem; }
.gallery-card-admin .gca-title { font-size: .8rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: .4rem; }
.gallery-card-admin .gca-actions { display: flex; gap: .4rem; }

/* ── Rich Text Editor ────────────────────────────────────── */
.editor-toolbar { display: flex; gap: .3rem; flex-wrap: wrap; padding: .6rem; background: var(--bg); border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; }
.editor-btn { background: white; border: 1px solid var(--border); border-radius: 6px; width: 28px; height: 28px; font-family: inherit; font-size: .8rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.editor-btn:hover { background: var(--primary-lt); border-color: var(--primary); color: var(--primary); }
.editor-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.editor-content {
  min-height: 200px; padding: 1rem; border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius); outline: none;
  font-family: inherit; font-size: .88rem; line-height: 1.7;
}
.editor-content:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,58,237,.1); }
.editor-content h2,h3,h4 { margin: 1rem 0 .5rem; }
.editor-content p { margin-bottom: .75rem; }
.editor-content ul, .editor-content ol { padding-left: 1.5rem; margin-bottom: .75rem; }
.editor-content blockquote { border-left: 4px solid var(--primary); padding: .5rem 1rem; margin: 1rem 0; background: var(--primary-lt); border-radius: 0 var(--radius) var(--radius) 0; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.pagination-info { font-size: .78rem; color: var(--text-muted); }
.pagination-btns { display: flex; gap: .4rem; }
.page-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: white; font-family: inherit; font-size: .8rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.current { background: var(--primary); border-color: var(--primary); color: white; font-weight: 700; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Toast ───────────────────────────────────────────────── */
#toast { position: fixed; bottom: 2rem; right: 2rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; pointer-events: none; }
.toast-item { background: #1e1b4b; color: white; padding: .85rem 1.25rem; border-radius: var(--radius); font-size: .83rem; font-weight: 600; display: flex; align-items: center; gap: .6rem; animation: toastIn .3s ease; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.toast-item.success { background: #065f46; }
.toast-item.error   { background: #991b1b; }
.toast-item.warning { background: #92400e; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3.5rem 2rem; }
.empty-state svg { color: #d1d5db; margin-bottom: 1rem; }
.empty-state h4   { font-size: 1rem; font-weight: 700; margin-bottom: .4rem; }
.empty-state p    { font-size: .82rem; color: var(--text-muted); }

/* ── Upload Preview ──────────────────────────────────────── */
.upload-preview { position: relative; display: inline-block; margin-top: .75rem; }
.upload-preview img { max-height: 160px; border-radius: var(--radius); border: 2px solid var(--border); }
.upload-preview-rm { position: absolute; top: -.4rem; right: -.4rem; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: white; border: none; cursor: pointer; font-size: .9rem; display: flex; align-items: center; justify-content: center; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  #sidebar { position: fixed; left: -260px; top: 0; bottom: 0; width: 260px; z-index: 100; transition: left var(--transition); }
  #sidebar.open { left: 0; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }
  .sidebar-overlay.show { display: block; }
  #sidebar-toggle { display: block; }
  .page { padding: 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .table-toolbar { flex-direction: column; align-items: stretch; }
}
