/* ==========================================================================
   CYBERPUNK CHATBOT INTERFACE (Tactical Terminal)
   ========================================================================== */

/* Header Area */
.chat-header {
  position: fixed; top: 0; left: 0; width: 100%; height: 75px;
  background: rgba(10, 10, 18, 0.85); backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 242, 254, 0.2);
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 40px; z-index: 100;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

/* GANTI .back-btn LAMA DENGAN INI */
.back-btn-desktop {
  color: var(--text-muted); text-decoration: none; 
  font-family: var(--font-cyber); font-size: 0.85rem; letter-spacing: 1px;
  transition: var(--transition-smooth); display: flex; align-items: center; gap: 12px;
}
.back-btn-desktop:hover { color: var(--neon-cyan); text-shadow: 0 0 8px var(--neon-cyan); }
.bot-identity {
  display: flex; align-items: center; gap: 15px;
}
.identity-text {
  display: flex; flex-direction: column; align-items: flex-end;
}
.bot-name {
  font-family: var(--font-cyber); font-size: 0.95rem; color: var(--text-main); letter-spacing: 1px;
}
.bot-status {
  font-family: monospace; font-size: 0.75rem; color: #00ff66; letter-spacing: 1px;
  display: flex; align-items: center; gap: 6px; margin-top: 4px;
}
.status-indicator {
  width: 6px; height: 6px; background: #00ff66; border-radius: 50%; box-shadow: 0 0 10px #00ff66;
  animation: pulse 2s infinite;
}

@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.3; } 100% { opacity: 1; } }

/* Main Chat Container (Glass Terminal Window) */
.chat-wrapper {
  max-width: 950px;
  margin: 110px auto 40px auto;
  height: calc(100vh - 150px);
  display: flex; flex-direction: column;
  background: rgba(10, 10, 18, 0.6);
  border: 1px solid rgba(0, 242, 254, 0.15);
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(0, 242, 254, 0.05);
  position: relative;
  overflow: hidden;
}

/* Scanline / Grid Effect Inside Terminal */
.chat-wrapper::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(rgba(0, 242, 254, 0.03) 1px, transparent 1px),
              linear-gradient(90deg, rgba(0, 242, 254, 0.03) 1px, transparent 1px);
  background-size: 25px 25px;
  pointer-events: none; z-index: 0;
}

.chat-box {
  flex: 1; overflow-y: auto; padding: 35px;
  display: flex; flex-direction: column; gap: 25px;
  z-index: 1; scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-box::-webkit-scrollbar { width: 6px; }
.chat-box::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.chat-box::-webkit-scrollbar-thumb { background: rgba(0, 242, 254, 0.3); border-radius: 10px; }
.chat-box::-webkit-scrollbar-thumb:hover { background: var(--neon-cyan); }

/* Message Architecture */
.message-wrapper {
  display: flex; align-items: flex-end; gap: 15px; max-width: 85%;
}
.bot-wrapper { align-self: flex-start; }
.user-wrapper { align-self: flex-end; flex-direction: row-reverse; }

/* Avatar Boxes */
.chat-avatar {
  width: 42px; height: 42px; border-radius: 6px;
  border: 1px solid var(--neon-cyan);
  background: rgba(0, 242, 254, 0.1);
  display: flex; justify-content: center; align-items: center;
  flex-shrink: 0; overflow: hidden;
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.2);
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-avatar i { color: var(--neon-cyan); font-size: 1.2rem; }

.user-avatar {
  border-color: var(--neon-purple); background: rgba(157, 78, 221, 0.1);
  box-shadow: 0 0 12px rgba(157, 78, 221, 0.2);
}
.user-avatar i { color: var(--neon-purple); }

/* Bubble Messages */
.message {
  padding: 18px 24px; border-radius: 8px; line-height: 1.6; font-size: 0.95rem;
  position: relative; animation: msgFade 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
  backdrop-filter: blur(5px);
}

@keyframes msgFade { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

/* System Status Message */
.system-msg {
  align-self: center; background: rgba(0, 0, 0, 0.4);
  border: 1px dashed rgba(255, 255, 255, 0.2); color: var(--text-muted);
  font-size: 0.75rem; font-family: var(--font-cyber); padding: 8px 18px;
  letter-spacing: 1px; max-width: 100%; border-radius: 4px;
}

/* Sender Labels (SYS // FADIL vs USER // GUEST) */
.msg-sender {
  font-family: var(--font-cyber); font-size: 0.65rem; color: var(--neon-cyan);
  margin-bottom: 10px; letter-spacing: 1px; opacity: 0.8; display: block;
}

.bot-msg {
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.08), rgba(0, 242, 254, 0.01));
  border: 1px solid rgba(0, 242, 254, 0.15); border-left: 4px solid var(--neon-cyan);
  color: var(--text-main); border-bottom-left-radius: 0;
}

