/* Nova Portal - Styles
   ====================== */

:root {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1b26;
  --bg-tertiary: #24283b;
  --bg-hover: #2f3447;
  --text-primary: #c0caf5;
  --text-secondary: #565f89;
  --text-muted: #414868;
  --accent: #7aa2f7;
  --accent-hover: #89b4fa;
  --accent-soft: rgba(122, 162, 247, 0.1);
  --success: #9ece6a;
  --warning: #e0af68;
  --error: #f7768e;
  --border: #3b4261;
  --shadow: rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
}

/* ==================
   Sidebar
   ================== */

.sidebar {
  width: 220px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.logo-icon {
  font-size: 2rem;
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.nav-links {
  list-style: none;
  margin-top: 1.5rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

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

.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.status-indicator.online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-indicator.offline {
  background: var(--error);
}

/* ==================
   Main Content
   ================== */

.content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background: var(--bg-primary);
}

.view {
  display: none;
  animation: fadeIn 0.2s ease;
}

.view.active {
  display: block;
}

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

.view-header {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.view-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-right: auto;
}

.view-header .subtitle {
  width: 100%;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: -0.25rem;
}

/* ==================
   Buttons
   ================== */

.btn-primary {
  padding: 0.625rem 1.25rem;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-icon {
  padding: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.btn-icon:hover {
  opacity: 1;
}

.btn-icon-sm {
  padding: 0.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  opacity: 0;
  transition: opacity 0.2s;
}

/* ==================
   Chat View
   ================== */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.message {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  max-width: 85%;
}

.message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: var(--accent);
}

.message-body {
  display: flex;
  flex-direction: column;
}

.message.user .message-body {
  align-items: flex-end;
}

.message-content {
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  background: var(--bg-tertiary);
}

.message.user .message-content {
  background: var(--accent);
  color: var(--bg-primary);
}

.message-content p {
  margin: 0;
}

.message-content code {
  background: rgba(0, 0, 0, 0.2);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 0.875em;
}

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

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); }
  40% { transform: scale(1); }
}

.chat-input {
  display: flex;
  padding: 1rem;
  border-top: 1px solid var(--border);
  gap: 0.75rem;
  background: var(--bg-tertiary);
}

.chat-input input {
  flex: 1;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.2s;
}

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

.chat-input input::placeholder {
  color: var(--text-muted);
}

.chat-input button {
  padding: 0.875rem 1.25rem;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-input button:hover {
  background: var(--accent-hover);
}

.chat-input button svg {
  width: 20px;
  height: 20px;
}

/* ==================
   Dashboard
   ================== */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}

.card-status.online {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.card-status.offline {
  background: var(--error);
}

.card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.stat {
  flex: 1;
  min-width: 80px;
}

.stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dashboard-footer {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ==================
   Kanban Board
   ================== */

.kanban-board {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: calc(100vh - 200px);
}

.kanban-column {
  min-width: 320px;
  max-width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

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

.column-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.task-count {
  background: var(--bg-tertiary);
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.kanban-cards {
  flex: 1;
  min-height: 100px;
  transition: background 0.2s;
}

.kanban-cards.drag-over {
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}

.kanban-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.75rem;
  cursor: grab;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.kanban-card:hover .btn-icon-sm {
  opacity: 0.7;
}

.kanban-card:hover .btn-icon-sm:hover {
  opacity: 1;
}

.kanban-card.dragging {
  opacity: 0.5;
}

.kanban-card.priority-high {
  border-left: 3px solid var(--error);
}

.kanban-card.priority-medium {
  border-left: 3px solid var(--warning);
}

.kanban-card.priority-low {
  border-left: 3px solid var(--success);
}

.kanban-card .card-header {
  margin-bottom: 0.5rem;
}

.kanban-card h4 {
  font-size: 0.95rem;
  font-weight: 600;
  flex: 1;
}

.kanban-card .card-actions {
  display: flex;
  gap: 0.25rem;
}

.kanban-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.kanban-card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.card-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==================
   Notes
   ================== */

.notes-container {
  display: flex;
  gap: 1.25rem;
  height: calc(100vh - 180px);
}

.notes-sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-y: auto;
  flex-shrink: 0;
}

.notes-section {
  margin-bottom: 1.5rem;
}

.notes-section h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding: 0 0.5rem;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.note-item {
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.9rem;
}

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

.note-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.note-item.loading {
  color: var(--text-muted);
  font-style: italic;
}

.note-editor {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.editor-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

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

.note-editor textarea {
  flex: 1;
  padding: 1.25rem;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: none;
}

.note-editor textarea:focus {
  outline: none;
}

.note-editor textarea::placeholder {
  color: var(--text-muted);
}

/* ==================
   Modal
   ================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 1000;
}

.modal.open {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal.open .modal-content {
  transform: scale(1);
}

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem;
  border-top: 1px solid var(--border);
}

/* Form */
.form-group {
  padding: 0 1.25rem;
  margin-bottom: 1rem;
}

.form-group:first-of-type {
  margin-top: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  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-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

.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;
}

/* ==================
   Toast
   ================== */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.875rem 1.25rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s, transform 0.3s;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-error {
  border-color: var(--error);
  background: rgba(247, 118, 142, 0.1);
}

.toast-success {
  border-color: var(--success);
  background: rgba(158, 206, 106, 0.1);
}

/* ==================
   Scrollbar
   ================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==================
   Responsive
   ================== */

@media (max-width: 768px) {
  .sidebar {
    width: 64px;
    padding: 0.75rem;
  }
  
  .logo-text,
  .nav-link span:not(:first-child),
  .sidebar-footer span {
    display: none;
  }
  
  .logo {
    justify-content: center;
    padding: 0.75rem;
  }
  
  .nav-link {
    justify-content: center;
    padding: 0.75rem;
  }
  
  .sidebar-footer {
    justify-content: center;
  }
  
  .content {
    padding: 1rem;
  }
  
  .kanban-board {
    flex-direction: column;
  }
  
  .kanban-column {
    min-width: 100%;
    max-width: 100%;
  }
  
  .notes-container {
    flex-direction: column;
  }
  
  .notes-sidebar {
    width: 100%;
    height: auto;
    max-height: 200px;
  }
  
  .modal-content {
    margin: 1rem;
  }
}
