/* بىلىمزار Admin — Modern Dashboard UI */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #39e3af;
  --primary-dark: #2bc992;
  --primary-light: #e8fbf4;
  --sidebar-bg: #0f172a;
  --sidebar-hover: rgba(255,255,255,.06);
  --sidebar-active: rgba(37,99,235,.22);
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.08);
  --sidebar-width: 240px;
  --font-main: 'UKIJ Tuz Tom', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.admin-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 4px 0 24px rgba(15,23,42,.12);
  overflow: hidden;
}

.sidebar-brand {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-image {
  display: block;
  max-width: 100%;
  width: 168px;
  height: 48px;
  object-fit: contain;
  object-position: center;
}

.brand-image--text {
  width: auto;
  height: auto;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  color: #fff;
  line-height: 1.45;
  word-break: break-word;
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; overscroll-behavior: contain; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin-bottom: 4px;
  border-radius: 10px;
  color: rgba(255,255,255,.65);
  transition: all .2s;
  font-size: 14px;
}

.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #6eecc4;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: .85;
}

.nav-icon img, .nav-icon svg { width: 100%; height: 100%; object-fit: contain; filter: brightness(0) invert(1); opacity: .8; }
.nav-item.active .nav-icon img, .nav-item.active .nav-icon svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: rgba(255,255,255,.5);
  flex-shrink: 0;
}