.user-msg .msg-sender { color: var(--neon-purple); text-align: right; }
.user-msg {
  background: linear-gradient(135deg, rgba(157, 78, 221, 0.08), rgba(157, 78, 221, 0.01));
  border: 1px solid rgba(157, 78, 221, 0.15); border-right: 4px solid var(--neon-purple);
  color: var(--text-main); border-bottom-right-radius: 0;
}

/* Command Line Input Area */
.chat-input-area {
  display: flex; gap: 15px; padding: 20px 35px;
  background: rgba(0, 0, 0, 0.4); border-top: 1px solid rgba(255, 255, 255, 0.08);
  align-items: center; z-index: 1;
}

.cmd-prompt {
  font-family: var(--font-cyber); color: var(--neon-cyan); font-size: 1rem; font-weight: bold;
}

#user-input {
  flex: 1; padding: 12px 0; background: transparent; border: none;
  color: var(--text-main); font-size: 1rem; font-family: monospace; /* Font koding agar terasa seperti di terminal */
}

#user-input:focus { outline: none; }
#user-input::placeholder { color: rgba(255, 255, 255, 0.2); }

#send-btn {
  padding: 12px 25px; border-radius: 4px; border: 1px solid var(--neon-cyan);
  background: rgba(0, 242, 254, 0.1); color: var(--neon-cyan);
  font-family: var(--font-cyber); font-size: 0.8rem; letter-spacing: 1px;
  cursor: pointer; transition: var(--transition-smooth);
  display: flex; align-items: center; gap: 10px; font-weight: bold;
}

#send-btn:hover {
  background: var(--neon-cyan); color: var(--bg-dark); box-shadow: 0 0 20px rgba(0, 242, 254, 0.4);
}
/* Tambahkan ini tepat sebelum baris @media (max-width: 768px) */
.mobile-only-trigger {
  display: none !important;
}
/* ==========================================================================
   RESPONSIVE OPTIMIZATION (MOBILE VIEWPORT REPAIR)
   ========================================================================== */
@media (max-width: 768px) {
  /* 1. Penyesuaian Navigasi Atas (Header) */
  .chat-header {
    padding: 0 15px;
    height: 65px;
  }

  .back-btn span {
    display: none; /* Sembunyikan teks "RETURN // PORTFOLIO" agar hemat ruang */
  }

  .back-btn {
    font-size: 1.1rem; /* Perbesar sedikit ukuran ikon panah agar mudah ditekan */
    padding: 10px 5px;
  }

  .bot-name {
    font-size: 0.85rem; /* Perkecil sedikit ukuran font judul agar tidak sesak */
    letter-spacing: 0.5px;
  }

  .bot-status {
    font-size: 0.7rem;
  }

  /* 2. Reset Margin & Batasan Window Terminal */
  .chat-wrapper { 
    margin: 80px 10px 15px 10px; 
    height: calc(100vh - 105px); 
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
  }

  /* 3. Kurangi Padding Box Obrolan Agar Ruang Teks Lebih Luas */
  .chat-box { 
    padding: 15px; 
    gap: 15px;
  }

  /* 4. Paksa Lebar Pesan Fleksibel & Matikan Efek Kolom Ganda */
  .message-wrapper { 
    max-width: 100%; 
    width: 100%;
    gap: 0;
  }
  
  .message {
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  /* 5. Sembunyikan Avatar Total */
  .chat-avatar {
    display: none !important;
  }

  /* 6. Perbaikan Sektor Form Input & Tombol Transmit */
  .chat-input-area { 
    padding: 12px 15px; 
    gap: 10px;
  }

  .cmd-prompt {
    font-size: 0.9rem;
  }

  #user-input {
    font-size: 0.9rem;
  }

  /* Mengubah button menjadi lingkaran/persegi ikon murni */
  #send-btn {
    padding: 0;
    width: 45px;
    height: 45px;
    justify-content: center;
    flex-shrink: 0; /* Mencegah tombol gepeng atau menyusut */
    border-radius: 50%; /* Membuatnya bulat rapi ala tombol chat modern jika diinginkan, atau ubah ke 4px jika ingin tetap kaku */
  }

  /* Sembunyikan tulisan TRANSMIT secara total di mobile */
  #send-btn span { 
    display: none !important; 
  }
  
  /* Pusatkan ikon satelit tepat di tengah-tengah tombol */
  #send-btn i {
    margin: 0;
    font-size: 1.1rem;
  }
}

