/* ============================================================
   World of Woki — Dashboard Styles
   Dark theme with glassmorphism, fluid layout, premium feel.
   ============================================================ */

/* ---- CSS Custom Properties ---- */

:root {
  /* Background & Surface */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-surface: rgba(17, 24, 39, 0.7);
  --bg-surface-hover: rgba(30, 41, 59, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-border: rgba(255, 255, 255, 0.06);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  /* Accent Colors */
  --accent-primary: #6366f1;
  --accent-primary-glow: rgba(99, 102, 241, 0.3);
  --accent-success: #22c55e;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-info: #06b6d4;

  /* Status Colors */
  --status-backlog: #64748b;
  --status-todo: #6366f1;
  --status-in-progress: #f59e0b;
  --status-review: #06b6d4;
  --status-done: #22c55e;
  --status-blocked: #ef4444;
  --status-cancelled: #475569;

  /* Priority Colors */
  --priority-low: #22c55e;
  --priority-medium: #f59e0b;
  --priority-high: #f97316;
  --priority-critical: #ef4444;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Borders & Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --border-subtle: 1px solid rgba(255, 255, 255, 0.06);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-primary-glow);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

/* ---- Reset & Base ---- */

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(6, 182, 212, 0.06) 0%, transparent 50%);
}

::selection {
  background: var(--accent-primary);
  color: white;
}

/* ---- Scrollbar ---- */

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

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

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

/* ---- Header ---- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  border-bottom: var(--border-subtle);
  height: 56px;
  position: relative;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-logo {
  font-size: 24px;
  animation: spin 8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.header-brand h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  background: var(--accent-primary-glow);
  padding: 2px 8px;
  border-radius: 99px;
}

.header-stats {
  display: flex;
  gap: var(--space-lg);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-count {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat[data-status="todo"] .stat-count { color: var(--status-todo); }
.stat[data-status="in_progress"] .stat-count { color: var(--status-in-progress); }
.stat[data-status="review"] .stat-count { color: var(--status-review); }
.stat[data-status="done"] .stat-count { color: var(--status-done); }

.header-connection {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 12px;
  color: var(--text-muted);
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-warning);
  transition: background var(--transition-normal);
}

.connection-dot.connected {
  background: var(--accent-success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.connection-dot.disconnected {
  background: var(--accent-danger);
}

/* ---- Main Layout ---- */

.app-main {
  display: grid;
  grid-template-columns: 1fr 400px;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ---- Panel ---- */

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: var(--border-subtle);
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 600;
}

/* ---- Task Board ---- */

.board {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  overflow-x: auto;
  flex: 1;
}

.board-column {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.column-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding-bottom: var(--space-sm);
  border-bottom: var(--border-subtle);
}

.column-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-backlog { background: var(--status-backlog); }
.dot-todo { background: var(--status-todo); }
.dot-in_progress { background: var(--status-in-progress); }
.dot-review { background: var(--status-review); }
.dot-done { background: var(--status-done); }

.column-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  overflow-y: auto;
  flex: 1;
  padding-right: var(--space-xs);
}

/* ---- Task Card ---- */

.task-card {
  background: var(--bg-glass);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.task-card:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.task-card-id {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.task-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  line-height: 1.4;
}

.task-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.task-card-priority {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
}

.priority-low { color: var(--priority-low); background: rgba(34, 197, 94, 0.1); }
.priority-medium { color: var(--priority-medium); background: rgba(245, 158, 11, 0.1); }
.priority-high { color: var(--priority-high); background: rgba(249, 115, 22, 0.1); }
.priority-critical { color: var(--priority-critical); background: rgba(239, 68, 68, 0.15); }

.task-card-assignee {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ---- Right Panel Tabs ---- */

.panel-chat {
  border-left: var(--border-subtle);
  background: var(--bg-surface);
}

.panel-tabs {
  display: flex;
  border-bottom: var(--border-subtle);
}

.tab {
  flex: 1;
  padding: var(--space-md);
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 2px solid transparent;
}

.tab:hover {
  color: var(--text-secondary);
  background: var(--bg-glass);
}

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

.tab-content {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
}

/* ---- Chat ---- */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.chat-msg {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  max-width: 95%;
  animation: fadeIn 200ms ease;
}

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

.chat-msg.system {
  background: var(--bg-glass);
  border: var(--border-subtle);
  color: var(--text-secondary);
  align-self: center;
  text-align: center;
  font-size: 12px;
}

.chat-msg.user {
  background: var(--accent-primary);
  color: white;
  align-self: flex-end;
  border-radius: var(--radius-md) var(--radius-md) var(--radius-sm) var(--radius-md);
}

.chat-msg.response {
  background: var(--bg-glass);
  border: var(--border-subtle);
  color: var(--text-primary);
  align-self: flex-start;
}

.chat-msg.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--accent-danger);
  align-self: flex-start;
}

