/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --text: #2d3748;
  --text-secondary: #718096;
  --accent: #8b7fc7;
  --accent-light: #e8e4f0;
  --accent-hover: #7a6db8;
  --border: #e8e4f0;
  --success: #48bb78;
  --warning: #ed8936;
  --danger: #fc8181;
  --danger-solid: #e53e3e;
  --info: #63b3ed;
  --sidebar-bg: #2d3748;
  --sidebar-text: #cbd5e0;
  --sidebar-active: #8b7fc7;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #1a202c;
  --bg-card: #2d3748;
  --text: #e2e8f0;
  --text-secondary: #a0aec0;
  --border: #4a5568;
  --sidebar-bg: #171923;
  --shadow: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* === Loading === */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 32px;
  gap: 16px;
  color: var(--text-secondary);
}

.loading-screen.hidden { display: none; }

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* === Layout === */
.app {
  display: flex;
  min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.logo-text {
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name { font-weight: 600; font-size: 13px; color: #fff; }
.user-role { font-size: 12px; color: var(--sidebar-text); }

/* === Main === */
.main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: border-color var(--transition);
}

.search-box:focus-within { border-color: var(--accent); }

.search-box input {
  border: none;
  background: none;
  outline: none;
  font-size: 14px;
  color: var(--text);
  width: 200px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-sm { padding: 5px 12px; font-size: 12px; }

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

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

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

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: var(--danger-solid);
  color: white;
}

.btn-danger:hover {
  background: #c53030;
  transform: translateY(-1px);
}

/* === Views === */
.view {
  display: none;
  padding: 32px;
  flex: 1;
}

.view.active { display: block; }

/* === Stats Grid === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue { background: #ebf4ff; color: #4299e1; }
.stat-icon.green { background: #f0fff4; color: #48bb78; }
.stat-icon.purple { background: var(--accent-light); color: var(--accent); }
.stat-icon.orange { background: #fffaf0; color: #ed8936; }

[data-theme="dark"] .stat-icon.blue { background: rgba(66,153,225,0.15); }
[data-theme="dark"] .stat-icon.green { background: rgba(72,187,120,0.15); }
[data-theme="dark"] .stat-icon.purple { background: rgba(139,127,199,0.15); }
[data-theme="dark"] .stat-icon.orange { background: rgba(237,137,54,0.15); }

.stat-content { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-secondary); }

/* === Cards === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.card-header h3 { font-size: 15px; font-weight: 600; }

.link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.link:hover { text-decoration: underline; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dashboard-grid .full-width {
  grid-column: 1 / -1;
}

/* === Task List (Dashboard) === */
.task-list {
  padding: 8px 0;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  transition: background var(--transition);
  cursor: pointer;
}

.task-row:hover { background: var(--bg); }

.task-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.task-check:hover { border-color: var(--accent); }

.task-check.checked {
  background: var(--success);
  border-color: var(--success);
}

.task-check.checked::after {
  content: '✓';
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.task-info { flex: 1; min-width: 0; }
.task-title {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-title.completed {
  text-decoration: line-through;
  color: var(--text-secondary);
}

.task-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.deadline-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.deadline-badge.overdue {
  background: #fff5f5;
  border-color: var(--danger);
  color: var(--danger-solid);
}

[data-theme="dark"] .deadline-badge.overdue {
  background: rgba(229,62,62,0.15);
}

.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-low { background: #f0fff4; color: #38a169; }
.badge-medium { background: #fffaf0; color: #dd6b20; }
.badge-high { background: #fff5f5; color: #e53e3e; }

[data-theme="dark"] .badge-low { background: rgba(56,161,105,0.15); }
[data-theme="dark"] .badge-medium { background: rgba(221,107,32,0.15); }
[data-theme="dark"] .badge-high { background: rgba(229,62,62,0.15); }

/* === Progress List === */
.progress-list { padding: 16px 22px; }

.progress-item {
  margin-bottom: 20px;
}

.progress-item:last-child { margin-bottom: 0; }

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
}

.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.progress-fill.design { background: #8b7fc7; }
.progress-fill.development { background: #4299e1; }
.progress-fill.marketing { background: #48bb78; }
.progress-fill.research { background: #ed8936; }

/* === Activity Feed === */
.activity-feed {
  padding: 16px 22px;
  max-height: 300px;
  overflow-y: auto;
}

.activity-feed.full {
  max-height: none;
  padding: 8px 0;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 22px;
  align-items: flex-start;
  transition: background var(--transition);
}

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

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--accent-light);
}

.activity-icon.created { background: #f0fff4; }
.activity-icon.status { background: #ebf4ff; }
.activity-icon.edited { background: #fffaf0; }
.activity-icon.deleted { background: #fff5f5; }

.activity-content { flex: 1; }
.activity-text { font-size: 13px; line-height: 1.5; }
.activity-text strong { font-weight: 600; }
.activity-time { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.empty-state {
  padding: 40px 22px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* === Search Results === */
.search-results {
  margin-bottom: 20px;
}

.search-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.search-results-header h3 { font-size: 15px; font-weight: 600; }

.search-results-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg); }

.search-result-info { flex: 1; }
.search-result-title { font-weight: 600; font-size: 14px; }
.search-result-meta { font-size: 12px; color: var(--text-secondary); }

/* === Kanban === */
.tasks-toolbar {
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  gap: 8px;
}

.filter-btn {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.kanban {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.kanban-col {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 400px;
}

[data-theme="dark"] .kanban-col {
  background: rgba(0,0,0,0.15);
}

.kanban-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.kanban-header h4 { flex: 1; font-size: 14px; font-weight: 600; }

.kanban-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.kanban-dot.todo { background: var(--info); }
.kanban-dot.progress { background: var(--warning); }
.kanban-dot.done { background: var(--success); }

.kanban-count {
  background: var(--border);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all var(--transition);
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.kanban-card-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.kanban-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kanban-card-deadline {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kanban-card-deadline.overdue { color: var(--danger-solid); font-weight: 600; }

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

.kanban-card-assignee {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.mini-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
}

.kanban-card-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
}

.kanban-card:hover .kanban-card-actions { opacity: 1; }

.card-action {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-size: 16px;
}

.card-action:hover { background: var(--bg); color: var(--accent); }
.card-action.delete:hover { color: var(--danger-solid); background: #fff5f5; }

[data-theme="dark"] .card-action.delete:hover { background: rgba(229,62,62,0.15); }

.kanban-card-badges {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

/* === Team === */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.team-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.team-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.team-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 auto 14px;
}

.team-name { font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.team-role { color: var(--text-secondary); font-size: 13px; margin-bottom: 16px; }

.team-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.team-stat { text-align: center; }
.team-stat-value { font-weight: 700; font-size: 18px; display: block; }
.team-stat-label { font-size: 11px; color: var(--text-secondary); }

/* === Settings === */
.settings-form {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-weight: 600; font-size: 13px; color: var(--text-secondary); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition);
  outline: none;
}

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

textarea.input { resize: vertical; }

.theme-options { display: flex; gap: 8px; }

.theme-btn {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition);
  color: var(--text);
}

.theme-btn.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.theme-btn:hover { border-color: var(--accent); }

.save-status {
  font-size: 13px;
  color: var(--success);
  min-height: 20px;
  transition: opacity var(--transition);
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s ease;
}

.modal-sm { max-width: 400px; }

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

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

.modal-header h3 { font-size: 17px; }

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

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

.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 18px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}

/* === Toast === */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  background: var(--sidebar-bg);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

/* === Responsive === */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .header { padding: 12px 16px; }
  .view { padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .search-box { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .page-title { font-size: 18px; }
}

/* === Animations === */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-card, .kanban-card, .team-card, .card {
  animation: fadeInUp 0.4s ease both;
}

.stat-card:nth-child(2), .kanban-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3), .kanban-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4), .kanban-card:nth-child(4) { animation-delay: 0.15s; }