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

@font-face {
  font-family: 'Jarvis';
  src: url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Exo+2:wght@300;400;600;700&display=swap');
}

:root {
  --primary: #00a8ff;
  --secondary: #0097e6;
  --accent: #f5f6fa;
  --bg-dark: #0a0a1a;
  --bg-card: #12122a;
  --bg-input: #1a1a3e;
  --text: #e0e0ff;
  --text-dim: #8888aa;
  --glow: 0 0 20px rgba(0, 168, 255, 0.3);
  --glow-strong: 0 0 40px rgba(0, 168, 255, 0.5);
}

body {
  font-family: 'Exo 2', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.star {
  position: absolute;
  background: white;
  border-radius: 50%;
  animation: twinkle var(--duration) ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

/* Auth Screen */
#auth-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: var(--bg-dark);
}

.auth-container {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 40px;
  width: 420px;
  max-width: 90vw;
  border: 1px solid rgba(0, 168, 255, 0.2);
  box-shadow: var(--glow);
  position: relative;
  overflow: hidden;
}

.auth-container::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(transparent, rgba(0, 168, 255, 0.1), transparent 30%);
  animation: rotate 4s linear infinite;
}

@keyframes rotate {
  100% { transform: rotate(360deg); }
}

.auth-content {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border-radius: 16px;
  padding: 10px;
}

.logo {
  text-align: center;
  margin-bottom: 30px;
}

.logo-icon {
  font-size: 48px;
  margin-bottom: 10px;
  display: block;
}

.logo h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 28px;
  background: linear-gradient(135deg, #00a8ff, #00ff88);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 4px;
}

.logo p {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 5px;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid rgba(0, 168, 255, 0.2);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-family: 'Exo 2', sans-serif;
  transition: all 0.3s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(0, 168, 255, 0.2);
}

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  font-family: 'Exo 2', sans-serif;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  box-shadow: var(--glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-strong);
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-secondary:hover {
  background: rgba(0, 168, 255, 0.1);
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  color: var(--text-dim);
  font-size: 14px;
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.error-msg {
  background: rgba(255, 0, 0, 0.1);
  border: 1px solid rgba(255, 0, 0, 0.3);
  color: #ff4444;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 13px;
  display: none;
}

/* Main Chat */
#chat-screen {
  display: none;
  height: 100vh;
  flex-direction: column;
}

#chat-screen.active {
  display: flex;
}

.chat-header {
  background: rgba(18, 18, 42, 0.95);
  backdrop-filter: blur(10px);
  padding: 15px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 168, 255, 0.1);
  z-index: 10;
}

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

.chat-header .logo-small span {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
  background: linear-gradient(135deg, #00a8ff, #00ff88);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chat-header .user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.chat-header .user-info span {
  color: var(--text-dim);
  font-size: 14px;
}

.btn-logout {
  background: transparent;
  border: 1px solid rgba(255, 0, 0, 0.3);
  color: #ff4444;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Exo 2', sans-serif;
  transition: all 0.3s;
}

.btn-logout:hover {
  background: rgba(255, 0, 0, 0.1);
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Visualizer */
.visualizer-container {
  height: 200px;
  background: linear-gradient(180deg, rgba(0, 168, 255, 0.05), transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

#visualizer {
  width: 100%;
  height: 100%;
}

.visualizer-status {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.visualizer-status.speaking {
  color: var(--primary);
  animation: pulse-text 1s ease-in-out infinite;
}

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

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 30px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: rgba(0, 168, 255, 0.3);
  border-radius: 3px;
}

.message {
  max-width: 80%;
  padding: 15px 20px;
  border-radius: 15px;
  line-height: 1.6;
  font-size: 15px;
  animation: messageIn 0.3s ease;
}

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

.message.user {
  background: linear-gradient(135deg, rgba(0, 168, 255, 0.15), rgba(0, 168, 255, 0.05));
  border: 1px solid rgba(0, 168, 255, 0.2);
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

.message.jarvis {
  background: rgba(18, 18, 42, 0.8);
  border: 1px solid rgba(0, 255, 136, 0.15);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}

.message.jarvis .msg-label {
  font-size: 11px;
  color: #00ff88;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 5px;
  display: block;
}

.message.jarvis .msg-content {
  color: var(--text);
}

.input-container {
  background: rgba(18, 18, 42, 0.95);
  backdrop-filter: blur(10px);
  padding: 20px 30px;
  border-top: 1px solid rgba(0, 168, 255, 0.1);
  display: flex;
  gap: 15px;
  align-items: center;
}

.input-container input {
  flex: 1;
  padding: 14px 20px;
  background: var(--bg-input);
  border: 1px solid rgba(0, 168, 255, 0.2);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-family: 'Exo 2', sans-serif;
  transition: all 0.3s;
}

.input-container input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(0, 168, 255, 0.15);
}

.input-container input::placeholder {
  color: var(--text-dim);
}

.btn-mic, .btn-send {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  border: none;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-send {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  box-shadow: var(--glow);
}

.btn-send:hover {
  transform: scale(1.05);
  box-shadow: var(--glow-strong);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-mic {
  background: rgba(18, 18, 42, 0.8);
  border: 1px solid rgba(0, 168, 255, 0.3);
  color: var(--text-dim);
  border-radius: 50%;
}

.btn-mic:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 15px rgba(0, 168, 255, 0.2);
}

.btn-mic.recording {
  background: #ff2222;
  border-color: #ff2222;
  color: white;
  border-radius: 50%;
  animation: mic-pulse 1s ease-in-out infinite;
  box-shadow: 0 0 30px rgba(255, 34, 34, 0.5);
}

.btn-mic.processing {
  background: rgba(0, 168, 255, 0.15);
  border-color: var(--primary);
  color: var(--primary);
  border-radius: 50%;
  pointer-events: none;
}

@keyframes mic-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 34, 34, 0.4); }
  50% { transform: scale(1.1); box-shadow: 0 0 40px rgba(255, 34, 34, 0.7); }
}

.typing-indicator {
  align-self: flex-start;
  padding: 15px 25px;
  background: rgba(18, 18, 42, 0.8);
  border: 1px solid rgba(0, 255, 136, 0.15);
  border-radius: 15px;
  border-bottom-left-radius: 5px;
  display: none;
}

.typing-indicator.active {
  display: flex;
  gap: 5px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-10px); opacity: 1; }
}

