/* ==========================================================================
   ChatSphere - Modern Native CSS Design System
   ========================================================================== */

:root {
  /* Color Palette - Modern Dark Theme */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);

  /* Accents & Brand Gradients */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --bubble-gradient: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;

  /* Typography Colors */
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-inverse: #ffffff;

  /* Sizing & Transitions */
  --header-height: 68px;
  --sidebar-width: 320px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-panel: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-glow: 0 0 25px -5px rgba(99, 102, 241, 0.4);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  background-image: 
    radial-gradient(at 10% 10%, rgba(99, 102, 241, 0.12) 0px, transparent 45%),
    radial-gradient(at 90% 90%, rgba(139, 92, 246, 0.10) 0px, transparent 45%);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Glassmorphism Panel Component */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
}

/* Helper Classes */
.hidden {
  display: none !important;
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-gradient);
  color: var(--text-inverse);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.btn-icon:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}
.btn-link-sm {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.75rem;
  cursor: pointer;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ==========================================================================
   Authentication Screen
   ========================================================================== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 36px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  animation: fadeIn 0.4s ease;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.app-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-icon {
  font-size: 2rem;
  width: 46px;
  height: 46px;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.auth-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.form-actions-inline {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.seed-hints {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-glass);
}
.seed-hints small {
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
}
.seed-chips {
  display: flex;
  gap: 8px;
}
.chip {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}
.chip:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

/* Alert Box */
.alert-box {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 18px;
}
.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.alert-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

/* ==========================================================================
   Main Application Layout
   ========================================================================== */
.app-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-glass);
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon-sm {
  font-size: 1.4rem;
}
.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Live WebSocket Indicator */
.ws-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--warning);
}
.ws-online .status-dot {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}
.ws-offline .status-dot {
  background-color: var(--danger);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* User Profile Pill */
.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-glass);
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: white;
}
.user-info-text {
  display: flex;
  flex-direction: column;
}
.user-fullname {
  font-size: 0.85rem;
  font-weight: 600;
}
.user-role-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.5px;
}
.btn-logout {
  color: var(--text-muted);
}
.btn-logout:hover {
  color: var(--danger);
}

/* ==========================================================================
   Notifications Drawer / Dropdown
   ========================================================================== */
.notification-wrapper {
  position: relative;
}
.btn-notification {
  position: relative;
}
.badge-count {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: var(--radius-full);
  line-height: 1;
  animation: pulse 2s infinite;
}

.notification-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 340px;
  max-height: 420px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
  animation: slideDown 0.2s ease;
}

.notification-dropdown-header {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
}
.notification-dropdown-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.notification-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notification-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  gap: 10px;
}
.notification-item.unread {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.2);
}
.notification-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.notification-icon {
  font-size: 1.2rem;
  line-height: 1;
}
.notification-content {
  flex: 1;
}
.notification-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.notification-message {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}
.notification-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   App Body (Sidebar + Chat Area)
   ========================================================================== */
.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-glass);
}
.tab-btn {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.sidebar-actions {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-glass);
}
.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}
.search-box input {
  padding-left: 30px;
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

/* Conversation List */
.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}
.conv-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
.conv-item.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
}

.conv-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}
.conv-avatar.group {
  background: linear-gradient(135deg, #3b82f6 0%, #2dd4bf 100%);
  color: white;
}
.conv-avatar.user {
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  color: white;
}

.conv-meta {
  flex: 1;
  min-width: 0;
}
.conv-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}
.conv-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.conv-snippet {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Chat Main Area
   ========================================================================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(11, 15, 25, 0.4);
  position: relative;
  overflow: hidden;
}

/* Empty State */
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  max-width: 480px;
  margin: 0 auto;
}
.empty-illustration {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.6;
}
.chat-empty-state h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.chat-empty-state p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Active Chat Window */
.chat-active-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
}
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
}
.chat-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.chat-header-actions {
  display: flex;
  gap: 8px;
}

