/* ============================================
   TASKFLOW — Industrial Dark Theme
   Font: Syne (display) + DM Sans (body)
   Palette: Deep charcoal, electric amber, off-white
   ============================================ */

:root {
  --bg-base: #0e0e0f;
  --bg-surface: #161618;
  --bg-raised: #1e1e21;
  --bg-hover: #252529;
  --border: #2a2a2e;
  --border-light: #333338;

  --accent: #f5a623;
  --accent-dim: #b87a1a;
  --accent-glow: rgba(245, 166, 35, 0.15);

  --text-primary: #f0ede8;
  --text-secondary: #8a8790;
  --text-muted: #555358;

  --status-todo: #4a90d9;
  --status-progress: #f5a623;
  --status-done: #4caf7d;
  --status-overdue: #e05c5c;

  --priority-high: #e05c5c;
  --priority-medium: #f5a623;
  --priority-low: #4a90d9;

  --sidebar-w: 220px;
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ——— SCREENS ——— */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

/* ——— AUTH ——— */
#auth-screen {
  align-items: center;
  justify-content: center;
  position: relative;
}

.auth-bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(245,166,35,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.auth-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.4;
  pointer-events: none;
}

.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 100%;
  max-width: 420px;
  padding: 24px;
  position: relative;
  z-index: 1;
  animation: fadeUp 0.5s ease both;
}

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

.auth-brand {
  text-align: center;
}

.brand-icon {
  font-size: 40px;
  color: var(--accent);
  line-height: 1;
  display: block;
  margin-bottom: 8px;
  animation: spin 12s linear infinite;
}

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

.brand-name {
  font-family: 'Syne', sans-serif;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.brand-tagline {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}

.auth-tabs {
  display: flex;
  background: var(--bg-raised);
  border-radius: 6px;
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--accent);
  color: #000;
}

.auth-form { display: none; }
.auth-form.active { display: block; }

/* ——— FORMS ——— */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
}

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

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a8790' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

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

.form-error {
  background: rgba(224,92,92,0.1);
  border: 1px solid rgba(224,92,92,0.3);
  border-radius: var(--radius);
  color: #e05c5c;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.form-error.hidden { display: none; }

/* ——— BUTTONS ——— */
.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}

.btn-primary:hover { background: #f0b845; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  padding: 10px 20px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}

.btn-sm {
  padding: 5px 12px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  margin-bottom: 4px;
  display: block;
  transition: color 0.2s;
}
.btn-back:hover { color: var(--text-primary); }

/* ——— APP LAYOUT ——— */
#app-screen {
  display: none;
  flex-direction: row;
  min-height: 100vh;
}

#app-screen.active { display: flex; }

/* ——— SIDEBAR ——— */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.brand-icon-sm {
  color: var(--accent);
  font-size: 22px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

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

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-left: 2px solid var(--accent);
}

.nav-icon { font-size: 14px; width: 18px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-info { display: flex; align-items: center; gap: 10px; min-width: 0; }

.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  color: #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  padding: 6px 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.logout-btn:hover {
  border-color: var(--status-overdue);
  color: var(--status-overdue);
}

/* ——— MAIN CONTENT ——— */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  max-width: calc(100vw - var(--sidebar-w));
  overflow-x: hidden;
}

.view { display: none; animation: fadeIn 0.25s ease both; }
.view.active { display: block; }

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

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.view-header h2 {
  font-family: 'Syne', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.view-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.view-header .btn-primary {
  width: auto;
  padding: 10px 18px;
  flex-shrink: 0;
}

/* ——— STATS GRID ——— */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 36px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--text-muted);
}

.stat-card.todo::before { background: var(--status-todo); }
.stat-card.progress::before { background: var(--status-progress); }
.stat-card.done::before { background: var(--status-done); }
.stat-card.overdue::before { background: var(--status-overdue); }

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

/* ——— SECTION TITLE ——— */
.section-title {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ——— TASK LIST ——— */
.task-list { display: flex; flex-direction: column; gap: 8px; }

.task-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.15s;
  cursor: pointer;
}

.task-card:hover {
  border-color: var(--border-light);
  background: var(--bg-raised);
  transform: translateX(2px);
}

.task-card.overdue {
  border-left: 3px solid var(--status-overdue);
}

.task-priority-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.task-priority-dot.high { background: var(--priority-high); }
.task-priority-dot.medium { background: var(--priority-medium); }
.task-priority-dot.low { background: var(--priority-low); }

.task-main { flex: 1; min-width: 0; }

.task-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  gap: 10px;
}

.task-badge {
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-todo { background: rgba(74,144,217,0.15); color: var(--status-todo); }
.badge-in_progress { background: rgba(245,166,35,0.15); color: var(--status-progress); }
.badge-done { background: rgba(76,175,125,0.15); color: var(--status-done); }
.badge-overdue { background: rgba(224,92,92,0.15); color: var(--status-overdue); }

.task-actions { display: flex; gap: 6px; }

.task-action-btn {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.task-action-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-glow);
}

.task-action-btn.danger:hover {
  border-color: var(--status-overdue);
  color: var(--status-overdue);
  background: rgba(224,92,92,0.08);
}

/* ——— PROJECTS GRID ——— */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.project-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 0;
  background: var(--accent-glow);
  transition: height 0.2s;
}

.project-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}

.project-card:hover::after { height: 3px; bottom: 0; top: auto; left: 0; right: 0; }

.project-card-name {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

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

.project-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.project-task-count {
  background: var(--bg-raised);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}

/* ——— PROJECT MEMBERS BAR ——— */
.project-members-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.members-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#project-members-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.member-chip {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ——— FILTER BAR ——— */
.filter-bar {
  display: flex;
  gap: 8px;
}

.filter-bar select {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 32px 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a8790' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.2s;
}

.filter-bar select:focus { border-color: var(--accent); }

/* ——— USERS TABLE ——— */
.users-table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.users-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
}

.users-table tr:last-child td { border-bottom: none; }
.users-table tbody tr:hover { background: var(--bg-raised); }

.role-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.role-badge.admin { background: rgba(245,166,35,0.15); color: var(--accent); }
.role-badge.member { background: rgba(74,144,217,0.15); color: var(--status-todo); }

/* ——— MODALS ——— */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease both;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  animation: slideUp 0.25s ease both;
}

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

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

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

.modal-header h3 {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
}

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

.modal-task-name {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 18px;
  padding: 10px 12px;
  background: var(--bg-raised);
  border-radius: 6px;
}

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

.modal-actions .btn-primary { width: auto; }

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

.empty-state-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-text { font-size: 14px; }

/* ——— TOAST ——— */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-primary);
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: slideInRight 0.3s ease;
}

.toast.hidden { display: none; }
.toast.success { border-left: 3px solid var(--status-done); }
.toast.error { border-left: 3px solid var(--status-overdue); }

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

/* ——— HIDDEN UTIL ——— */
.hidden { display: none !important; }

/* ——— SCROLLBAR ——— */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ——— RESPONSIVE ——— */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 60px; }
  .sidebar-brand span:last-child,
  .nav-item span:not(.nav-icon),
  .user-details,
  .logout-btn { display: none; }
  .main-content { margin-left: 60px; padding: 20px 16px; }
  .projects-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
