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

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #3b82f6;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* === Auth === */
.auth-container {
  max-width: 400px;
  margin: 10vh auto;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-header h1 {
  font-size: 28px;
  color: var(--primary);
}

.auth-header p {
  color: var(--text-muted);
  margin-top: 6px;
}

.logo-icon { font-size: 1.1em; }

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.auth-tabs .tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  font-size: 15px;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: .2s;
}

.auth-tabs .tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* === Forms === */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color .2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

textarea { resize: vertical; min-height: 80px; }

.error-msg {
  background: #fef2f2;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 12px;
}

/* === Buttons === */
.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: .15s;
  white-space: nowrap;
}

.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: .9; }
.btn-outline { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; padding: 12px; font-size: 15px; }

/* === Top Bar === */
.topbar {
  display: flex;
  align-items: center;
  background: var(--surface);
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  gap: 16px;
}

.topbar-left h1 {
  font-size: 18px;
  color: var(--primary);
  white-space: nowrap;
}

.topbar-center { flex: 1; display: flex; justify-content: center; }

.search-box {
  display: flex;
  gap: 6px;
  max-width: 400px;
  width: 100%;
}

.search-box input {
  flex: 1;
  padding: 6px 12px;
  font-size: 13px;
}

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

.user-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.ws-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
}

.ws-indicator.connected { background: var(--success); }
.ws-indicator.connecting { background: var(--warning); }
.ws-indicator.disconnected { background: var(--danger); }

/* === Layout === */
.main-layout {
  display: flex;
  height: calc(100vh - 56px);
}

/* === Sidebar === */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 16px 0;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-section { margin-bottom: 8px; }

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
}

.sidebar-header h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
}

.nav-list { list-style: none; }

.nav-list li {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: .15s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-list li:hover { background: rgba(255,255,255,.07); }
.nav-list li.active { background: var(--sidebar-active); color: #fff; border-radius: 0; }

/* === Content Area === */
.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.panel-header h2 { font-size: 20px; }

.panel-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.panel-actions { display: flex; gap: 8px; align-items: center; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state h2 { color: var(--text); margin-bottom: 8px; }

/* === Badge === */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-admin { background: #dbeafe; color: #1d4ed8; }
.badge-member { background: #f1f5f9; color: #475569; }

/* === Members === */
.member-list { list-style: none; }

.member-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.member-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.member-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-remove-spacer {
  display: inline-block;
  width: 32px;
  flex-shrink: 0;
}

.member-remove-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  line-height: 1;
  font-size: 18px;
  font-weight: 700;
  color: var(--danger);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.member-remove-btn:hover {
  background: #fef2f2;
  border-color: var(--danger);
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.inline-form input, .inline-form select { width: auto; flex: 1; }

/* === Board === */
.board-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.board-column {
  background: var(--bg);
  border-radius: var(--radius);
  min-height: 200px;
}

.column-header {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.todo-header { background: #e0e7ff; color: #3730a3; }
.progress-header { background: #fef3c7; color: #92400e; }
.done-header { background: #dcfce7; color: #166534; }

.column-cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; }

.task-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow .15s;
  border-left: 3px solid transparent;
}

.task-card:hover { box-shadow: var(--shadow-lg); }
.task-card.priority-high { border-left-color: var(--danger); }
.task-card.priority-medium { border-left-color: var(--warning); }
.task-card.priority-low { border-left-color: var(--success); }

.task-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.task-card-title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.task-card-head-actions {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  margin: -2px -2px 0 0;
}

.task-card-edit-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.task-card-edit-btn:hover {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.task-card-edit-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.task-card-delete-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.task-card-delete-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.task-card-delete-btn:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.task-card-meta {
  display: flex;
  justify-content: flex-end;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.task-card-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.task-card-actions .btn { padding: 3px 8px; font-size: 11px; }

/* === Search Results === */
.search-result-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.search-result-item:hover { background: var(--bg); }
.search-result-item h4 { font-size: 14px; margin-bottom: 4px; }
.search-result-item p { font-size: 12px; color: var(--text-muted); }

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 28px;
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal h3 {
  margin-bottom: 20px;
  font-size: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.text-muted { color: var(--text-muted); }
.section { margin-top: 20px; }
.section h3 { font-size: 15px; margin-bottom: 10px; }

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .board-columns { grid-template-columns: 1fr; }
  .topbar-center { display: none; }
}
