/* =========================
   OFFLINE PAGE STYLE
========================= */

/* Background eksotik gradient (biru/teal)
   Jangan kasih padding di body — biar nav / prefooter / footer lebar penuh seperti semula.
   Jarak aman hanya di isi utama: main.container */
body.offline-page {
  background: linear-gradient(135deg, #0c4a6e 0%, #0e7490 25%, #14b8a6 50%, #0d9488 75%, #115e59 100%);
  background-attachment: fixed;
}

/* Kolom utama sama seperti bookmark: lebar max 720px, di tengah layar */
body.offline-page main.container {
  max-width: 720px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-inline-start: max(16px, env(safe-area-inset-left, 0px));
  padding-inline-end: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: max(28px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  /* id/en: rata kiri; ar (dir=rtl): rata kanan — ikuti document.dir dari offline.js */
  text-align: start;
}

body.offline-page::before {
  display: none;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 999;
}

body.offline-page .navbar .logo{
  background: linear-gradient(135deg, #38bdf8, #2563eb, #14b8a6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow: 0 10px 26px rgba(2,6,23,0.16);
}

body.dark.offline-page .navbar .logo{
  background: linear-gradient(135deg, #7dd3fc, #60a5fa, #34d399);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow:
    0 0 18px rgba(56,189,248,0.18),
    0 10px 30px rgba(0,0,0,0.55);
}

/* kasih jarak konten dari navbar */
.page,
.page-container {
  padding-top: 40px;
}

.container {
  max-width: 720px;
  margin: 30px auto 0;
  padding: 0;
}

body.offline-page main.container > h2,
.container h2 {
  font-family: "Playfair Display", serif;
  font-size: 28px;
  margin-top: 0;
  margin-bottom: 32px;
  color: #0f172a;
  text-align: start;
}

/* Dark: judul utama — biru gradien terang, mudah dibaca di atas gradient halaman */
body.dark.offline-page main.container > h2 {
  background: linear-gradient(
    135deg,
    #f0f9ff 0%,
    #bae6fd 25%,
    #7dd3fc 55%,
    #38bdf8 85%,
    #60a5fa 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 2px 14px rgba(56, 189, 248, 0.4));
}

/* Grid daftar — banyak artikel muat tanpa memanjang berlebihan */
#offline-list.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  align-items: stretch;
  margin-top: 16px;
}

@media (min-width: 900px) {
  #offline-list.cards {
    grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
    gap: 16px;
  }
}

@media (max-width: 480px) {
  #offline-list.cards {
    grid-template-columns: 1fr;
  }
}

/* Kartu artikel offline — kompak + glass ringan */
.offline-card {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow:
    0 4px 18px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.offline-card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 12px 28px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  border-color: rgba(14, 165, 233, 0.35);
}

.offline-card__media {
  position: relative;
  flex-shrink: 0;
  aspect-ratio: 16 / 9;
  max-height: 96px;
  background: rgba(15, 23, 42, 0.06);
}

.offline-card__media .offline-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
  border-radius: 0;
  display: block;
}

.offline-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 6px;
  min-height: 0;
  padding: 11px 13px 13px;
}

.offline-card__title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
  color: #0f172a;
  text-align: start;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.offline-card__cat {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  margin: 0;
  text-align: start;
}

.offline-card--no-thumb .offline-card__body {
  padding-top: 13px;
}

.offline-card .offline-actions {
  margin-top: auto;
  padding-top: 4px;
  gap: 8px;
}

.offline-card .offline-progress-bar {
  height: 4px;
  margin: 0;
}

.offline-card .offline-progress-text {
  font-size: 11px;
  margin: 0;
  line-height: 1.3;
  text-align: start;
}

.offline-card .offline-actions a,
.offline-card .offline-actions button {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 9px;
  font-size: 12px;
  text-align: center;
  justify-content: center;
}

#offline-list.cards > .offline-empty {
  grid-column: 1 / -1;
  margin: 2rem 0 3rem;
}

/* Tombol aksi */
.offline-actions {
  display: flex;
  gap: 10px;
}

.offline-actions a,
.offline-actions button {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: 0.2s ease;
}

/* tombol baca */
.offline-actions a {
  background: #1e3a8a;
  color: white;
}

.offline-actions a:hover {
  background: #1e40af;
}

/* tombol hapus */
.offline-actions button {
  background: #f1f5f9;
  color: #0f172a;
}

.offline-actions button:hover {
  background: #e2e8f0;
}

/* kondisi kosong */
.offline-empty {
  text-align: start;
  margin-top: 48px;
  color: #64748b;
  font-size: 15px;
}

body.dark .offline-empty{
  color: rgba(148,163,184,0.95);
}

/* =========================
   BACK BUTTON (OFFLINE PAGE)
   ========================= */
.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 20px;
  text-decoration: none;
  transition: all 0.25s ease;
  backdrop-filter: blur(6px);
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateX(-2px);
}

.back-btn:active {
  transform: scale(0.92);
}

/* SEARCH OFFLINE */
.offline-search {
  width: 100%;
  max-width: 420px;
  padding: 12px 16px;
  margin: 0 0 24px;
  border-radius: 12px;
  border: 1px solid #dcdcdc;
  font-size: 15px;
  outline: none;
  transition: all 0.2s ease;
  text-align: start;
}

.offline-search:focus {
  border-color: #1e3a8a;
  box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.15);
}

body.dark .offline-search{
  background: rgba(2,6,23,0.45);
  border-color: rgba(148,163,184,0.20);
  color: rgba(226,232,240,0.95);
}

body.dark .offline-search::placeholder{
  color: rgba(148,163,184,0.85);
}

.offline-progress {
  font-size: 13px;
  color: #2563eb;
  font-weight: 600;
  margin: 4px 0 10px;
}