/* Chat Messages Stream */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.date-divider {
  text-align: center;
  margin: 12px 0;
  position: relative;
}
.date-divider span {
  background: var(--bg-tertiary);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Message Bubble */
.message-bubble {
  max-width: 68%;
  display: flex;
  flex-direction: column;
  animation: messageIn 0.2s ease;
}

.message-bubble.incoming {
  align-self: flex-start;
}
.message-bubble.incoming .bubble-content {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message-bubble.outgoing {
  align-self: flex-end;
}
.message-bubble.outgoing .bubble-content {
  background: var(--bubble-gradient);
  color: var(--text-inverse);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.25);
  border-bottom-right-radius: 4px;
}

.bubble-sender {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
  padding-left: 2px;
}

.bubble-content {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
}
.bubble-time {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.55);
}
.bubble-status {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  letter-spacing: -2.5px;
  margin-left: 3px;
  user-select: none;
}
.bubble-status.status-sent {
  color: #94a3b8; /* Ceklis 1 abu-abu (terkirim) */
}
.bubble-status.status-delivered {
  color: #94a3b8; /* Ceklis 2 abu-abu (tersampaikan) */
}
.bubble-status.status-read {
  color: #38bdf8; /* Ceklis 2 biru ala WhatsApp (dibaca) */
}

.subgroup-item.active {
  background: rgba(99, 102, 241, 0.18);
  border-left: 3px solid var(--primary);
}

/* Chat Footer (Input) */
.chat-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-glass);
}
.message-form {
  display: flex;
  gap: 12px;
  align-items: center;
}
.message-form input {
  flex: 1;
  padding: 12px 18px;
  font-size: 0.92rem;
  border-radius: var(--radius-full);
  background: rgba(17, 24, 39, 0.9);
}
.btn-send {
  padding: 12px 22px;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal-dialog {
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 90vh;
}
.modal-dialog.modal-lg {
  max-width: 820px;
}

.modal-header {
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
}
.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}
.subtitle-sm {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border-glass);
}

/* Admin Table */
.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.table-responsive {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-glass);
}
.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}
.data-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}
.badge-status {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}
.badge-deleted {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 380px;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  animation: slideInRight 0.3s ease;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.toast.toast-success {
  border-left-color: var(--success);
}
.toast.toast-error {
  border-left-color: var(--danger);
}
.toast.toast-notification {
  border-left-color: #8b5cf6;
}

.toast-icon {
  font-size: 1.25rem;
  line-height: 1;
}
.toast-body {
  flex: 1;
}
.toast-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.toast-message {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

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

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: flex;
  }
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    background: var(--bg-secondary);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-panel);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .message-bubble {
    max-width: 85%;
  }
  .user-info-text {
    display: none;
  }
}

/* ==========================================================================
   Right Info Drawer (Detail Percakapan & Grup)
   ========================================================================== */
.info-drawer {
  width: 360px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  z-index: 25;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
}

.info-drawer.hidden {
  display: none !important;
}

.info-drawer-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.info-drawer-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.info-drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Custom Scrollbar for Drawer Content */
.info-drawer-content::-webkit-scrollbar {
  width: 5px;
}
.info-drawer-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
.info-drawer-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Group Hero Card inside Drawer */
.drawer-hero {
  text-align: center;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--border-glass);
}
.drawer-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
  margin: 0 auto 12px;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}
.drawer-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  word-break: break-word;
}
.drawer-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Drawer Section */
.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.drawer-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-desc-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
}

/* Member Items in Drawer */
.drawer-member-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.drawer-member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  transition: var(--transition);
}
.drawer-member-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
.drawer-member-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.drawer-member-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}
.drawer-member-names {
  min-width: 0;
  flex: 1;
}
.drawer-member-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.drawer-member-email {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge-role-owner {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.3);
  font-weight: 700;
}
.badge-role-admin {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  font-weight: 700;
}
.badge-role-member {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-glass);
  font-weight: 500;
}

/* Join Request Item */
.drawer-request-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.2);
  gap: 8px;
}

/* Responsive Drawer on Small Screens */
@media (max-width: 900px) {
  .info-drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    z-index: 40;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.6);
  }
}
@media (max-width: 600px) {
  .info-drawer {
    width: 100%;
  }
}