/* Clear history button */
.btn-clear {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Exo 2', sans-serif;
  font-size: 12px;
  transition: all 0.3s;
}

.btn-clear:hover {
  border-color: rgba(255, 0, 0, 0.3);
  color: #ff4444;
}

.btn-admin {
  background: transparent;
  border: 1px solid rgba(0, 255, 136, 0.3);
  color: #00ff88;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Exo 2', sans-serif;
  font-size: 12px;
  transition: all 0.3s;
}

.btn-admin:hover {
  background: rgba(0, 255, 136, 0.1);
  border-color: #00ff88;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid rgba(0, 168, 255, 0.2);
  border-radius: 16px;
  width: 90%;
  max-width: 900px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--glow-strong);
}

.modal-header {
  padding: 20px 25px;
  border-bottom: 1px solid rgba(0, 168, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 18px;
  background: linear-gradient(135deg, #00ff88, #00a8ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  transition: color 0.3s;
}

.modal-close:hover {
  color: #ff4444;
}

.modal-body {
  padding: 20px 25px;
}

#admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#admin-table th {
  text-align: left;
  padding: 12px 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 11px;
  border-bottom: 1px solid rgba(0, 168, 255, 0.1);
}

#admin-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text);
}

#admin-table tr:hover td {
  background: rgba(0, 168, 255, 0.03);
}

.btn-delete-user {
  background: transparent;
  border: 1px solid rgba(255, 50, 50, 0.3);
  color: #ff4444;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Exo 2', sans-serif;
  font-size: 11px;
  transition: all 0.3s;
}

.btn-delete-user:hover {
  background: rgba(255, 50, 50, 0.1);
}

.role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.role-badge.admin {
  background: rgba(0, 255, 136, 0.15);
  color: #00ff88;
  border: 1px solid rgba(0, 255, 136, 0.3);
}

.role-badge.user {
  background: rgba(0, 168, 255, 0.15);
  color: var(--primary);
  border: 1px solid rgba(0, 168, 255, 0.3);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  vertical-align: middle;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 50, 50, 0.3);
  border-radius: 24px;
  transition: all 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #ff4444;
  border-radius: 50%;
  transition: all 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: rgba(0, 255, 136, 0.3);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #00ff88;
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.4;
  cursor: not-allowed;
}

.toggle-label {
  font-size: 11px;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.toggle-label.active { color: #00ff88; }
.toggle-label.inactive { color: #ff4444; }

.actions-cell {
  white-space: nowrap;
}

.btn-edit-user {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.3s;
}

.btn-edit-user:hover {
  background: rgba(0, 168, 255, 0.15);
}

.text-dim {
  color: var(--text-dim);
}

.modal-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid rgba(0, 168, 255, 0.2);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Exo 2', sans-serif;
  transition: all 0.3s;
}

.modal-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(0, 168, 255, 0.2);
}
