:root {
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  --panel-bg: rgba(30, 41, 59, 0.45);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-primary: #6366f1;
  --accent-hover: #4f46e5;
  --accent-danger: #ef4444;
  --accent-danger-hover: #dc2626;
  --badge-success: #10b981;
  --badge-warning: #f59e0b;
  --badge-danger: #ef4444;
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

/* Glassmorphism Panel base */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* LOGIN PANEL */
#login-container {
  width: 100%;
  max-width: 440px;
  padding: 40px;
  text-align: center;
  animation: fadeIn 0.6s ease;
}

#login-container h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  background: linear-gradient(to right, #a5b4fc, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#login-container p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.input-group {
  margin-bottom: 20px;
}

input, select {
  width: 100%;
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

select option {
  background: #0f172a;
  color: #ffffff;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent-primary);
  border: none;
  border-radius: 8px;
  color: white;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.error-msg {
  color: var(--accent-danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

/* MAIN DASHBOARD LAYOUT */
#dashboard-container {
  width: 100%;
  max-width: 1200px;
  min-height: 90vh;
  margin: 40px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.6s ease;
}

body:has(#dashboard-container[style*="display: none"]) {
  /* keep centring for login */
}
body:has(#dashboard-container:not([style*="display: none"])) {
  display: block; /* scrollable dashboard */
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  width: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo h1 {
  font-size: 20px;
  font-weight: 600;
}

.main-content {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.right-panel {
  flex: 2.2;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.status-card, .qr-card, .add-bridge-card, .mappings-card {
  padding: 24px;
}

h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 18px;
  color: #c7d2fe;
}

/* STATUS Badges */
.status-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: capitalize;
}

.badge-connected {
  background: rgba(16, 185, 129, 0.15);
  color: var(--badge-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-disconnected {
  background: rgba(239, 68, 68, 0.15);
  color: var(--badge-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-awaiting_qr {
  background: rgba(245, 158, 11, 0.15);
  color: var(--badge-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
  animation: pulse 1.5s infinite alternate;
}

/* QR Code */
.qr-card {
  text-align: center;
}

.qr-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.qr-container {
  background: white;
  padding: 16px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 16px;
}

.qr-container img {
  display: block;
  width: 200px;
  height: 200px;
}

.scan-notice {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
}

/* Forms */
.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  flex: 1;
}

.add-bridge-card button {
  margin-top: 8px;
}

/* Active Bridges List */
.mappings-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 40px 0;
}

.mapping-item {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.2s, background 0.2s;
}

.mapping-item:hover {
  transform: translateY(-2px);
  background: rgba(15, 23, 42, 0.6);
}

.mapping-info h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.mapping-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-danger {
  padding: 8px 12px;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 6px;
  color: var(--accent-danger);
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Keyframes */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* Responsive */
@media (max-width: 900px) {
  .main-content {
    flex-direction: column;
  }
  .left-panel, .right-panel {
    width: 100%;
  }
}

/* Joined Groups Styling */
.groups-card {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
}

.groups-card h3 {
  margin-bottom: 4px;
}

.section-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.groups-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.groups-list::-webkit-scrollbar {
  width: 6px;
}

.groups-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.groups-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.groups-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.group-list-item {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.group-list-item:hover {
  background: rgba(15, 23, 42, 0.6);
}

.group-list-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  text-align: left;
}

.group-list-subject {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.group-list-jid {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-small {
  padding: 6px 10px;
  font-size: 11px;
  border-radius: 4px;
  min-width: 55px;
}

.loading-state {
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 20px 0;
}

/* INSTRUCTIONS PANEL */
.instructions-card {
  padding: 28px;
  margin-top: 28px;
  background: rgba(15, 23, 42, 0.35);
}

.instructions-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: #a5b4fc;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
}

.instructions-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.instruction-step {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
}

.instruction-step:hover {
  background: rgba(30, 41, 59, 0.3);
  border-color: rgba(99, 102, 241, 0.25);
  transform: translateY(-2px);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-header strong {
  font-size: 15px;
  color: #f8fafc;
  font-weight: 600;
}

.step-num {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.step-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-details p {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

.step-example {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.25);
  border-left: 3px solid #818cf8;
  border-radius: 0 6px 6px 0;
}

.example-label {
  font-size: 11px;
  font-weight: 600;
  color: #a5b4fc;
  text-transform: uppercase;
}

.step-options {
  list-style: none;
  padding: 0;
  margin: 4px 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-options li {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.option-header {
  display: flex;
  align-items: center;
}

.option-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.option-badge.recommended {
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.step-list {
  margin: 4px 0 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-list li {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.step-list li::marker {
  color: #a5b4fc;
  font-weight: 600;
}

.step-details code {
  background: rgba(15, 23, 42, 0.7);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  color: #818cf8;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

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