/* ==========================================================================
   Announcement Readonly Banner (FR-COM-02)
   ========================================================================== */
.announcement-banner {
  padding: 10px 16px;
  background: rgba(234, 179, 8, 0.12);
  border-top: 1px solid rgba(234, 179, 8, 0.3);
  color: #facc15;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
}

/* ==========================================================================
   Voice Call WebRTC (FR-CALL-01 s/d FR-CALL-05)
   ========================================================================== */
.incoming-call-card {
  max-width: 320px;
  text-align: center;
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(99, 102, 241, 0.4);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.incoming-call-avatar-wrapper {
  position: relative;
  margin-bottom: 6px;
}
.incoming-call-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: white;
  position: relative;
  z-index: 2;
}
.incoming-call-pulse {
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.35);
  animation: callPulse 1.5s infinite;
  z-index: 1;
}
@keyframes callPulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 0.2; }
  100% { transform: scale(0.9); opacity: 0.8; }
}
.incoming-call-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}
.incoming-call-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.incoming-call-actions {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  width: 100%;
}
.btn-call-accept {
  flex: 1;
  background: #10b981;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-call-accept:hover {
  background: #059669;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}
.btn-call-reject {
  flex: 1;
  background: #ef4444;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-call-reject:hover {
  background: #dc2626;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* Active Call Floating Card */
.active-call-overlay {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  animation: slideDown 0.3s ease-out;
}
.active-call-card {
  width: 300px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.active-call-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.active-call-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: dotBlink 1.2s infinite ease-in-out;
}
@keyframes dotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.active-call-titles {
  flex: 1;
  min-width: 0;
}
.active-call-titles h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.active-call-status-text {
  font-size: 0.75rem;
  color: #10b981;
}
.active-call-participants-badge {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-full);
}
.active-call-timer {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}
.active-call-actions {
  display: flex;
  gap: 8px;
}
.active-call-actions button {
  flex: 1;
  justify-content: center;
}

/* ==========================================================================
   Communities (FR-COM-01 s/d FR-COM-05)
   ========================================================================== */
.community-item {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border-glass);
  transition: var(--transition);
}
.community-header-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
}
.community-header-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
.community-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: white;
  flex-shrink: 0;
}
.community-info {
  flex: 1;
  min-width: 0;
}
.community-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.community-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.community-subgroups-list {
  padding-left: 20px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
}
.subgroup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: var(--transition);
}
.subgroup-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.subgroup-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.badge-announcement {
  font-size: 0.65rem;
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.3);
  padding: 1px 5px;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   Notification Read/Unread Status Badges
   ========================================================================== */
.notification-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 5px;
}
.notif-status-badge {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1.2;
}
.notif-status-badge.badge-unread {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.notif-status-badge.badge-read {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   Community Hub Styles (FR-COM-01 s/d FR-COM-05)
   ========================================================================== */
.community-active-window {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg-primary);
}

.community-hub-header {
  padding: 20px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: rgba(30, 41, 59, 0.45);
  backdrop-filter: blur(12px);
  gap: 16px;
  flex-wrap: wrap;
}

.community-hub-profile {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 1;
  min-width: 260px;
}

.community-hub-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

.community-hub-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.community-hub-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.community-hub-title-row h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.community-hub-description {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0;
  max-width: 650px;
  line-height: 1.4;
}

.community-hub-stats {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.community-hub-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.community-hub-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.community-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.community-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.community-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.community-section-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 3px 0 0 0;
}

.community-card {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  transition: var(--transition);
}

.announcement-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-color: rgba(234, 179, 8, 0.35);
  background: rgba(234, 179, 8, 0.06);
  gap: 16px;
}

.announcement-card-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.announcement-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: rgba(234, 179, 8, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.community-subgroups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.subgroup-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: var(--transition);
}

.subgroup-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
}

.subgroup-card-top {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subgroup-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.subgroup-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.subgroup-card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.subgroup-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 10px;
  gap: 8px;
}

.community-filter-toggle {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
}

.filter-pill {
  flex: 1;
  text-align: center;
  padding: 5px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}

.filter-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.filter-pill:hover:not(.active) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}


