/* reset box sizing & prevent horizontal scroll */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

:root {
  --bg: #ffffff;
  --text: #111;
  --sub: #555;
  --card: #f4f4f4;
  --border: #e4e4e4;
  --link: #dc1305;
  --card-head: #dddddd;
  --content-link-bg-light: #ff8880;
  --content-link-bg-dark: #93eba2;
}

[data-theme="dark"] {
  --bg: #0d0d0d;
  --text: #f2f2f2;
  --sub: #c2c2c2;
  --card: #1a1a1a;
  --border: #2d2d2d;
  --link: #28c840;
  --card-head: #2b2b2b;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  width: 100%;
  max-width: 750px;
  margin: 0 auto;
  min-width: 0;
  transition: background .2s, color .2s;
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* NAVBAR */
nav {
  width: 100%;
  padding: 18px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: transparent;
  position: relative;
}

.left {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 0 1 auto;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
}

.right {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}

.nav-link {
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  padding: 6px 8px;
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: 6px;
}

.nav-link:active,
.nav-link:focus {
  outline: none;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 6px;
}

.hamburger {
  display: none;
  flex-direction: column;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
}

.hamburger span {
  width: 25px;
  height: 3px;
  background-color: var(--text);
  margin: 3px 0;
  transition: 0.3s;
  border-radius: 3px;
}

.mobile-nav {
  display: none;
  width: 100%;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

.mobile-nav.active {
  display: block;
}

.mobile-nav .nav-link {
  display: block;
  padding: 12px 16px;
  font-size: 16px;
}

/* CONTENT (sections) */
.section {
  display: none;
  padding: 18px;
  flex: 1;
}

.active {
  display: block;
}

h1 {
  font-size: 26px;
  margin: 0 0 10px 0;
}
h2 {
  font-size: 22px;
  margin: 0 0 10px 0;
}
p {
  margin: 0 0 12px 0;
  color: var(--sub);
  line-height: 1.6;
}

a {
  color: var(--link);
  text-decoration: none;
}

.section a:not(.nav-link):not(.btn):not(.post-link) {
  display: inline-block;
  padding: 0px 0px;
  border-radius: 5px;
  text-decoration: none;
  transition: background-color 0.2s;
  background-color: transparent;
  box-shadow: none;
  outline: none;
  border: none;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.section a:not(.nav-link):not(.btn):focus {
  outline: none;
  box-shadow: 0 0 0 0px var(--link);
}

.post-favicon {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: text-bottom;
  border-radius: 2px;
}

.btn {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 16px;
  background: var(--text);
  color: var(--bg);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}

/* SPEAKING CARDS */
.speak-card {
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 20px;
}

.speak-card-head {
  background: var(--card-head);
  padding: 8px 12px;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.red {
  background: #ff5f57;
}
.yellow {
  background: #ffbd2e;
}
.green {
  background: #28c840;
}

.speak-card-body {
  padding: 14px 16px;
}
.speak-card-body pre {
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  color: var(--text);
}

/* Style untuk kartu kutipan keamanan */
.quote-card {
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 20px;
}

.quote-card-head {
  background: var(--card-head);
  padding: 8px 12px;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quote-card-body {
  padding: 14px 16px;
}

/* CLIENTS GRID */
.clients-description {
  margin-bottom: 30px;
  line-height: 1.6;
}

.clients-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 30px;
  margin-top: 30px;
}

.client-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  background-color: var(--card);
  border-radius: 8px;
  padding: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: none;
  outline: none;
}

.client-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.client-item img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.client-name {
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

/* CONTACT STYLES */
.contact-info {
  margin-bottom: 20px;
}

.contact-info p {
  font-size: 16px;
  margin-bottom: 8px;
}

.contact-info a {
  color: var(--link);
  text-decoration: none !important;
}

.contact-info a:hover {
  text-decoration: none !important;
}

.security-key {
  margin-top: 30px;
}

.security-key h2 {
  margin-bottom: 15px;
}

.key-details {
  background: var(--card);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

.key-details p {
  margin: 5px 0;
  display: flex;
}

.key-details strong {
  width: 120px;
  flex-shrink: 0;
}

/* FOOTER */
footer {
  width: 100%;
  margin-top: auto;
  padding: 40px 20px 20px;
  text-align: center;
  border-top: 1px solid var(--border);
  background-color: var(--bg);
}

.footer-social-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.footer-social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--sub);
  background-color: var(--card);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: color 0.2s ease-in-out, background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
  box-shadow: none;
  outline: none;
}

.footer-social-links a:hover {
  color: var(--text);
  background-color: var(--card-head);
  border-color: var(--link);
}

.footer-copyright {
  font-size: 14px;
  color: var(--sub);
}

.muted {
  color: var(--sub);
  font-size: 14px;
}

/* Style untuk form tambah artikel */
.add-post-form-container {
  display: flex;
  gap: 10px;
  align-items: center;
}

.form-input {
  flex-grow: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

/* PERBAIKAN: Hapus margin-top pada tombol di dalam form agar tidak turun ke baris baru */
.add-post-form-container .btn {
  margin-top: 0;
}

.form-input:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 2px rgba(40, 200, 64, 0.2);
}

[data-theme="dark"] .form-input:focus {
  box-shadow: 0 0 0 2px rgba(40, 200, 64, 0.4);
}

/* RESPONSIVE */
@media (max-width: 600px) {
  nav {
    padding: 14px 10px;
    gap: 8px;
  }
  .brand-name {
    font-size: 22px;
  }
  .nav-link {
    margin: 0;
    font-size: 14px;
  }
  .theme-toggle {
    width: 34px;
    height: 34px;
  }
  h1 {
    font-size: 22px;
  }
  .speak-card-head {
    height: 24px;
    padding: 7px 10px;
  }
  .speak-card-body {
    padding: 12px 12px;
  }
  .speak-card-body pre {
    font-size: 13px;
  }

  .hamburger {
    display: flex;
  }

  .right .nav-link {
    display: none;
  }

  .mobile-nav .nav-link {
    display: block;
    font-size: 16px;
    padding: 12px 16px;
  }

  .right {
    gap: 6px;
  }

  .key-details strong {
    width: 100px;
  }

  .clients-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}

/* --- STYLE UNTUK MODAL/POPUP --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 95%;
  max-width: 690px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--sub);
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text);
}

.modal-body {
  padding: 20px;
  overflow-y: auto; /* Ini membuat konten bisa di-scroll */
  flex-grow: 1; /* Memastikan body mengisi sisa ruang */
}

.modal-body p {
  margin-bottom: 15px; /* Beri jarak antar item di dalam modal */
}

@media (max-width: 360px) {
  .nav-link {
    flex-basis: 100%;
    display: inline-block;
  }
  .right {
    gap: 6px;
  }

  .clients-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }
}


/* --- STYLE UNTUK LOGIN MODAL --- */
#login-form {
  padding: 20px 24px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

/* --- STYLE UNTUK STATISTIK PENGUNJUNG (PERBAIKAN TERBARU) --- */
#visitor-statistics {
    width: 100%;
    margin-top: 20px;
    padding: 20px;
    border-top: 1px solid var(--border);
    background-color: var(--bg);
}