/* FLOATING ACTION BUTTON - DESKTOP ONLY */
@media screen and (min-width: 769px) {
  .desktop-report-fab {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 45px;
    height: 45px;
    background: rgba(10, 10, 18, 0.8);
    border: 1px solid rgba(255, 0, 60, 0.3);
    border-radius: 50%;
    color: #ff003c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    text-decoration: none;
    box-shadow: 0 0 10px rgba(255, 0, 60, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 9998;
    transition: all 0.3s ease;
  }

  .desktop-report-fab:hover {
    background: #ff003c;
    color: #0a0a12;
    border-color: #ff003c;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 0 20px rgba(255, 0, 60, 0.5);
  }
}

/* Sembunyikan tombol melayang ini di perangkat mobile */
@media screen and (max-width: 768px) {
  /* ==========================================================================
     TAMBAHAN UNTUK NAVBAR GABUNGAN MOBILE
     ========================================================================== */
  .back-btn-desktop {
    display: none !important; /* Sembunyikan tombol kembali bawaan desktop */
  }

  .mobile-only-trigger {
    display: block !important; /* Munculkan hamburger menu di mobile */
  }

  /* Modifikasi chat-header lama agar bertindak sebagai fixed navbar di mobile */
  .chat-header {
    position: fixed; top: 0; left: 0; width: 100%; height: 55px; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(10, 10, 18, 0.95); border-bottom: 1px solid rgba(0, 242, 254, 0.15);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 9999;
  }

  /* Tombol Hamburger */
  .nav-toggle-btn {
    background: transparent; border: 1px solid rgba(0, 242, 254, 0.3); color: #00f2fe;
    width: 36px; height: 36px; border-radius: 4px; display: flex; align-items: center;
    justify-content: center; cursor: pointer; font-size: 0.9rem; outline: none;
  }

  /* ==========================================================================
     PERBAIKAN POSISI DROPDOWN RATAKAN KIRI DENGAN TOMBOL
     ========================================================================== */
  
  /* 1. Pastikan kontainer pembungkus tombol menjadi acuan koordinat (Anchor) */
  .nav-menu-wrapper {
    position: relative;
    display: inline-block;
  }

  /* 2. Atur posisi panel dropdown content */
  .nav-dropdown-content {
    display: none;
    position: absolute;
    
    /* Jarak vertikal dari tombol hamburger ke bawah */
    top: calc(100% + 8px); 
    
    /* MEMBUAT STRUKTUR PAS RATA KIRI: Menempel tegak lurus dengan sisi kiri tombol */
    left: 0; 
    
    background: #0d0d1a;
    border: 1px solid rgba(0, 242, 254, 0.25);
    min-width: 180px;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    z-index: 10000;
  }

  .nav-dropdown-content.show-menu {
    display: block; animation: fadeInMenu 0.2s ease-out;
  }

  .nav-dropdown-item {
    color: #8a8a98; padding: 12px 16px; text-decoration: none; display: flex;
    align-items: center; gap: 10px; font-size: 0.8rem; border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-family: monospace;
  }

  .nav-dropdown-item.purple-twin { color: #a855f7; }
  .nav-dropdown-item.red-report { color: #ff003c; }

  @keyframes fadeInMenu {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .desktop-report-fab {
    display: none !important;
  }
}

/* ==========================================================================
   ALERT LAYER TRANSITION CONTROLLER
   ========================================================================== */
.custom-alert-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(10, 10, 18, 0.85);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100000;
  
  /* Menyembunyikan alert di awal */
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
}

/* Kelas pemicu yang diaktifkan oleh JavaScript */
.custom-alert-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.custom-alert-box {
  /* Memastikan transisi animasi pembesaran kotak seimbang */
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.2);
}

.custom-alert-overlay.active .custom-alert-box {
  transform: scale(1);
}

/* ==========================================================================
   TACTICAL TERMINAL LOADER OVERLAY
   ========================================================================== */
.terminal-loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0a0a12;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000000; /* Mengunci posisi di atas elemen apa pun termasuk header */
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

/* Kelas pemicu hilangnya loader dari Javascript */
.terminal-loader-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-content {
  text-align: center;
  font-family: monospace;
  color: #00f2fe;
}

.loader-matrix {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

.matrix-text {
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  text-shadow: 0 0 8px rgba(0, 242, 254, 0.6);
}

.glow-bar {
  width: 280px;
  height: 4px;
  background: rgba(0, 242, 254, 0.05);
  border: 1px solid rgba(0, 242, 254, 0.2);
  border-radius: 2px;
  margin: 12px auto;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: #00f2fe;
  box-shadow: 0 0 12px #00f2fe;
  animation: loadProgress 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.loader-sub {
  font-size: 0.75rem;
  color: #8a8a98;
  letter-spacing: 1px;
  animation: pulseText 0.8s infinite alternate;
}

/* KEYFRAMES SIMULASI ANIMASI LOADING */
@keyframes loadProgress {
  0% { width: 0%; }
  25% { width: 35%; }
  65% { width: 75%; }
  100% { width: 100%; }
}

@keyframes pulseText {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

/* Class untuk menyembunyikan tombol transmit */
.transmit-hidden {
  display: none !important;
}