/* Design Tokens & Colors */
:root {
  --bg: #f8fafc;
  --bg-gradient: radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.03) 0%, transparent 50%),
                 radial-gradient(circle at 100% 100%, rgba(59, 130, 246, 0.03) 0%, transparent 50%);
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --panel-hover: #f1f5f9;
  --line: #e2e8f0;
  --line-focus: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #94a3b8;
  
  /* Primary & Accent Palette */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eeeffe;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  
  /* Shadows & Borders */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.03), 0 2px 4px -2px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
  --shadow-hover: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 10px 10px -6px rgba(15, 23, 42, 0.08);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

html {
  background: var(--bg);
  scroll-behavior: smooth;
  height: 100%;
}

body {
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* Typography */
h1, h2, h3, h4, .view-title, .nav, .stat strong, .pill, button {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 { font-size: 28px; font-weight: 800; color: var(--text); }
h2 { font-size: 22px; font-weight: 700; color: var(--text); }
h3 { font-size: 16px; font-weight: 700; color: var(--text); }
h4 { font-size: 15px; font-weight: 600; color: var(--text); }

/* Inputs and Forms */
input,
select,
textarea {
  font-family: inherit;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  min-height: 40px;
  padding: 8px 12px;
  outline: none;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

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

/* Buttons */
button {
  align-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  cursor: pointer;
  display: inline-flex;
  font-weight: 600;
  font-size: 13.5px;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

button.secondary:hover {
  background: var(--panel-soft);
  color: var(--text);
  border-color: var(--line-focus);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

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

button.danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

button.icon {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--text-secondary);
  min-height: 32px;
  padding: 0 10px;
}

button.icon:hover {
  background: var(--line);
  color: var(--text);
  box-shadow: none;
}

/* Shell Layout */
.hidden {
  display: none !important;
}

/* Auth Pages */
.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(400px, 100%);
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.logo-auth {
  height: 42px;
  width: auto;
  margin: 0 auto 16px auto;
  display: block;
}

.auth-panel p {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.divider {
  color: var(--muted);
  font-size: 12px;
  margin: 20px 0;
  text-align: center;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  margin: 0 12px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 16px;
}

.stack {
  display: grid;
  gap: 12px;
}

/* App Shell */
.app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  align-content: space-between;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: grid;
  gap: 24px;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  height: 28px;
  width: auto;
  margin-bottom: 8px;
  display: block;
}

#user-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  padding-left: 2px;
}

nav {
  display: grid;
  gap: 4px;
}

.nav {
  background: transparent;
  color: var(--text-secondary);
  justify-content: start;
  text-align: left;
  border-radius: var(--radius-sm);
  min-height: 38px;
  padding: 0 12px;
  box-shadow: none;
  font-size: 14px;
  transition: all 0.15s ease;
}

.nav:hover {
  background: var(--panel-soft);
  color: var(--text);
  box-shadow: none;
  transform: none;
}

.nav.active {
  background: var(--primary-light);
  color: var(--primary);
  box-shadow: none;
}

.nav.active:hover {
  background: var(--primary-light);
  color: var(--primary);
}

#logout {
  width: 100%;
}

/* Workspace Content Area */
.workspace {
  min-width: 0;
  padding: 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* Topbar Header */
.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

.topbar p {
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Filters Component */
.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(200px, 1fr) repeat(3, 160px);
  margin-bottom: 24px;
  padding: 12px;
}

/* Task Board Columns */
.board {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
}

.column {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  min-height: 400px;
  padding: 16px;
}

.column h3 {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.column h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* Cards & Grid Items */
.task-card,
.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  padding: 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.task-card:hover,
.item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--line-focus);
}

.task-card p,
.item p {
  color: var(--text-secondary);
  font-size: 13.5px;
  margin-top: 8px;
  word-break: break-word;
}

.card-title {
  align-items: start;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.card-title h4,
.item h4 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

.card-title time {
  background: var(--accent-light);
  border-radius: 999px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  white-space: nowrap;
}

.meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

.meta span {
  display: inline-flex;
  align-items: center;
  background: var(--panel-soft);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(226, 232, 240, 0.5);
}

/* Badges / Pills */
.pill {
  border-radius: 4px;
  color: white;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: none;
}

/* Action Controls Inside Cards */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.actions button {
  font-size: 12px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  color: var(--text-secondary);
  border: 1px solid var(--line);
  box-shadow: none;
}

.actions button:hover {
  background: var(--line);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.actions button.danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

.actions button.danger:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

/* Resource List Grid Layouts */
#project-list,
#tag-list,
#goal-list {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  width: 100%;
}

/* Custom Item Styling for resource lists */
#project-list .item,
#tag-list .item,
#goal-list .item {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-left: 4px solid var(--primary);
  background: var(--panel);
}

#project-list .item h4,
#tag-list .item h4,
#goal-list .item h4 {
  margin-bottom: 6px;
}

#project-list .item p,
#tag-list .item p,
#goal-list .item p {
  flex-grow: 1;
  margin-top: 4px;
  font-size: 13px;
}

#project-list .item .actions,
#tag-list .item .actions,
#goal-list .item .actions {
  margin-top: 12px;
}

/* Panel Elements */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

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

.panel-head h3 {
  font-size: 16px;
  font-weight: 700;
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* Dashboard Statistics & Panels */
.stats {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 24px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.stat span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
  margin-top: 6px;
  color: var(--text);
  font-weight: 800;
}

.stat small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 6px;
  font-weight: 500;
}

.hero-stats .stat:first-child {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none;
}

