/* ===== Variables ===== */
:root {
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --nav-active-bg: rgba(99, 102, 241, 0.2);
  --nav-active-text: #a5b4fc;
  --nav-hover-bg: rgba(255, 255, 255, 0.06);
  --accent: #6366f1;
  --accent-soft: #818cf8;
  --main-bg: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 40px -10px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition-view: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-nav: 0.2s ease;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--main-bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== Login Screen ===== */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  box-sizing: border-box;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 40%, #0f172a 100%);
}

.login-screen.hidden {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 360px;
  margin: auto;
  padding: 2rem 1.75rem;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1rem;
}

.login-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin-bottom: 0.75rem;
}

.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  text-align: center;
  margin: 0;
  letter-spacing: -0.02em;
}

.login-desc {
  font-size: 0.875rem;
  color: #64748b;
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-form .form-group {
  margin-bottom: 1.25rem;
}

.login-form .form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}

.login-form .form-group input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-form .form-group input::placeholder {
  color: #94a3b8;
}

.login-form .form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.login-form .btn-block {
  width: 100%;
  padding: 0.8rem 1rem;
  margin-top: 0.25rem;
  font-weight: 600;
  border-radius: 10px;
}

.login-error {
  font-size: 0.8125rem;
  color: #dc2626;
  margin: 0.4rem 0 0;
  min-height: 1.25rem;
}

/* ===== App Layout ===== */
.app {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-img {
  width: 150px;
  height: 50px;
  max-width: 150px;
  max-height: 50px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-nav), color var(--transition-nav),
    transform 0.15s ease;
  position: relative;
}

.nav-item:hover {
  background: var(--nav-hover-bg);
  color: #fff;
}

.nav-item:active {
  transform: scale(0.98);
}

.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-text);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent-soft);
  border-radius: 0 3px 3px 0;
}

.nav-label {
  letter-spacing: 0.02em;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
}

.footer-text {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  display: block;
  margin-bottom: 0.5rem;
}

.sidebar-footer .btn-folder {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.7rem;
  font-family: inherit;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.sidebar-footer .btn-folder:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-logout {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.btn-logout:hover {
  background: rgba(220, 38, 38, 0.2);
  color: #f87171;
  border-color: rgba(220, 38, 38, 0.3);
}

/* ===== Main content ===== */
.main {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
  padding: 2rem 2.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Views (content panels) ===== */
.view {
  position: absolute;
  top: 2rem;
  left: 2.5rem;
  right: 2.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity var(--transition-view), transform var(--transition-view),
    visibility var(--transition-view);
  pointer-events: none;
}

.view.view-active {
  position: relative;
  top: 0;
  left: 0;
  right: 0;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.view-header {
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.view-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.view-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.view-content {
  margin-top: 1rem;
}

.placeholder-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.placeholder-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ===== Table toolbar (search + add) ===== */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
}

.search-input {
  width: 100%;
  max-width: 320px;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-sm);
  background: var(--card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 0.75rem center;
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.th-aksi,
.td-aksi {
  min-width: 80px;
  white-space: nowrap;
}

/* Kolom Aksi tetap terlihat saat scroll horizontal */
.data-table th.th-aksi {
  position: sticky;
  right: 0;
  background: var(--sidebar-bg);
  z-index: 2;
  box-shadow: -4px 0 10px rgba(0, 0, 0, 0.12);
}

.data-table td.td-aksi {
  position: sticky;
  right: 0;
  background: var(--card-bg);
  z-index: 1;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.06);
}

.data-table tbody tr.row-noindex td.td-aksi {
  background: #fef9c3;
}

.data-table tbody tr.row-error td.td-aksi {
  background: #fecaca;
}

.data-table tbody tr:hover td.td-aksi {
  background: rgba(99, 102, 241, 0.04);
}

.data-table tbody tr.row-noindex:hover td.td-aksi {
  background: #fef08a;
}

.data-table tbody tr.row-error:hover td.td-aksi {
  background: #fca5a5;
}

/* Kolom 301 (penanda redirect di AGED) */
.td-301 {
  min-width: 2.5rem;
  text-align: center;
}
.badge-301 {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #1e3a5f;
  background: #bae6fd;
  border-radius: 4px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.is-open .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
}

.modal-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group select {
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: border-color 0.2s ease;
  cursor: pointer;
}

.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea {
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: border-color 0.2s ease;
  resize: vertical;
  min-height: 4rem;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group.form-group-full {
  grid-column: 1 / -1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.modal-footer-end {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-footer-detail {
  justify-content: space-between;
}

.modal-footer-detail .btn-primary {
  margin-left: auto;
}

.modal.modal-sm {
  max-width: 400px;
}

.modal-confirm .modal-body {
  padding: 1.5rem;
}

.confirm-message {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
}

@media (max-width: 520px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Data table (ACID dll) ===== */
.table-scroll-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#view-acid .view-content,
#view-ebn .view-content,
#view-aged .view-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.table-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.04);
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Sticky bar di bawah (tetap di bawah saat scroll) */
.sticky-bottom {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  flex-shrink: 0;
  padding: 0.5rem 0;
  background: var(--main-bg);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  z-index: 10;
}

.sticky-bottom-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.data-table {
  width: 100%;
  min-width: 1400px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  background: var(--sidebar-bg);
  color: rgba(255, 255, 255, 0.95);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--sidebar-border);
}

.data-table th:not(:last-child) {
  border-right: 1px solid var(--sidebar-border);
}

.data-table tbody tr {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

.data-table tbody tr.row-noindex {
  background: #fef9c3;
}

.data-table tbody tr.row-noindex:hover {
  background: #fef08a;
}

.data-table tbody tr.row-error {
  background: #fecaca;
}

.data-table tbody tr.row-error:hover {
  background: #fca5a5;
}

.data-table td {
  padding: 0.65rem 1rem;
  color: var(--text-primary);
}

.data-table td:not(:last-child) {
  border-right: 1px solid rgba(0, 0, 0, 0.05);
}

/* Kolom domain dan ip tampil penuh, tidak terpotong */
.data-table th:nth-child(1),
.data-table td:nth-child(1) {
  min-width: 200px;
  max-width: 320px;
  white-space: normal;
  word-break: break-all;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  min-width: 130px;
  max-width: 200px;
  white-space: normal;
  word-break: break-all;
}

.data-table .empty-row {
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  padding: 2rem 1rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 72px;
    min-width: 72px;
    padding: 0.5rem 0;
  }

  .sidebar-header {
    padding: 1rem 0.5rem;
    display: flex;
    justify-content: center;
  }

  .footer-text {
    display: none;
  }

  .logo-icon {
    margin: 0 auto;
  }

  .nav-label {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 1rem;
  }

  .main {
    margin-left: 72px;
    padding: 1.5rem 1.25rem;
  }

  .view {
    left: 1.25rem;
    right: 1.25rem;
  }
}
