/* ==================================================================
   Rames — Tema di atas Bootstrap 5.3
   Brand: teal/cyan, glassmorphism ringan, data monospace.
   ================================================================== */
:root {
  --bs-body-font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bs-body-font-size: 0.925rem;
  --bs-body-line-height: 1.55;
  --bs-body-color: #12343c;
  --bs-body-bg: #f3f7f8;
  --bs-link-color: #0f766e;
  --bs-link-hover-color: #0d9488;
  
  --accent: #0d9488;
  --accent2: #0f766e;
  --grad: linear-gradient(135deg, #2dd4bf 0%, #14b8a6 55%, #0d9488 100%);
  --border: rgba(13, 90, 80, .12);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

body {
  background:
    radial-gradient(900px 520px at 85% -10%, rgba(45, 212, 191, .14), transparent 60%),
    radial-gradient(760px 460px at -8% 18%, rgba(16, 185, 129, .08), transparent 55%),
    var(--bs-body-bg);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
  linear-gradient(rgba(13, 90, 80, .05) 1px, transparent 1px),
  linear-gradient(90deg, rgba(13, 90, 80, .05) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 78%);
  mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 78%);
}
a {
  color: #4CAF50;
}
.nav-pills {
  --bs-nav-pills-link-active-bg: #23c8b5;
}

/* ---------- Typography helpers ---------- */
.mono { font-family: var(--mono); }
code { font-family: var(--mono); font-size: .9em; color: #0f766e; background: rgba(13, 148, 136, .10); padding: 1px 6px; border-radius: 6px; }

/* ---------- Buttons: brand primary (solid, tanpa gradasi/glow) ---------- */
.btn-primary {
  --bs-btn-bg: #0f766e;                 /* teal-700: kontras putih ≈ 5.5:1 (AA) */
  --bs-btn-border-color: #0f766e;
  --bs-btn-hover-bg: #115e59;           /* teal-800 */
  --bs-btn-hover-border-color: #115e59;
  --bs-btn-active-bg: #134e4a;          /* teal-900 */
  --bs-btn-active-border-color: #134e4a;
  --bs-btn-disabled-bg: #0f766e;
  --bs-btn-disabled-border-color: #0f766e;
  --bs-btn-focus-shadow-rgb: 15, 118, 110;
  background-image: none;
}

/* ---------- Topbar / Navbar ---------- */
.topbar {
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar .navbar { padding-top: .4rem; padding-bottom: .4rem; }
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 17px; letter-spacing: .02em; text-decoration: none;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand:hover, .brand:focus { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.mark {
  width: 20px; height: 20px; border-radius: 7px; flex: none;
  background: var(--grad);
  box-shadow: 0 0 18px rgba(20, 184, 166, .45);
  position: relative;
}
.mark::after { content: ""; position: absolute; inset: 6px; border-radius: 3px; background: rgba(255, 255, 255, .9); }
.mark-sm { width: 12px; height: 12px; border-radius: 4px; background: var(--grad); display: inline-block; }

/* Gaya link nav lama (`.navbar-nav .nav-link`) dihapus: menu kini di `.sidebar-nav` (lihat blok Layout sidebar). */
.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad); color: #ffffff; font-weight: 800; font-size: 12px;
  box-shadow: 0 0 12px rgba(20, 184, 166, .45); flex: none;
}
.avatar.sm { width: 22px; height: 22px; font-size: 11px; margin-right: 8px; box-shadow: none; }

/* ---------- Page head ---------- */
.page-head h1 { font-weight: 800; letter-spacing: -.01em; }

/* ---------- Breadcrumb (elegan & tenang, tanpa gradasi/glow) ---------- */
.breadcrumb {
  --bs-breadcrumb-divider: "\203A"; /* › */
  --bs-breadcrumb-item-padding-x: .5rem;
  --bs-breadcrumb-margin-bottom: 0;
  font-size: 12.5px;
  letter-spacing: .01em;
  color: var(--bs-secondary-color, #5b7a84);
}
.breadcrumb .breadcrumb-item {
  display: inline-flex;
  align-items: center;
}
.breadcrumb .breadcrumb-item + .breadcrumb-item::before {
  color: rgba(13, 90, 80, .32);
  font-weight: 600;
}
.breadcrumb .breadcrumb-item a {
  color: var(--bs-secondary-color, #5b7a84);
  text-decoration: none;
  transition: color .15s ease;
}
.breadcrumb .breadcrumb-item a:hover,
.breadcrumb .breadcrumb-item a:focus-visible {
  color: var(--accent2);
  text-decoration: none;
}
.breadcrumb .breadcrumb-item.active {
  color: var(--bs-body-color);
  font-weight: 600;
}

/* ---------- Tables ---------- */
.table { --bs-table-hover-bg: rgba(13, 148, 136, .05); }
.table thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--bs-secondary-color, #5b7a84);
  background: rgba(13, 148, 136, .06);
  font-weight: 700; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table > :not(caption) > * > * { padding: .75rem 1rem; }

/* ---------- Badges (status) ---------- */
.badge {
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em;
  text-transform: capitalize; padding: .45em .8em;
}
.badge-running { color: #047857; background: rgba(5, 150, 105, .12); }
.badge-deploying { color: #0369a1; background: rgba(2, 132, 199, .12); }
.badge-stopped, .badge-unknown { color: #5b7a84; background: rgba(13, 90, 80, .08); }
.badge-error { color: #be123c; background: rgba(225, 29, 72, .10); }

/* ---------- App info (detail) ---------- */
.app-info { display: flex; flex-wrap: wrap; margin: 0; }
.app-info-item { flex: 1 1 100%; padding: 12px 2px; }
.app-info-item + .app-info-item { border-top: 1px solid var(--border); }
@media (min-width: 768px) {
  .app-info-item { flex: 1 1 50%; }
  .app-info-item:nth-child(-n+2) { border-top: 0; }
  .app-info-item:nth-child(even) { padding-left: 20px; border-left: 1px solid var(--border); }
}
.app-info .k {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--bs-secondary-color, #5b7a84); margin-bottom: 3px; font-weight: 600;
}
.app-info .v { font-weight: 600; word-break: break-word; font-size: 13.5px; }

/* ---------- Tabs (scroll horizontal di layar sempit) ---------- */
.nav-pills.tab-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--bs-secondary-color, #94a3b8) transparent;
}
.nav-pills.tab-scroll .nav-item { flex: 0 0 auto; }
.nav-pills.tab-scroll .nav-link { white-space: nowrap; color: #139081; }
.nav-pills.tab-scroll .nav-link.active { background: #23c8b5; color: white; box-shadow: 0 0 12px rgba(20, 184, 166, .45); }
.nav-pills.tab-scroll::-webkit-scrollbar { height: 5px; }
.nav-pills.tab-scroll::-webkit-scrollbar-thumb {
  background: var(--bs-secondary-color, #94a3b8);
  border-radius: 3px;
}

/* ---------- Forms ---------- */
.form-label { font-weight: 600; color: #2f5d67; }
.form-control:focus { border-color: #14b8a6; box-shadow: 0 0 0 3px rgba(20, 184, 166, .20); }
.port-input { max-width: 160px; font-family: var(--mono); }
.form-card { max-width: 640px; }

/* ---------- Template gallery (thumbnail) ---------- */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 158px), 1fr));
  gap: 14px;
}
.template-tile {
  display: flex; width: 100%; min-width: 0; flex-direction: column; align-items: center; gap: 9px;
  padding: 12px; border: 1px solid var(--border); border-radius: 14px;
  background: rgba(255, 255, 255, .86); color: var(--bs-body-color); text-align: center;
  cursor: pointer; -webkit-appearance: none; appearance: none;
  box-shadow: 0 1px 2px rgba(13, 90, 80, .05);
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease, transform .16s ease;
}
.template-tile:hover {
  border-color: rgba(13, 148, 136, .45); background: #fff;
  box-shadow: 0 14px 30px -18px rgba(13, 90, 80, .5);
  transform: translateY(-2px);
}
.template-tile:focus-visible { outline: 3px solid rgba(20, 184, 166, .35); outline-offset: 2px; }
/* Kotak logo berukuran tetap; logo mengisi kotak (contain) supaya logo ber-viewBox
   lebar (mis. MySQL/MariaDB) tidak tampil mengecil di samping logo persegi.
   Latar dibuat netral (bukan tint) agar logo pucat/ber-halo tetap terbaca bersih. */
.template-tile-media {
  display: flex; width: 100%; height: 92px; align-items: center; justify-content: center;
  padding: 10px; border: 1px solid rgba(13, 90, 80, .10); border-radius: 10px;
  background: #f8fafb;
}
.template-tile-logo { display: block; width: 100%; height: 100%; object-fit: contain; }
.template-tile-fallback { font-size: 2rem; line-height: 1; }
/* Logo template di luar galeri (tab Template halaman Config & judul form deploy):
   ukuran tetap kecil supaya sejajar teks dan tidak mengubah tinggi baris. */
.template-logo-card { display: block; width: 40px; height: 40px; object-fit: contain; flex: 0 0 auto; }
.template-logo-inline { display: inline-block; width: 32px; height: 32px; object-fit: contain; vertical-align: -8px; }
.template-tile-name {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  min-width: 0; font-size: .88rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere;
}
.template-tile-category {
  display: inline-block; max-width: 100%; margin-top: auto; padding: 3px 10px;
  border-radius: 9px; background: rgba(13, 148, 136, .10); color: #0f766e;
  font-size: .72rem; font-weight: 600; line-height: 1.35; text-align: center; overflow-wrap: anywhere;
}

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; }
.empty-icon {
  width: 56px; height: 56px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center;
  font-size: 26px; border-radius: 16px; color: #0f766e;
  background: rgba(45, 212, 191, .12); border: 1px solid rgba(13, 148, 136, .30);
  box-shadow: 0 0 26px -6px rgba(13, 148, 136, .35);
}

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); color: var(--bs-secondary-color, #5b7a84); }
.footer a { color: inherit; }

/* ---------- Auth ---------- */
.auth-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  padding: 20px; position: relative; overflow: hidden;
}
.auth-glow {
  position: fixed; width: 560px; height: 560px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(20, 184, 166, .25), rgba(45, 212, 191, .10) 45%, transparent 70%);
  filter: blur(20px); animation: float 9s ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: translate(-30%, -20%); } 50% { transform: translate(-10%, -30%); } }
.auth-card {
  position: relative; width: 100%; max-width: 400px;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--border); border-radius: 18px;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px -30px rgba(13, 90, 80, .4), 0 0 0 1px rgba(13, 148, 136, .08);
  overflow: hidden;
}
.auth-brand {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; font-size: 24px; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-card .sub { text-align: center; color: var(--bs-secondary-color, #5b7a84); margin: 8px 0 18px; font-size: 13px; }

/* ---------- Panduan template/app (HTML hasil Markdown::toHtml) ---------- */
.guide-content {
  font-size: 0.925rem;
  line-height: 1.65;
  color: var(--bs-body-color);
  overflow-wrap: anywhere;
}
.guide-content > :first-child { margin-top: 0; }
.guide-content > :last-child { margin-bottom: 0; }
.guide-content h1,
.guide-content h2,
.guide-content h3,
.guide-content h4 {
  font-weight: 700;
  line-height: 1.3;
  margin: 1.4em 0 0.6em;
  color: #0f3f46;
}
.guide-content h1 { font-size: 1.35rem; }
.guide-content h2 {
  font-size: 1.15rem;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}
.guide-content h3 { font-size: 1.02rem; }
.guide-content h4 { font-size: 0.95rem; }
.guide-content p { margin: 0 0 0.8em; }
.guide-content ul,
.guide-content ol { margin: 0 0 0.9em; padding-left: 1.4em; }
.guide-content li { margin: 0.2em 0; }
.guide-content li > ul,
.guide-content li > ol { margin: 0.2em 0; }
.guide-content a {
  color: var(--bs-link-color);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.guide-content a:hover { color: var(--bs-link-hover-color); }
.guide-content code {
  font-family: var(--mono);
  font-size: 0.86em;
  color: #0f766e;
  background: rgba(13, 148, 136, 0.10);
  padding: 1px 6px;
  border-radius: 6px;
  overflow-wrap: anywhere;
}
.guide-content pre {
  background: #0d1117;
  color: #e6e6e6;
  border: 1px solid rgba(13, 90, 80, 0.18);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 1em;
  overflow-x: auto;
  overflow-wrap: anywhere;
}
.guide-content pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: 0.85em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.guide-content blockquote {
  margin: 0 0 1em;
  padding: 0.5em 1em;
  border-left: 4px solid var(--accent);
  background: rgba(13, 148, 136, 0.07);
  border-radius: 0 8px 8px 0;
  color: #3f6470;
}
.guide-content blockquote > :last-child { margin-bottom: 0; }
.guide-content table {
  width: 100%;
  margin: 0 0 1em;
  border-collapse: collapse;
  font-size: 0.9em;
}
.guide-content table th,
.guide-content table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.guide-content table th {
  background: rgba(13, 148, 136, 0.08);
  font-weight: 600;
}
.guide-content img { max-width: 100%; height: auto; }
.guide-content hr { border-top: 1px solid var(--border); margin: 1.4em 0; }

/* ==================================================================
   Layout sidebar — shell aside + kolom utama (menggantikan topbar-navbar).
   ≤991px: aside menjadi offcanvas drawer (Bootstrap .offcanvas-lg),
   ≥992px: aside menjadi kolom tetap & .app-main digeser selebar sidebar.
   ================================================================== */
.app-sidebar {
  --bs-offcanvas-width: 200px;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
}
.app-sidebar-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex: none;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
}
.app-sidebar-head .brand { font-size: 18px; }
.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: .75rem .6rem;
}
.sidebar-nav .nav { gap: .15rem; }
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--bs-secondary-color, #5b7a84);
  font-weight: 500;
  border-radius: 9px;
  padding: .55rem .75rem;
}
.sidebar-nav .nav-link .nav-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex: none;
}
.sidebar-nav .nav-link .nav-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Tombol burger (lipat desktop & buka drawer mobile). */
.sidebar-toggle,
.sidebar-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  flex: none;
  color: var(--bs-secondary-color, #5b7a84);
  background: rgba(13, 148, 136, .06);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.sidebar-toggle:hover,
.sidebar-burger:hover { color: var(--bs-body-color); background: rgba(13, 148, 136, .12); }
.sidebar-nav .nav-link:hover { color: var(--bs-body-color); background: rgba(13, 148, 136, .08); }
.sidebar-nav .nav-link.active {
  color: #0f766e;
  background: linear-gradient(135deg, rgba(45, 212, 191, .18), rgba(13, 148, 136, .14));
  box-shadow: inset 0 0 0 1px rgba(13, 148, 136, .40);
}
.sidebar-user {
  flex: none;
  padding: .9rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--bs-secondary-color, #5b7a84);
  font-size: 13px;
}
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
@media (min-width: 992px) {
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 200px;
    transform: none;
    visibility: visible;
    /* Level stacking sidebar. Tanpa ini `.app-sidebar` tetap `z-index: auto`, sehingga card
       di `.app-main` (posisinya belakangan di DOM) melukis di atas sidebar — termasuk popover
       label rail. 1030 = layer "fixed" Bootstrap: di atas semua konten halaman, di bawah
       offcanvas (1045) & modal (1055) agar dialog tetap menutupi sidebar. */
    z-index: 1030;
    /* Bootstrap menyetel background offcanvas-lg transparan !important di ≥lg. */
    background: rgba(255, 255, 255, .86) !important;
    transition: width .18s ease;
  }
  .app-main { margin-left: 200px; transition: margin-left .18s ease; }

  /* Kondisi rail: sidebar menyempit, label disembunyikan, ikon terpusat. */
  body.sidebar-collapsed .app-sidebar { width: 72px; }
  body.sidebar-collapsed .app-main { margin-left: 72px; }
  body.sidebar-collapsed .app-sidebar-head { justify-content: center; padding-left: .5rem; padding-right: .5rem; }
  body.sidebar-collapsed .app-sidebar-head .brand { display: none; }
  body.sidebar-collapsed .sidebar-nav .nav-label,
  body.sidebar-collapsed .sidebar-nav .badge { display: none; }
  body.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
  body.sidebar-collapsed .sidebar-user { padding-left: .5rem; padding-right: .5rem; }
  body.sidebar-collapsed .sidebar-user-name,
  body.sidebar-collapsed .sidebar-user-badge,
  body.sidebar-collapsed .sidebar-logout { display: none; }
  body.sidebar-collapsed .sidebar-user > .d-flex { justify-content: center; margin-bottom: 0 !important; }

  /* Popover label menu saat rail terlipat — hanya di mode ini (label tersembunyi).
     `overflow: visible` wajib: kontainer pemotong satu-satunya adalah .sidebar-nav (overflow-y:auto),
     dan popover menggantung ke kanan keluar dari rail 72px. Tidak diubah saat sidebar terbuka. */
  body.sidebar-collapsed .sidebar-nav { overflow: visible; }
  body.sidebar-collapsed .sidebar-nav .nav-link { position: relative; }
  body.sidebar-collapsed .sidebar-nav .nav-link::before,
  body.sidebar-collapsed .sidebar-nav .nav-link::after {
    position: absolute;
    top: 50%;
    pointer-events: none;
    opacity: 0;
    z-index: 1080;
    transition: opacity .14s ease, transform .14s ease;
  }
  /* Bubble: tampil di kanan ikon, meluncur masuk sedikit. */
  body.sidebar-collapsed .sidebar-nav .nav-link::after {
    content: attr(data-label);
    left: calc(100% + 10px);
    transform: translateY(-50%) translateX(-4px);
    white-space: nowrap;
    background: rgba(255, 255, 255, .98);
    color: var(--bs-body-color);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: .35rem .65rem;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: 0 12px 26px -14px rgba(13, 90, 80, .55);
  }
  /* Panah kecil menunjuk ke ikon. */
  body.sidebar-collapsed .sidebar-nav .nav-link::before {
    content: "";
    left: calc(100% + 4px);
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: var(--border);
  }
  body.sidebar-collapsed .sidebar-nav .nav-link:hover::after,
  body.sidebar-collapsed .sidebar-nav .nav-link:focus-visible::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
  body.sidebar-collapsed .sidebar-nav .nav-link:hover::before,
  body.sidebar-collapsed .sidebar-nav .nav-link:focus-visible::before { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .app-sidebar, .app-main { transition: none; }
  body.sidebar-collapsed .sidebar-nav .nav-link::before,
  body.sidebar-collapsed .sidebar-nav .nav-link::after { transition: none; }
}
