:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1e1e2e;
  --bg-hover: #2a2a3e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: #2d2d3f;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Auth Screen */
#auth-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 100%);
}

.auth-container {
  background: var(--bg-secondary);
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.auth-container h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.auth-tabs {
  display: flex;
  margin: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 0.75rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
  border-bottom: 2px solid transparent;
}

.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

#auth-form input {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
}

#auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

#auth-submit {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: var(--transition);
}

#auth-submit:hover {
  background: var(--accent-hover);
}

.error-message {
  color: var(--danger);
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

/* Main App Layout */
#main-app {
  display: flex;
  height: 100vh;
}

#sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  color: var(--accent);
}

#nav-menu {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.95rem;
  transition: var(--transition);
  text-align: right;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-hover);
  color: var(--accent);
  border-right: 3px solid var(--accent);
}

.nav-icon {
  margin-left: 0.75rem;
  font-size: 1.2rem;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

#page-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* Mobile Navigation */
#mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 0.5rem;
  z-index: 200;
}

.mobile-tabs {
  display: flex;
  justify-content: space-around;
}

.mobile-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: var(--transition);
}

.mobile-tab.active {
  color: var(--accent);
}

#mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 300;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.5rem;
  padding: 0.5rem;
  border-radius: 50%;
  cursor: pointer;
}

/* Chat Interface */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  position: relative;
}

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.message-content {
  word-wrap: break-word;
  line-height: 1.6;
}

.message-content pre {
  background: #0a0a0f;
  padding: 0.5rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.message-content code {
  font-family: 'Courier New', monospace;
  background: rgba(255,255,255,0.1);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.message-source {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.chat-input-container {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}

#chat-input {
  flex: 1;
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  resize: none;
}

#chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Buttons */
.btn-primary {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
}

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

.btn-secondary {
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0.5rem 1rem;
}

.btn-success {
  background: var(--success);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0.5rem 1rem;
}

.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: white;
  margin: 0.2rem;
}

/* Lists */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.list-item:hover {
  background: var(--bg-hover);
}

.item-info {
  flex: 1;
}

.item-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Forms */
.knowledge-form,
.settings-container {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-card);
  padding: 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.form-group {
  margin-bottom: 1rem;
}

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

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.95rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.stat-card h3 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.stat-card p {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--accent);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  color: white;
  font-weight: bold;
  animation: slideIn 0.3s ease;
}

.toast-info { background: var(--accent); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

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

/* Modal */
.modal-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

/* Team Chat */
.team-chat-container {
  display: flex;
  gap: 1rem;
  height: 70vh;
}

.chat-list {
  width: 250px;
  border-left: 1px solid var(--border);
  padding-left: 1rem;
}

.team-chat-messages {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
}

.team-chat-input {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.team-chat-input textarea {
  flex: 1;
  padding: 0.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  resize: none;
}

/* Responsive */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0;
    right: -260px;
    height: 100vh;
    transition: right 0.3s ease;
  }

  #sidebar.open {
    right: 0;
  }

  #mobile-nav {
    display: block;
  }

  #mobile-menu-toggle {
    display: block;
  }

  #main-content {
    margin-right: 0;
  }

  #page-container {
    padding-bottom: 4rem;
  }

  .form-row {
    flex-direction: column;
  }
}
