/* ============================================================
   SANDIKALA — Bilik Sandi Digital
   Tema: futuristik, gelap, neon cyan/violet, glassmorphism
   Mobile-first
   ============================================================ */

:root {
  --bg-0: #05070d;
  --bg-1: #0a0f1c;
  --bg-2: #0f1526;
  --panel: rgba(18, 24, 42, 0.72);
  --panel-border: rgba(96, 220, 255, 0.18);
  --cyan: #4fe3ff;
  --violet: #9b6bff;
  --gold: #ffcb6b;
  --red: #ff5c7a;
  --green: #45f0b0;
  --text-0: #eaf3ff;
  --text-1: #a9b8d6;
  --text-2: #6c7a99;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-glow: 0 0 24px rgba(79, 227, 255, 0.15);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: "Segoe UI", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(circle at 15% 0%, rgba(79, 227, 255, 0.10), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(155, 107, 255, 0.12), transparent 45%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 40%, var(--bg-0));
  min-height: 100dvh;
}

/* animated cyber grid backdrop */
.grid-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(79, 227, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 227, 255, 0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse at center, black 0%, transparent 75%);
  animation: driftGrid 40s linear infinite;
}
@keyframes driftGrid {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 420px 420px, 420px 420px; }
}

a { color: inherit; }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(79, 227, 255, 0.25); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Login screen ---------- */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-glow), 0 20px 60px rgba(0,0,0,0.5);
  padding: 32px 24px 28px;
  animation: floatIn 0.6s ease both;
}
@keyframes floatIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  text-align: center;
}

.brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(79,227,255,0.18), rgba(155,107,255,0.18));
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 30px rgba(79,227,255,0.25);
}
.brand-mark svg { width: 34px; height: 34px; }

.brand-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub {
  font-size: 0.78rem;
  color: var(--text-1);
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-1);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(6, 10, 20, 0.65);
  color: var(--text-0);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(79,227,255,0.15);
}

.btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  color: #041018;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 8px 24px rgba(79,227,255,0.25);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-0);
  box-shadow: none;
}
.btn-danger { background: linear-gradient(90deg, var(--red), #c73a5b); color: #1a0507; }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; width: auto; }

.error-msg {
  background: rgba(255, 92, 122, 0.1);
  border: 1px solid rgba(255, 92, 122, 0.35);
  color: #ffb3c1;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 14px;
}
.hint-msg {
  font-size: 0.72rem;
  color: var(--text-2);
  text-align: center;
  margin-top: 18px;
  line-height: 1.5;
}
.badge-secure {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--green);
  border: 1px solid rgba(69, 240, 176, 0.3);
  background: rgba(69, 240, 176, 0.08);
  padding: 4px 10px;
  border-radius: 999px;
  margin-top: 10px;
}
.badge-secure .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- App shell ---------- */
.app-shell {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-columns: 300px 1fr;
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 20% 0 0; z-index: 30; transform: translateX(-105%); transition: transform 0.25s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 25; }
  .sidebar-backdrop.open { display: block; }
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-header .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
.sidebar-header .brand-mark svg { width: 22px; height: 22px; }
.sidebar-header .brand-title { font-size: 1rem; }

.user-strip {
  padding: 12px 16px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem;
  background: linear-gradient(135deg, rgba(79,227,255,0.25), rgba(155,107,255,0.25));
  border: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-meta .name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .role { font-size: 0.7rem; color: var(--text-2); }

.role-pill {
  display: inline-block;
  font-size: 0.62rem;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-top: 2px;
}
.role-superadmin { background: rgba(255,92,122,0.15); color: var(--red); }
.role-kepala_daerah { background: rgba(255,203,107,0.15); color: var(--gold); }
.role-forkopimda { background: rgba(79,227,255,0.15); color: var(--cyan); }
.role-anggota { background: rgba(169,184,214,0.12); color: var(--text-1); }

.room-list { flex: 1; overflow-y: auto; padding: 8px; }
.room-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.15s;
}
.room-item:hover, .room-item.active { background: rgba(79, 227, 255, 0.08); }
.room-item.active { border: 1px solid var(--panel-border); }
.room-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(155,107,255,0.12);
  flex-shrink: 0;
}
.room-name { font-size: 0.88rem; font-weight: 600; }
.room-desc { font-size: 0.72rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.unread-dot {
  margin-left: auto;
  min-width: 18px; height: 18px; border-radius: 999px;
  background: var(--red); color: #fff;
  font-size: 0.66rem; font-weight: 700;
  display: grid; place-items: center;
  padding: 0 4px;
}

.sidebar-footer { padding: 10px 12px; border-top: 1px solid var(--panel-border); display: flex; gap: 8px; }

/* ---------- Chat area ---------- */
.chat-area { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.chat-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(10, 15, 28, 0.6);
  backdrop-filter: blur(10px);
}
.hamburger {
  display: none;
  background: none; border: none; color: var(--text-0);
  font-size: 1.3rem; cursor: pointer; padding: 4px;
}
@media (max-width: 860px) { .hamburger { display: block; } }

.chat-title { font-weight: 700; font-size: 0.98rem; }
.chat-sub { font-size: 0.72rem; color: var(--text-2); }
.burn-indicator {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  font-size: 0.72rem; color: var(--gold);
  border: 1px solid rgba(255,203,107,0.3);
  background: rgba(255,203,107,0.08);
  padding: 5px 10px; border-radius: 999px;
  white-space: nowrap;
}

.messages {
  flex: 1; overflow-y: auto; padding: 18px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.empty-state {
  margin: auto; text-align: center; color: var(--text-2); max-width: 280px; font-size: 0.85rem;
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 10px; opacity: 0.5; }

.msg-row { display: flex; flex-direction: column; max-width: 78%; }
.msg-row.mine { align-self: flex-end; align-items: flex-end; }
.msg-row.theirs { align-self: flex-start; align-items: flex-start; }
.msg-sender { font-size: 0.68rem; color: var(--text-2); margin-bottom: 3px; padding: 0 4px; }
.bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.42;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}
.msg-row.mine .bubble {
  background: linear-gradient(135deg, rgba(79,227,255,0.22), rgba(155,107,255,0.22));
  border: 1px solid rgba(79,227,255,0.3);
  border-bottom-right-radius: 4px;
}
.msg-row.theirs .bubble {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-bottom-left-radius: 4px;
}
.bubble.burning { animation: burnPulse 1.2s ease-in-out infinite; }
@keyframes burnPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255,92,122,0); }
  50% { box-shadow: 0 0 14px rgba(255,92,122,0.45); }
}
.msg-meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; padding: 0 4px; font-size: 0.65rem; color: var(--text-2); }
.msg-meta .flame { color: var(--gold); }
.msg-meta .countdown { color: var(--red); font-variant-numeric: tabular-nums; }

.composer {
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--panel-border);
  background: rgba(10, 15, 28, 0.6);
  backdrop-filter: blur(10px);
}
.composer-controls {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.burn-select {
  font-size: 0.72rem;
  background: rgba(6,10,20,0.6);
  border: 1px solid var(--panel-border);
  color: var(--text-1);
  border-radius: 999px;
  padding: 5px 10px;
  display: flex; align-items: center; gap: 6px;
}
.burn-select select, .burn-select input {
  background: transparent; border: none; color: var(--text-0); font-size: 0.72rem; outline: none;
}
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 11px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(6,10,20,0.65);
  color: var(--text-0);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
}
.composer textarea:focus { border-color: var(--cyan); }
.send-btn {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(79,227,255,0.3);
}
.send-btn svg { width: 20px; height: 20px; }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3,5,10,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 16px;
  backdrop-filter: blur(4px);
}
.modal {
  width: 100%; max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 22px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-glow), 0 20px 60px rgba(0,0,0,0.6);
}
.modal h3 { margin: 0 0 16px; font-size: 1.05rem; }
.member-list { max-height: 200px; overflow-y: auto; border: 1px solid var(--panel-border); border-radius: var(--radius-sm); padding: 6px; margin-bottom: 14px; }
.member-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; font-size: 0.85rem; }
.member-item:hover { background: rgba(255,255,255,0.04); }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(15,21,38,0.95); border: 1px solid var(--panel-border);
  padding: 10px 16px; border-radius: 999px; font-size: 0.82rem;
  z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.top-actions { display: flex; gap: 8px; margin-left: 10px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--panel-border); background: rgba(255,255,255,0.03);
  color: var(--text-1); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 16px; height: 16px; }