.offline-progress-bar {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 4px;
}

.offline-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #22c55e);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.offline-progress-text {
  font-size: 12px;
  color: #64748b;
}

body.dark .offline-progress-bar {
  background: #1e293b;
}

body.dark .offline-progress-text {
  color: #94a3b8;
}

/* ===== TOOLBAR ===== */
.offline-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  margin: 20px 0;
}

/* id/en: filter + sort + stat + tombol satu alur dari kiri (bukan sort ke kanan layar) */
html[dir="ltr"] body.offline-page .offline-tools {
  justify-content: flex-start;
  align-items: flex-start;
}

.offline-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: #e5e7eb;
  cursor: pointer;
  font-size: 0.9rem;
  transition: 0.2s;
}

body.dark .filter-btn{
  background: rgba(255,255,255,0.08);
  color: rgba(226,232,240,0.92);
  border: 1px solid rgba(148,163,184,0.18);
}

.filter-btn.active {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: white;
}

body.dark #sort-select{
  background: rgba(2,6,23,0.45);
  border: 1px solid rgba(148,163,184,0.20);
  color: rgba(226,232,240,0.95);
}

/* tombol hapus */
.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.btn-danger:hover {
  opacity: 0.9;
}

/* progress bar */
.offline-progress-bar {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0;
}

.offline-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  border-radius: 999px;
}

/* ===============================
   OFFLINE ACTIONS TOP (HEADER)
================================ */
.offline-actions-top {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
}

/* dropdown sort — rata kiri id/en; ikut arah di ar */
#sort-select {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  text-align: start;
}

/* Download + Hapus: satu baris, tidak pecah saat toolbar wrap */
.offline-actions-buttons {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  align-self: flex-start;
}

/* tombol download semua */
#download-all {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
  transition: 0.25s;
}

#download-all:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.35);
}

/* tombol hapus semua */
#delete-all {
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(239, 68, 68, 0.25);
}

/* mobile: stack ke bawah */
@media (max-width: 768px) {
  .offline-tools {
    flex-direction: column;
    align-items: stretch;
  }

  body.offline-page .offline-actions-top {
    justify-content: flex-start;
  }
}

/* =====================
   OFFLINE STATS
===================== */
.offline-stats {
  display: flex;
  gap: 16px;
  margin: 20px 0 30px;
  flex-wrap: wrap;
}

/* Stat di dalam toolbar: jangan margin vertikal besar — biar sejajar dengan #sort-select */
body.offline-page .offline-actions-top .offline-stats {
  margin: 0;
  align-items: stretch;
}

.offline-stat-card {
  flex: 1;
  min-width: 140px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
  padding: 18px;
  border-radius: 14px;
  text-align: start;
  box-shadow: 0 8px 22px rgba(0,0,0,0.12);
}

.offline-stat-card span {
  display: block;
  font-size: 26px;
  font-weight: 700;
}

.offline-stat-card small {
  opacity: 0.9;
}

/* AUTO RTL SAAT GOOGLE SET ARAB */
html[lang="ar"] body {
  direction: rtl;
  text-align: right;
}

html[lang="ar"] .hero,
html[lang="ar"] .navbar,
html[lang="ar"] .quick-menu,
html[lang="ar"] .article-content {
  text-align: right;
}

/* ========== Halaman offline — RTL: toolbar dua baris; filter pakai .offline-filters yang sama (flex) = lebar tombol seperti ID/EN ========== */
html[dir="rtl"] body.offline-page .offline-tools,
body.rtl-ui.offline-page .offline-tools {
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

html[dir="rtl"] body.offline-page .offline-actions-top,
body.rtl-ui.offline-page .offline-actions-top {
  justify-content: flex-start;
  width: 100%;
  flex-wrap: wrap;
  gap: 10px;
}

html[dir="rtl"] body.offline-page .offline-actions-top .offline-stats,
body.rtl-ui.offline-page .offline-actions-top .offline-stats {
  margin: 0;
}

.offline-actions a.btn-premium,
.offline-actions .read-article-link {
  position: relative;
  z-index: 2;
  pointer-events: auto;
  cursor: pointer;
}

/* =========================
   OFFLINE ARTICLE DARK MODE
========================= */

/* Dark: efek biru hanya pada grid artikel */
body.dark.offline-page #offline-list.cards .offline-card {
  background: rgba(15, 23, 42, 0.78);
  border-color: rgba(56, 189, 248, 0.38);
  box-shadow:
    0 6px 22px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(56, 189, 248, 0.28),
    0 0 28px rgba(37, 99, 235, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

body.dark.offline-page #offline-list.cards .offline-card:hover {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(56, 189, 248, 0.45),
    0 0 40px rgba(59, 130, 246, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

body.dark .offline-card__title {
  color: #f1f5f9;
}

body.dark .offline-card__cat {
  color: #94a3b8;
}

body.dark .offline-card__media {
  background: rgba(0, 0, 0, 0.28);
}

/* progress bar */

body.dark .offline-progress-bar{

background:rgba(255,255,255,0.08);

border-radius:8px;

overflow:hidden;

}

body.dark .offline-progress-fill{

background:linear-gradient(90deg,#38bdf8,#22c55e);

height:6px;

}

/* text progress */

body.dark .offline-progress-text{

color:#cbd5f5;

font-size:13px;

}

/* tombol baca */

body.dark .btn-premium{

background:linear-gradient(90deg,#38bdf8,#22c55e);

color:white;

border-radius:10px;

padding:8px 14px;

font-size:13px;

}

/* tombol hapus */

body.dark .delete-btn{

background:#ef4444;

color:white;

border:none;

border-radius:10px;

padding:8px 14px;

font-size:13px;

}