.sidebar-footer a { color: rgba(255,255,255,.7); font-size: 13px; }
.sidebar-footer a:hover { color: #fff; }

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.topbar {
  background: var(--card);
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-heading { font-size: 20px; font-weight: 700; color: #0f172a; }
.topbar-meta { font-size: 13px; color: var(--text-muted); background: var(--bg); padding: 6px 12px; border-radius: 8px; }

.content { padding: 28px 32px; flex: 1; }

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  border-radius: 4px 0 0 4px;
}

.stat-card.orange::before { background: #f97316; }
.stat-card.green::before { background: #22c55e; }
.stat-card.purple::before { background: #a855f7; }
.stat-card.red::before { background: #ef4444; }
.stat-card.teal::before { background: #14b8a6; }

.stat-value { font-size: 26px; font-weight: 800; color: #0f172a; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* Panels */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  border: 1px solid rgba(226,232,240,.6);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title { font-size: 16px; font-weight: 700; color: #0f172a; }
.panel-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.panel-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 1024px) { .panel-grid { grid-template-columns: 1fr; } }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid #f1f5f9; }
th { background: #f8fafc; font-weight: 600; color: #475569; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-thumb { width: 72px; height: 44px; border-radius: 8px; overflow: hidden; background: #f1f5f9; border: 1px solid var(--border); }
.table-thumb img { width: 100%; height: 100%; object-fit: cover; }
.text-muted { color: var(--text-muted); }

/* Forms */
.form-panel { width: 100%; }
.form-card { width: 100%; }
.panel-body { padding-top: 4px; }
.panel-header .btn-sm { flex-shrink: 0; }
.panel-body form { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 24px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field { min-width: 0; }
.field-label, label { display: block; font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 8px; }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=url], input[type=email], select, textarea, button {
  font-family: var(--font-main);
}

input[type=text], input[type=password], input[type=number], input[type=date], input[type=url], input[type=email], select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  transition: border .2s, box-shadow .2s;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

textarea { min-height: 110px; resize: vertical; }
.config-guide {
  padding: 16px 20px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}

.config-guide p {
  margin: 0 0 8px;
}

.config-guide p:last-child {
  margin-bottom: 0;
}

.config-guide code {
  padding: 2px 6px;
  background: #fff;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text);
}

.form-actions { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }

.form-section { margin-bottom: 28px; }
.form-section-title { font-size: 14px; font-weight: 700; color: #334155; margin-bottom: 16px; padding-left: 10px; border-left: 3px solid var(--primary); }

/* Upload */
.upload-field { margin-bottom: 0; }

.upload-card {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  padding: 18px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.upload-card-preview {
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
}

.upload-card-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.upload-tabs {
  display: inline-flex;
  gap: 4px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
}

.upload-tab {
  border: none;
  background: transparent;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .2s;
  font-family: var(--font-main);
}

.upload-tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.upload-box {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 16px;
  background: #fff;
  transition: border-color .2s, background .2s;
}

.upload-box:hover, .upload-box.is-dragover { border-color: var(--primary); background: var(--primary-light); }

.upload-preview-media { max-width: 100%; max-height: 160px; object-fit: contain; display: block; }
.upload-card-preview video.upload-preview-media { width: 100%; max-height: 160px; }

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  padding: 24px 12px;
  cursor: pointer;
  text-align: center;
  font-size: 13px;
}

.upload-placeholder-icon { font-size: 36px; opacity: .45; }
.upload-box-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.upload-url-panel { margin-top: 4px; }
.upload-url-panel[hidden] { display: none !important; }

.upload-field.mode-url .upload-box { display: none; }
.upload-field.mode-url .upload-url-panel { display: block !important; }

@media (max-width: 768px) {
  .upload-card { grid-template-columns: 1fr; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  line-height: 1.2;
}

.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-gray { background: #f1f5f9; color: #475569; border: 1px solid var(--border); }
.btn-gray:hover { background: #e2e8f0; color: #334155; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }

/* Badges & alerts */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-primary { background: #d4f7ea; color: #39e3af; }

.alert { padding: 14px 18px; border-radius: 10px; margin-bottom: 20px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.search-bar { display: flex; gap: 8px; }
.search-bar input { width: 260px; }

.pagination { display: flex; gap: 6px; margin-top: 20px; }
.pagination a, .pagination span { padding: 7px 13px; border-radius: 8px; background: #fff; border: 1px solid var(--border); font-size: 13px; color: var(--text); }
.pagination a:hover { background: var(--primary-light); text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Messages & chart */
.msg-list { list-style: none; }
.msg-item { padding: 14px 0; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.msg-item:last-child { border-bottom: none; }
.msg-title { font-weight: 600; color: #0f172a; font-size: 14px; }
.msg-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.msg-type { font-size: 12px; color: var(--primary); margin-top: 4px; }

.chart-box { height: 300px; width: 100%; }
.chart-legend { display: flex; gap: 16px; margin-bottom: 12px; font-size: 12px; color: var(--text-muted); }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .4; }

/* Chapter list */
.chapter-list { display: flex; flex-direction: column; gap: 10px; }
.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid var(--border);
  gap: 12px;
}

.chapter-item-info { flex: 1; min-width: 0; }
.chapter-item-title { font-weight: 600; color: #0f172a; }
.chapter-item-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #167a62 50%, #39e3af 100%);
}

.login-card {
  background: #fff;
  padding: 44px 40px;
  border-radius: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; color: #0f172a; }
.login-sub { text-align: center; color: var(--text-muted); margin-bottom: 32px; font-size: 13px; }
.login-card label { margin-top: 14px; }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand-icon { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, #39e3af, #6eecc4); display: inline-flex; align-items: center; justify-content: center; font-size: 28px; margin-bottom: 12px; }

/* Config sections */
.config-section { margin-bottom: 32px; }
.config-section:last-child { margin-bottom: 0; }

/* Banner management */
.form-hint-block { margin: -8px 0 16px; }
.banner-form code {
  padding: 2px 6px;
  background: #f1f5f9;
  border-radius: 4px;
  font-size: 12px;
  color: #475569;
}

.banner-toolbar {
  align-items: center;
}

.banner-toolbar-meta {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: var(--text-muted);
}

.banner-stat strong {
  color: #0f172a;
  font-weight: 700;
}

.banner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.banner-card {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, .8);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.banner-card-media {
  position: relative;
  aspect-ratio: 25 / 12;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.banner-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.banner-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
}

.banner-card-media .badge {
  position: absolute;
  top: 10px;
  right: 10px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
}

.banner-card-sort {
  position: absolute;
  bottom: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .72);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.banner-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.banner-card-id {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.banner-card-link {
  font-size: 13px;
  line-height: 1.5;
  word-break: break-all;
  min-height: 40px;
}

.banner-card-time {
  font-size: 12px;
}

.banner-card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

@media (max-width: 768px) {
  :root { --sidebar-width: 72px; }
  .brand-image { width: 52px; height: 36px; }
  .brand-image--text { font-size: 11px; max-width: 56px; }
  .nav-item span:not(.nav-icon), .sidebar-footer span { display: none; }
  .sidebar-brand { justify-content: center; padding: 16px 8px; }
  .nav-item { justify-content: center; padding: 12px; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
