/* ============ LinkHub — tema ala dashboard oranye ============ */
:root {
  --radius: 18px;
  --radius-sm: 12px;
  --accent: #f2703c;
  --accent-strong: #e85c25;
  --accent-soft: #fdeee6;
  --green: #2ebd9c;
  --green-strong: #23a587;
  --shadow: 0 10px 30px rgba(180, 90, 50, 0.10);
  --shadow-sm: 0 4px 14px rgba(120, 70, 40, 0.08);
  --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html[data-theme='light'] {
  --bg: #f7f3f0;
  --bg-glow: rgba(242, 112, 60, 0.16);
  --surface: #ffffff;
  --surface-2: #fbf7f4;
  --surface-3: #fdeee6;
  --text: #211913;
  --text-2: #6f625a;
  --text-3: #a89c93;
  --border: rgba(60, 30, 15, 0.08);
  --input-bg: #f6f1ed;
  --bar-bg: rgba(247, 243, 240, 0.78);
}

html[data-theme='dark'] {
  --bg: #17130f;
  --bg-glow: rgba(242, 112, 60, 0.22);
  --surface: #211b16;
  --surface-2: #2a221c;
  --surface-3: #35261e;
  --text: #f6efe9;
  --text-2: #bcaea3;
  --text-3: #877a70;
  --border: rgba(255, 235, 220, 0.09);
  --input-bg: #2c241e;
  --bar-bg: rgba(23, 19, 15, 0.78);
  --accent-soft: #3a241a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1000px 420px at 85% -10%, var(--bg-glow), transparent 65%),
    radial-gradient(700px 380px at -10% 110%, var(--bg-glow), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ============ Layout ============ */
.app {
  display: flex;
  gap: 16px;
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 74px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
}

.logo-mark {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(10, 63, 158, 0.35);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 30px;
  flex: 1;
}

.side-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  transition: all 0.2s ease;
}
.side-btn:hover { background: var(--surface-3); color: var(--accent); transform: translateY(-2px); }
.side-btn.active { background: var(--accent-soft); color: var(--accent); }
.side-btn .icon-moon { display: none; }
html[data-theme='dark'] .side-btn .icon-sun { display: none; }
html[data-theme='dark'] .side-btn .icon-moon { display: block; }
html[data-theme='dark'] .side-btn.active { color: var(--accent); }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

/* Topbar — sticky: bar logo/cari/tambah selalu tetap di atas saat scroll */
.topbar {
  display: flex;
  gap: 14px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 10px 0;
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

/* Scroll ke section tidak tertutup topbar sticky */
.main, .main section { scroll-margin-top: 90px; }

.btn-add {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-add:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn-add .plus { color: var(--green); font-size: 20px; font-weight: 500; line-height: 1; }

.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0 16px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.search svg { color: var(--text-3); flex-shrink: 0; }
.search-toggle {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  color: var(--text-3);
  border-radius: 8px;
  transition: color 0.2s ease;
}
.search-toggle:hover { color: var(--accent); }
.search-toggle svg { width: 20px; height: 20px; color: inherit; }
.search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 12px 0;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
}
.search input::placeholder { color: var(--text-3); }

.icon-btn {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.icon-btn:hover { color: var(--accent); transform: translateY(-2px); }
.icon-btn.ghost { box-shadow: none; background: transparent; border: none; width: 40px; height: 40px; }
.icon-btn .icon-moon { display: none; }
html[data-theme='dark'] .icon-btn .icon-sun { display: none; }
html[data-theme='dark'] .icon-btn .icon-moon { display: block; }
.icon-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* ============ Stats ============ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-card.accent { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); border: none; }
.stat-card.accent .stat-label { color: rgba(255, 255, 255, 0.85); }
.stat-card.accent .stat-value { color: #fff; }
.stat-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-value.small { font-size: 14px; font-weight: 600; color: var(--text-2); }

/* ============ Section ============ */
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 18px; font-weight: 600; }
.section-sub { font-size: 13px; color: var(--text-3); }

/* ============ Link cards ============ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

.card-media {
  position: relative;
  height: 118px;
  background:
    radial-gradient(120px 90px at 30% 25%, rgba(242, 112, 60, 0.35), transparent 70%),
    linear-gradient(135deg, var(--surface-3), var(--surface-2));
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card-media img.thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-media .media-favicon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--surface);
  padding: 8px;
  box-shadow: var(--shadow-sm);
  object-fit: contain;
  z-index: 1;
}

.card-live { position: absolute; top: 12px; right: 12px; z-index: 2; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
}
.badge.live { background: rgba(46, 189, 156, 0.16); color: var(--green-strong); }
html[data-theme='dark'] .badge.live { color: #4fd6b8; }
.badge.live .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.4s ease infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.75); } }

.card-body { padding: 13px 15px 12px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card-domain { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-domain img { width: 18px; height: 18px; border-radius: 5px; object-fit: contain; flex-shrink: 0; }
.card-domain span {
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.card-title:hover { color: var(--accent); }
.card-desc {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mini-news { list-style: none; display: flex; flex-direction: column; gap: 7px; margin-top: 4px; border-top: 1px dashed var(--border); padding-top: 10px; }
.mini-news li a {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
}
.mini-news li a:hover { color: var(--accent); }

.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 10px; }
.card-actions .btn-open {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 9px 0;
  border-radius: 12px;
  transition: all 0.15s;
}
.card-actions .btn-open:hover { background: var(--accent); color: #fff; }
.card-actions .btn-mini {
  width: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  background: var(--input-bg);
  transition: all 0.15s;
}
.card-actions .btn-mini:hover { color: var(--accent); }
.card-actions .btn-mini svg { width: 16px; height: 16px; }
.card-actions .btn-mini.danger:hover { color: #e04545; }
/* ============ Empty state ============ */
.empty {
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  color: var(--text-2);
}
.empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty h3 { color: var(--text); font-size: 19px; margin-bottom: 8px; }
.empty p { font-size: 14px; line-height: 1.7; max-width: 520px; margin: 0 auto 20px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 28px;
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(232, 92, 37, 0.35);
  transition: all 0.2s ease;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(232, 92, 37, 0.45); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; transform: none; }
.btn-ghost {
  background: var(--input-bg);
  color: var(--text-2);
  font-weight: 600;
  font-size: 15px;
  padding: 14px 24px;
  border-radius: 16px;
  transition: all 0.15s;
}
.btn-ghost:hover { color: var(--text); }

/* ============ News wall ============ */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.news-card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}
.news-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.news-thumb {
  width: 84px;
  height: 84px;
  flex-shrink: 0;
  border-radius: 14px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
}
.news-thumb.fallback {
  display: grid;
  place-items: center;
  padding: 18px;
}
.news-thumb.fallback img { width: 100%; height: 100%; object-fit: contain; }
.news-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.news-source { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-3); }
.news-source img { width: 15px; height: 15px; border-radius: 4px; object-fit: contain; }
.news-source .live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 1.4s ease infinite; }
.news-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news-card:hover .news-title { color: var(--accent); }
.news-snippet {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* ============ Modal ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 8, 0.55);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 26px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
  animation: slideUp 0.25s ease;
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-head h3 { font-size: 19px; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.field span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field input {
  background: var(--input-bg);
  border: 1.5px solid transparent;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border 0.15s;
}
.field input:focus { border-color: var(--accent); }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.6; margin-bottom: 12px; }