.chat-msg code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
}

.chat-input {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-top: var(--border-subtle);
}

.chat-input input {
  flex: 1;
  background: var(--bg-glass);
  border: var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.chat-input input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary-glow);
}

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

/* ---- Activity Feed ---- */

.activity-feed {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.activity-item {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm);
  font-size: 12px;
  border-radius: var(--radius-sm);
  animation: fadeIn 200ms ease;
}

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

.activity-time {
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 11px;
}

.activity-actor {
  color: var(--accent-info);
  font-weight: 500;
  white-space: nowrap;
}

.activity-text {
  color: var(--text-secondary);
}

.activity-empty {
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-xl);
  font-size: 13px;
}

/* ---- File Browser ---- */

.file-browser {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-path {
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: var(--border-subtle);
  background: var(--bg-glass);
}

.file-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
}

.file-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.file-item-icon {
  font-size: 14px;
}

.file-item-name {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
}

.file-item-size {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: #5558e6;
  box-shadow: var(--shadow-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: var(--border-subtle);
}

.btn-ghost:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 12px;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* ---- Modal ---- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 200ms ease;
}

.modal-wide {
  width: 640px;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

/* ---- Forms ---- */

.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg-glass);
  border: var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary-glow);
}

.form-group textarea {
  resize: vertical;
  font-family: var(--font-sans);
}

.form-group select {
  cursor: pointer;
}

.form-group select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

/* ---- Task Detail ---- */

.detail-body {
  font-size: 13px;
  line-height: 1.6;
}

.detail-body .detail-field {
  margin-bottom: var(--space-md);
}

.detail-body .detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.detail-body .detail-value {
  color: var(--text-primary);
}

.detail-body .detail-history {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: var(--border-subtle);
}

.detail-body .history-item {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.detail-body .history-time {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.detail-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: var(--border-subtle);
}

/* ---- Status Badge ---- */

.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
}

.status-backlog { color: var(--status-backlog); background: rgba(100, 116, 139, 0.15); }
.status-todo { color: var(--status-todo); background: rgba(99, 102, 241, 0.15); }
.status-in_progress { color: var(--status-in-progress); background: rgba(245, 158, 11, 0.15); }
.status-review { color: var(--status-review); background: rgba(6, 182, 212, 0.15); }
.status-done { color: var(--status-done); background: rgba(34, 197, 94, 0.15); }
.status-blocked { color: var(--status-blocked); background: rgba(239, 68, 68, 0.15); }
.status-cancelled { color: var(--status-cancelled); background: rgba(71, 85, 105, 0.15); }

/* ---- Responsive & Mobile Optimization ---- */

.mobile-view-switch {
  display: none;
}

@media (max-width: 900px) {
  .app-header {
    flex-wrap: wrap;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
  }

  .header-brand h1 {
    font-size: 15px;
  }

  .header-badge {
    display: none;
  }

  .header-ai {
    display: none !important;
  }

  .header-stats {
    display: none;
  }

  .mobile-view-switch {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: var(--border-subtle);
    margin-left: auto;
  }

  .mobile-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .mobile-tab.active {
    background: var(--accent-primary);
    color: #ffffff;
    font-weight: 600;
  }

  .app-main {
    grid-template-columns: 1fr;
    height: calc(100vh - 54px);
  }

  /* Default view on mobile is chat; can toggle to board */
  body[data-mobile-view="board"] .panel-chat {
    display: none;
  }

  body[data-mobile-view="board"] .panel-board {
    display: flex;
  }

  body:not([data-mobile-view="board"]) .panel-board {
    display: none;
  }

  body:not([data-mobile-view="board"]) .panel-chat {
    display: flex;
    flex: 1;
    height: 100%;
  }

  .chat-messages {
    max-height: calc(100vh - 170px);
  }

  .chat-input input {
    font-size: 15px; /* Prevent iOS safari auto-zoom */
  }
}