.statistics-container {
    max-width: 100%;
    margin: 0 auto;
}

/* Style untuk judul yang di tengah */
.statistics-title {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 20px;
    color: var(--text);
    text-align: center;
}

/* Style untuk ringkasan statistik dalam 1 baris */
.stats-summary {
    display: flex;
    background-color: var(--card);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.stat-item {
    flex: 1; /* Membuat setiap item memiliki lebar yang sama */
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-right: 1px solid var(--border);
}

.stat-item:last-child {
    border-right: none; /* Menghapus border di item terakhir */
}

.stat-label {
    font-weight: 600;
    color: var(--sub);
}

.stat-value {
    font-weight: 600;
    color: var(--text);
}

.stats-section {
    margin-bottom: 20px;
}

.stats-section h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    color: var(--text);
}

.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

/* Tabel yang bisa di-scroll dengan tinggi maksimal */
.scrollable-table {
    max-height: 230px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.stats-table th {
    background-color: var(--card-head);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
}

.stats-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table tr:hover {
    filter: brightness(0.95);
}

/* Status indicators */
.status-online {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    background-color: rgba(40, 200, 64, 0.2);
    color: #28c840;
}

.status-offline {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    background-color: rgba(220, 53, 69, 0.2);
    color: #dc3545;
}

/* Private tables with smaller font size */
.private-table {
    font-size: 0.85em;
}

.private-table th {
    padding: 8px 10px;
}

.private-table td {
    padding: 8px 10px;
}

/* Public table */
.public-table {
    font-size: 0.9em;
}

.public-table th {
    padding: 10px 12px;
}

.public-table td {
    padding: 10px 12px;
}

/* Responsive untuk statistik */
@media (max-width: 600px) {
    .table-container {
        font-size: 14px;
    }
    
    .stats-table th, .stats-table td {
        padding: 8px 10px;
    }
    
    .private-table {
        font-size: 0.8em;
    }
    
    .private-table th, .private-table td {
        padding: 6px 8px;
    }
    
    .public-table {
        font-size: 0.85em;
    }
    
    .public-table th, .public-table td {
        padding: 8px 10px;
    }
    
    .scrollable-table {
        max-height: 250px;
    }
}