.preview-box {
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 14px;
  animation: slideUp 0.25s ease;
}
.preview-media {
  height: 150px;
  background:
    radial-gradient(140px 100px at 30% 30%, rgba(242, 112, 60, 0.35), transparent 70%),
    linear-gradient(135deg, var(--surface-3), var(--surface-2));
  display: grid;
  place-items: center;
  overflow: hidden;
}
.preview-media img { width: 100%; height: 100%; object-fit: cover; }
.preview-media .media-favicon { width: 56px; height: 56px; border-radius: 14px; background: var(--surface); padding: 9px; box-shadow: var(--shadow-sm); object-fit: contain; }
.preview-body { padding: 14px 16px; }
.preview-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.preview-meta img { width: 16px; height: 16px; border-radius: 4px; object-fit: contain; }
.preview-meta span { font-size: 12px; color: var(--text-3); }
.preview-meta .badge { color: var(--accent); background: var(--accent-soft); }
.preview-body h4 { font-size: 15.5px; font-weight: 600; line-height: 1.4; margin-bottom: 4px; }
.preview-body p { font-size: 12.5px; color: var(--text-2); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.modal-error {
  background: rgba(224, 69, 69, 0.12);
  color: #e04545;
  font-size: 13px;
  padding: 11px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
}
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  padding: 13px 24px;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  z-index: 200;
  animation: slideUp 0.25s ease;
  max-width: calc(100vw - 40px);
}
.toast.error { background: #e04545; color: #fff; }

/* ============ Base: elemen mobile/PWA (tersembunyi di desktop) ============ */
.topbar-logo { display: none; }
.bottom-nav { display: none; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .app { flex-direction: column; padding: 12px; gap: 12px; }
  .sidebar { display: none; }
  .main { gap: 16px; padding-bottom: 96px; }

  /* Topbar: logo + ikon cari (animasi slow-mo) + ikon tambah + ikon */
  .topbar { gap: 10px; flex-wrap: nowrap; }
  .topbar-logo {
    display: block;
    order: 0;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
  }

  /* Kolom pencarian disembunyikan sebagai ikon; diklik -> mengembang slow-mo */
  .search {
    order: 1;
    min-width: 52px;
    max-width: 52px;
    padding: 0;
    gap: 0;
    overflow: hidden;
    border-radius: 16px;
    transition:
      max-width 0.7s cubic-bezier(0.22, 1, 0.36, 1),
      padding 0.7s cubic-bezier(0.22, 1, 0.36, 1),
      gap 0.7s ease;
  }
  .search.open { max-width: 100%; padding: 0 10px 0 4px; gap: 8px; }
  .search-toggle {
    width: 50px;
    align-self: stretch;
    flex-shrink: 0;
    border-radius: 16px;
    color: var(--text-2);
    transition:
      color 0.3s ease,
      width 0.7s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .search-toggle:hover { color: var(--accent); }
  .search.open .search-toggle {
    width: 34px;
    color: var(--accent);
    transform: rotate(90deg);
  }
  .search-toggle svg { width: 22px; height: 22px; }
  .search input {
    opacity: 0;
    padding: 14px 0;
    transition: opacity 0.6s ease 0.15s;
  }
  .search.open input { opacity: 1; }

  .btn-add {
    order: 2;
    margin-left: auto;
    width: 50px;
    height: 50px;
    padding: 0;
    gap: 0;
    border-radius: 16px;
    justify-content: center;
  }
  .btn-add .btn-add-label { display: none; }
  .btn-add .plus { font-size: 24px; }
  .icon-btn { order: 3; width: 50px; height: 50px; border-radius: 16px; }

  /* Konten lebih ringkas di layar kecil */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .card-media { height: 92px; }
  .card-body { padding: 11px 12px 10px; gap: 6px; }
  .news-grid { grid-template-columns: 1fr; gap: 10px; }
  .section-head h2 { font-size: 17px; }

  /* Bottom nav ala PWA (sidebar pindah ke bawah) */
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 8px;
    justify-content: space-around;
    align-items: center;
    z-index: 90;
  }
  .bottom-nav .side-btn { width: 62px; height: 48px; border-radius: 14px; }

  .toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}

/* ============ Aplikasi Saya (quick links) ============ */
.quick-apps {
  margin-bottom: 22px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.quick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
  font-size: 0.9rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.quick-btn:hover {
  transform: translateY(-2px);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 8px 18px rgba(232, 92, 37, 0.22);
}