.hero-stats .stat:first-child span {
  color: rgba(255, 255, 255, 0.75);
}

.hero-stats .stat:first-child strong {
  color: white;
}

.hero-stats .stat:first-child small {
  color: rgba(255, 255, 255, 0.85);
}

/* Dashboard Panels Layout */
.charts {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, 1fr);
}

.today-panel {
  grid-column: 1 / -1;
}

.today-panel .list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.today-panel .task-card {
  margin-bottom: 0;
}

/* Progress Bars */
.bar-row {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 120px 1fr 36px;
  margin: 12px 0;
}

.bar-row span {
  color: var(--text-secondary);
  font-size: 13px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.bar-track {
  background: var(--line);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  position: relative;
}

.bar {
  background: var(--primary);
  height: 100%;
  border-radius: 999px;
}

/* Analytics component specifically for Today view */
.analytics {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.analytics-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* Simple flex layout lists */
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-list {
  display: grid;
  gap: 16px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Custom Workload section styling on Dashboard */
.workload-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}

.workload-stat:last-child {
  border-bottom: 0;
}

.workload-stat span {
  color: var(--text-secondary);
  font-size: 13.5px;
}

.workload-stat strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

/* Dialog & Modals */
dialog {
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(500px, calc(100% - 24px));
  padding: 24px;
  margin: auto;
  background: var(--panel);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(4px);
}

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

.dialog-head h3 {
  font-size: 18px;
  font-weight: 700;
}

/* Grid Layouts Inside Modals */
.grid-2 {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

/* Custom Styling for Dialog fields */
.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.modal-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* Toast Messages */
.toast {
  background: var(--text);
  border-radius: var(--radius-md);
  bottom: 24px;
  color: white;
  left: 50%;
  max-width: min(400px, calc(100% - 24px));
  padding: 12px 18px;
  position: fixed;
  text-align: center;
  transform: translateX(-50%);
  z-index: 1000;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translate(-50%, 10px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

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

@media (max-width: 1024px) {
  .board {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    align-content: start;
    border-bottom: 1px solid var(--line);
    border-right: 0;
    gap: 16px;
    height: auto;
    padding: 16px;
    position: static;
  }

  .sidebar div {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .logo {
    margin-bottom: 0;
  }

  #user-label {
    padding-left: 0;
  }

  nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none; /* Hide scrollbars */
  }
  
  nav::-webkit-scrollbar {
    display: none;
  }

  .nav {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 12px;
  }

  .sidebar-data-actions {
    display: flex;
    flex-direction: row !important;
    gap: 8px !important;
    width: 100%;
  }

  .sidebar-data-actions button {
    flex: 1;
    min-height: 34px;
  }

  #logout {
    margin-top: 8px;
    width: auto;
    justify-self: end;
  }

  .workspace {
    padding: 20px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }
  
  .topbar div:last-child {
    display: flex;
    gap: 8px;
  }

  .topbar button {
    flex: 1;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .board {
    grid-template-columns: 1fr;
  }

  .charts {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .auth-panel {
    padding: 24px 16px;
  }
  
  .stats {
    grid-template-columns: 1fr;
  }
}

/* Calendar grid styling */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.calendar-day-header {
  text-align: center;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.calendar-day {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  min-height: 100px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.calendar-day:hover {
  border-color: var(--line-focus);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.calendar-day.empty {
  background: transparent;
  border: none;
  pointer-events: none;
  box-shadow: none;
  transform: none;
}

.calendar-day-num {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.calendar-day-info {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-day-pct {
  font-weight: 850;
  font-size: 13px;
}

/* Heatmap tints */
.calendar-day.has-tasks {
  background: var(--accent-light);
  border-color: rgba(37, 99, 235, 0.15);
}

.calendar-day.completed-all {
  background: var(--success-light);
  border-color: rgba(16, 185, 129, 0.2);
}

/* Mobile responsive override */
@media (max-width: 820px) {
  .calendar-grid {
    grid-template-columns: repeat(7, minmax(40px, 1fr));
    gap: 6px;
  }
  
  .calendar-day {
    min-height: 70px;
    padding: 6px;
  }
  
  .calendar-day-num {
    font-size: 12px;
  }
  
  .calendar-day-info {
    margin-top: 4px;
  }
  
  .calendar-day-pct {
    font-size: 10px;
  }
  
  .calendar-day-info div:last-child {
    display: none !important;
  }
}

/* Task list container (flat vertical list) */
.task-list {
  display: flex;
  flex-direction: column;
}

/* Compact task row */
.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  transition: background 0.15s ease;
}

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

/* Status badge */
.status-badge {
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Priority stars */
.priority-stars {
  font-size: 13px;
  white-space: nowrap;
}

/* Task title in row */
.task-row .task-title {
  flex: 1;
  font-weight: 500;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Project name styling */
.task-project {
  font-size: 13px;
  white-space: nowrap;
}

/* Task date in row */
.task-row .task-date {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* Row action buttons */
.task-row-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.task-row:hover .task-row-actions {
  opacity: 1;
}

/* Hero section */
.hero-section {
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
  color: white;
}

.hero-greeting h2 {
  font-size: 26px;
  font-weight: 800;
  color: white;
  margin-bottom: 4px;
}

.hero-greeting p {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 4px;
}

.hero-stats-row {
  display: flex;
  gap: 32px;
  margin-top: 20px;
}

.hero-stat {
  display: flex;
  flex-direction: column;
}

.hero-stat-value {
  font-size: 28px;
  font-weight: 800;
}

.hero-stat-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
