/* ============================================================
   Design Tokens
   ============================================================ */
:root {
  --sidebar-width: 260px;
  --sidebar-bg: #0f172a;
  --sidebar-border: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: #1e3a5f;
  --sidebar-active-text: #60a5fa;
  --sidebar-hover-bg: #1e293b;
  --sidebar-hover-text: #e2e8f0;
  --sidebar-label-color: #475569;

  --main-bg: #f1f5f9;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --priority-low: #6b7280;
  --priority-medium: #3b82f6;
  --priority-high: #f59e0b;
  --priority-urgent: #ef4444;

  --kanban-todo: #3b82f6;
  --kanban-overdue: #ef4444;
  --kanban-done: #10b981;

  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --t: 0.2s ease;
}

/* ============================================================
   Base
   ============================================================ */
body {
  background-color: var(--main-bg);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text-primary);
  overflow-x: hidden;
}

/* ============================================================
   App layout (authenticated)
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transition: transform var(--t);
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #f1f5f9;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.sidebar-brand:hover { color: #60a5fa; }

.sidebar-brand i {
  font-size: 1.3rem;
  color: #60a5fa;
}

.sidebar-nav {
  padding: 0.75rem 0.625rem;
  flex: 1;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-label-color);
  padding: 0.75rem 0.625rem 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--t), color var(--t);
  margin-bottom: 0.1rem;
}

.sidebar-link i {
  font-size: 1rem;
  width: 1.1rem;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-hover-text);
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.7rem;
  color: var(--sidebar-text);
  text-transform: capitalize;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
}

.sidebar-backdrop.show { display: block; }

/* ============================================================
   Main wrapper
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding: 1.5rem;
}

.mobile-header {
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.main-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
}

/* ============================================================
   Page header
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

/* ============================================================
   Cards & panels
   ============================================================ */
.card {
  border-color: var(--border-color);
  border-radius: var(--radius);
}

.form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t), transform var(--t);
}

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

.data-table {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

/* ============================================================
   Kanban board
   ============================================================ */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: start;
}

.kanban-column {
  background: #f8fafc;
  border-radius: var(--radius);
  padding: 0.875rem;
  border: 1px solid var(--border-color);
}

.kanban-column-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
  padding-bottom: 0.625rem;
  border-bottom: 2px solid var(--border-color);
}

.kanban-column-header h3 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 0;
  color: var(--text-primary);
}

.kanban-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-todo    { background: var(--kanban-todo); }
.dot-overdue { background: var(--kanban-overdue); }
.dot-done    { background: var(--kanban-done); }

.count-badge {
  background: var(--border-color);
  color: var(--text-secondary);
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  font-weight: 700;
  margin-left: auto;
}

.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

/* ============================================================
   Task cards
   ============================================================ */
.task-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border-color);
  border-left-width: 4px;
  text-decoration: none;
  color: var(--text-primary);
  display: block;
  transition: box-shadow var(--t), transform var(--t);
}

.task-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: var(--text-primary);
}

.task-card.priority-low    { border-left-color: var(--priority-low); }
.task-card.priority-medium { border-left-color: var(--priority-medium); }
.task-card.priority-high   { border-left-color: var(--priority-high); }
.task-card.priority-urgent { border-left-color: var(--priority-urgent); }

.task-card-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.375rem;
  line-height: 1.3;
}

.task-card-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-bottom: 0.375rem;
}

.task-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 0.375rem;
}

/* Task detail left-border variant */
.task-detail-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.75rem;
  border: 1px solid var(--border-color);
  border-left-width: 5px;
  box-shadow: var(--shadow-sm);
}

.border-left-priority-low    { border-left-color: var(--priority-low); }
.border-left-priority-medium { border-left-color: var(--priority-medium); }
.border-left-priority-high   { border-left-color: var(--priority-high); }
.border-left-priority-urgent { border-left-color: var(--priority-urgent); }

.meta-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.meta-value {
  font-size: 0.875rem;
  color: var(--text-primary);
}

/* ============================================================
   Priority badges
   ============================================================ */
.priority-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.priority-badge.low    { background: #f1f5f9; color: var(--priority-low); }
.priority-badge.medium { background: #eff6ff; color: var(--priority-medium); }
.priority-badge.high   { background: #fffbeb; color: var(--priority-high); }
.priority-badge.urgent { background: #fef2f2; color: var(--priority-urgent); }

/* ============================================================
   Role badges
   ============================================================ */
.role-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
}

.role-admin     { background: #fef3c7; color: #b45309; }
.role-manager   { background: #e0f2fe; color: #0369a1; }
.role-developer { background: #f0fdf4; color: #166534; }

/* ============================================================
   Empty states
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.25rem;
  margin-bottom: 0.625rem;
  display: block;
  opacity: 0.55;
}

.empty-state h5 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.empty-state p {
  font-size: 0.8rem;
  margin-bottom: 0.625rem;
}

/* ============================================================
   Filter panel
   ============================================================ */
.filter-panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

/* ============================================================
   Forms
   ============================================================ */
.form-control:focus, .form-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.18);
}

/* ============================================================
   Tables
   ============================================================ */
.table-hover tbody tr:hover {
  background-color: #f8fafc;
  transition: background-color var(--t);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn { transition: all var(--t); }

.btn-gradient-primary {
  background: linear-gradient(to right, #6a11cb, #2575fc);
  color: #fff;
  border: none;
}

.btn-gradient-primary:hover {
  background: linear-gradient(to right, #5a0eb4, #1c62e7);
  color: #fff;
}

/* ============================================================
   Public layout (unauthenticated pages)
   ============================================================ */
.public-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.public-layout main { flex: 1; }

/* ============================================================
   Hero (used on index)
   ============================================================ */
.hero-section {
  min-height: 55vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-attachment: fixed;
}

.overlay { z-index: 1; }
.hero-section .container { z-index: 2; }

/* ============================================================
   Mobile responsiveness
   ============================================================ */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .mobile-header { display: flex !important; }
  .main-content { padding: 1rem; }
  .kanban-board { grid-template-columns: 1fr; }
}

@media (min-width: 992px) {
  .mobile-header { display: none !important; }
}

/* ============================================================
   Counter animation (used on index)
   ============================================================ */
.counter { font-weight: bold; }

/* ============================================================
   Worker detail stat cards
   ============================================================ */
.stat-card .icon { transition: transform 0.3s ease; }
.stat-card:hover .icon { transform: rotate(5deg) scale(1.1); }
