@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-color: #0f172a;
  --surface-color: #1e293b;
  --primary-color: #10b981;
  --primary-hover: #059669;
  --danger-color: #ef4444;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
}

body.light-mode {
  --bg-color: #f1f5f9;
  --surface-color: #ffffff;
  --primary-color: #059669;
  --primary-hover: #047857;
  --danger-color: #dc2626;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  display: block;
  overflow-y: auto;
  min-height: 100%;
  min-height: 100dvh;
}

.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100%;
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-color);
}

.screen {
  width: 100%;
  padding: calc(2rem + env(safe-area-inset-top, 0px)) 2rem calc(4rem + env(safe-area-inset-bottom, 0px)) 2rem;
  display: none;
  /* Flow natural */
  flex-direction: column;
}

.screen.view-active {
  display: flex;
  animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Join Screen */
#join-screen {
  justify-content: flex-start;
  align-items: center;
  padding-top: calc(5rem + env(safe-area-inset-top, 0px));
}

.logo-container {
  position: relative;
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, var(--primary-color), #3b82f6);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
}

.icon-mic {
  font-size: 2.5rem;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logo-image {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--primary-color);
  animation: pulse 2s infinite ease-out;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2.5rem;
  text-align: center;
}

.form-group {
  width: 100%;
  margin-bottom: 1.5rem;
}

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

.form-group input {
  width: 100%;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--surface-color);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.btn-primary {
  width: 100%;
  padding: 1rem;
  border-radius: 12px;
  border: none;
  background: var(--primary-color);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background-color 0.2s;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

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

.error-msg {
  color: var(--danger-color);
  font-size: 0.85rem;
  margin-top: 1rem;
  text-align: center;
  min-height: 20px;
}

/* Call Screen */
#call-screen {
  justify-content: space-between;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-badge,
.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-color);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--glass-border);
}

#signal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.signal-online {
  background-color: var(--primary-color);
  box-shadow: 0 0 8px var(--primary-color);
}

.signal-offline {
  background-color: var(--danger-color);
  box-shadow: 0 0 10px var(--danger-color);
  animation: flashSignal 1s infinite;
}

@keyframes flashSignal {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.2;
  }
}

.status-badge {
  color: var(--primary-color);
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

.center-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.visualizer-container {
  position: relative;
  width: 150px;
  height: 150px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 2rem;
}

.core-circle {
  width: 100px;
  height: 100px;
  background: var(--surface-color);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.5rem;
  z-index: 10;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--primary-color);
  transition: border-color 0.3s;
}

.visualizer-container.muted .core-circle {
  border-color: var(--danger-color);
  filter: grayscale(1);
}

.wave {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--primary-color);
  opacity: 0;
}

.visualizer-container:not(.muted) .wave1 {
  animation: ripple 2s infinite linear;
}

.visualizer-container:not(.muted) .wave2 {
  animation: ripple 2s infinite linear;
  animation-delay: 1s;
}

@keyframes ripple {
  0% {
    transform: scale(0.6);
    opacity: 1;
  }

  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

#call-status {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.participants-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: color 0.2s;
}

.participants-info.actionable {
  cursor: pointer;
  padding: 0.5rem 1rem;
  background: var(--surface-color);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.participants-info.actionable:active {
  transform: scale(0.95);
}

.arrow-down {
  font-size: 0.6rem;
  transition: transform 0.3s;
}

.members-grid {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 0;
  margin-top: 1rem;
  width: 100%;
  max-width: 320px;
  background: transparent;
  padding: 0.5rem 0;
  border: none;
  scroll-snap-type: x mandatory;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.members-grid::-webkit-scrollbar {
  display: none;
}

.members-page {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, auto);
  gap: 0.5rem;
  flex: 0 0 100%;
  scroll-snap-align: start;
  box-sizing: border-box;
  padding: 0.2rem;
}

.member-item {
  background: var(--surface-color);
  padding: 0.5rem 0.3rem;
  border-radius: 50px; /* Solid Kapsul */
  font-size: 0.62rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.hidden {
  display: none !important;
}

.controls-panel {
  display: flex;
  justify-content: space-evenly;
  padding: 1rem 0;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.btn-control {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: none;
  background: var(--surface-color);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-control .icon {
  font-size: 1.5rem;
  margin-bottom: 0.2rem;
}

.btn-control .label {
  font-size: 0.65rem;
  font-weight: 500;
}

.btn-control.toggle-on {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary-color);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-control.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-control:active {
  transform: scale(0.9);
}

.btn-icon-small {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--surface-color);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
}

.btn-icon-small:active {
  transform: scale(0.9);
}

.btn-log {
  margin-top: 0.5rem;
  padding: 0.8rem 1.5rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--surface-color);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.btn-log:active {
  transform: scale(0.95);
  background: var(--primary-color);
  color: white;
}

/* Toast Notification Styles */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 90%;
  max-width: 350px;
  pointer-events: none;
}

.toast {
  background: var(--surface-color);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  border-left: 4px solid var(--primary-color);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  animation: slideDownIn 0.3s forwards, fadeOut 0.3s forwards 2.7s;
  pointer-events: auto;
}

.toast.success { border-left-color: var(--primary-color); }
.toast.danger { border-left-color: var(--danger-color); }
.toast.info { border-left-color: #3b82f6; }

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

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* UI Ruangan Terdekat */
.nearby-container {
  text-align: left;
  animation: slideDownIn 0.3s forwards;
}

.nearby-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nearby-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

.btn-nearby-room {
  background: var(--surface-color);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.5rem 0.8rem;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn-nearby-room:hover,
.btn-nearby-room:active {
  background: rgba(16, 185, 129, 0.12);
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-1px);
}

.nearby-empty {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 0.2rem 0;
}
