/* ========== Global Reset & Base ========== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at top, #eef5ff 0, #f5f7fb 40%, #edf1f7 100%);
  color: #111827;
}

/* ========== App Shell ========== */

.app {
  max-width: 1280px;
  margin: 32px auto;
  padding: 24px 24px 32px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 22px;
  box-shadow:
    0 18px 45px rgba(15, 23, 42, 0.12),
    0 0 0 1px rgba(148, 163, 184, 0.15);
  backdrop-filter: blur(10px);
}

/* ========== Header & Screen Switcher ========== */

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

.app-title h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #0f172a;
}

.app-subtitle {
  font-size: 0.9rem;
  color: #6b7280;
  margin-top: 2px;
}

.screen-switcher {
  background: #e5edff;
  padding: 5px;
  border-radius: 999px;
  display: inline-flex;
  gap: 4px;
}

.screen-switcher button {
  border: none;
  padding: 7px 18px;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: #4b5563;
  transition: all 0.18s ease;
}

.screen-switcher button:hover {
  background: rgba(255, 255, 255, 0.85);
}

.screen-switcher button.active {
  background: #2563eb;
  color: #f9fafb;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
}

/* ========== Screens ========== */

.screen {
  display: none;
}

.screen.active-screen {
  display: block;
}

/* ========== Form: Add / Edit Task ========== */

.add-task {
  background: #f9fafb;
  border-radius: 16px;
  padding: 16px 16px 14px;
  border: 1px solid #e5e7eb;
  margin-bottom: 18px;
}

.add-task-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.add-task input[type="text"],
.add-task input[type="date"],
.add-task input[type="number"],
.add-task textarea,
.add-task select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  font-size: 0.95rem;
  color: #111827;
  outline: none;
  transition: all 0.16s ease;
}

.add-task input::placeholder,
.add-task textarea::placeholder {
  color: #9ca3af;
}

.add-task input:focus,
.add-task textarea:focus,
.add-task select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.add-task textarea {
  resize: vertical;
  min-height: 52px;
}

.add-task-meta {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) minmax(180px, 1.4fr) minmax(120px, 1fr);
  gap: 10px;
}

.add-task-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.add-task-actions button {
  padding: 9px 16px;
  border-radius: 999px;
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}

#saveTaskBtn {
  background: #22c55e;
  color: #f9fafb;
  box-shadow: 0 8px 18px rgba(34, 197, 94, 0.4);
}

#saveTaskBtn:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

#cancelEditBtn {
  background: #e5e7eb;
  color: #374151;
}

#cancelEditBtn:hover {
  background: #d1d5db;
}

/* ========== Generic Buttons / Inputs ========== */

button {
  font-family: inherit;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #2563eb;
}

/* Secondary button (Export .ics) */
.secondary-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: none;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  background: #2563eb;
  color: #f9fafb;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
  transition: all 0.18s ease;
  white-space: nowrap;
}

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

dialog.export-dialog {
  border: none;
  padding: 0;
  border-radius: 16px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow:
    0 18px 45px rgba(15, 23, 42, 0.22),
    0 0 0 1px rgba(148, 163, 184, 0.2);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
}

dialog.export-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.export-dialog-inner {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-dialog-inner h3 {
  font-size: 1.05rem;
  font-weight: 650;
  color: #0f172a;
}

.export-select-all {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #111827;
  font-size: 0.95rem;
}

.export-task-list {
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 14px;
  padding: 10px;
  max-height: 320px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

.export-task-item-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.export-task-item-title {
  font-size: 0.95rem;
  color: #0f172a;
  font-weight: 600;
}

.export-task-item-subtitle {
  font-size: 0.85rem;
  color: #6b7280;
}

.export-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

#exportIcsCancelBtn {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  color: #111827;
}

#exportIcsCancelBtn:hover {
  background: #f9fafb;
}

/* ===== Groups / "Folders" filter bar ===== */

.group-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0 10px;
}

.group-filter-label {
  font-size: 0.85rem;
  color: #6b7280;
  white-space: nowrap;
}

#groupFilterButtons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
  flex: 1;
}

.group-filter-btn {
  border: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  background: #e5e7eb;
  color: #374151;
  transition: all 0.15s ease;
}

.group-filter-btn:hover {
  background: #d1d5db;
}

.group-filter-btn.active {
  background: #2563eb;
  color: #f9fafb;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

@media (max-width: 900px) {
  .group-filter {
    flex-direction: column;
    align-items: flex-start;
  }

  .secondary-btn {
    align-self: stretch;
    text-align: center;
  }
}

/* ========== Tasks Screen Layout ========== */

.task-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #edf2f7;
  background: linear-gradient(to right, #f9fafb, #f3f4ff);
  border-radius: 14px 14px 0 0;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
}

.panel-header span {
  font-size: 0.78rem;
  color: #6b7280;
}

/* ========== List View (Tasks) ========== */

.list-panel {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.list-panel-inner {
  padding: 10px 14px 14px;
}

#taskList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#taskList > p {
  font-size: 0.88rem;
  color: #6b7280;
  padding: 18px 0;
  text-align: center;
  border-radius: 12px;
  background: #f9fafb;
  border: 1px dashed #d4d4dd;
}

.task-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.18s ease, transform 0.18s ease,
    border-color 0.18s ease;
}

.task-item:hover {
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
  border-color: #d1d5db;
}

.task-left {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  flex: 1;
}

.task-title-block {
  display: flex;
  flex-direction: column;
}

.task-title {
  font-size: 0.98rem;
  font-weight: 500;
  color: #111827;
}

.task-title.completed {
  text-decoration: line-through;
  color: #9ca3af;
}

.task-description {
  font-size: 0.82rem;
  color: #6b7280;
  margin-top: 3px;
}

.task-meta {
  font-size: 0.8rem;
  color: #6b7280;
}

.task-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 170px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.small-btn {
  font-size: 0.78rem;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  cursor: pointer;
  transition: all 0.16s ease;
}

.small-btn:hover:not(:disabled) {
  background: #e5edff;
  border-color: #c4d3ff;
}

.delete-btn {
  border: none;
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  background: #f97373;
  color: #fef2f2;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.18s ease;
  box-shadow: 0 5px 12px rgba(220, 38, 38, 0.35);
}

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

/* ========== Kanban Board ========== */

.kanban-panel {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.kanban-panel-inner {
  padding: 12px 14px 14px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 4px;
}

.kanban-column {
  background: #f9fafb;
  border-radius: 14px;
  padding: 10px;
  border: 1px solid #e5e7eb;
  min-height: 230px;
  display: flex;
  flex-direction: column;
}

.kanban-column h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #374151;
}

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

.kanban-column-body > p {
  font-size: 0.85rem;
  color: #6b7280;
  padding: 10px;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px dashed #d4d4dd;
  text-align: center;
  background: #ffffff;
}

.kanban-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 9px 10px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: box-shadow 0.18s ease, transform 0.18s ease,
    border-color 0.18s ease;
}

.kanban-card:hover {
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
  border-color: #d1d5db;
}

.kanban-card-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: #111827;
}

.kanban-card-title.completed {
  text-decoration: line-through;
  color: #9ca3af;
}

.kanban-card .task-meta {
  font-size: 0.75rem;
  color: #6b7280;
}

.kanban-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.kanban-move-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ========== Pomodoro Screen Layout ========== */

.pomodoro-screen {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 22px;
  margin-top: 6px;
}

/* ========== Pomodoro Panel ========== */

.pomodoro-panel {
  padding: 16px 18px 14px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #eff6ff, #fefce8);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
}

.pomodoro-panel h2 {
  font-size: 1.2rem;
  margin-bottom: 12px;
  color: #111827;
}

.pomodoro-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.pomodoro-row label {
  font-size: 0.9rem;
  color: #4b5563;
}

.pomodoro-row select {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.16s ease;
}

.pomodoro-row select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

.pomodoro-display {
  font-size: 2.7rem;
  text-align: center;
  margin: 10px 0 4px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #111827;
}

#pomodoroModeLabel,
#pomodoroCycleLabel,
#dailyStatsDisplay {
  text-align: center;
  font-size: 0.86rem;
  color: #4b5563;
  margin-bottom: 3px;
}

.pomodoro-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 10px 0 6px;
}

.pomodoro-controls button {
  padding: 7px 16px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.18s ease;
  background: #ffffff;
  color: #374151;
  box-shadow: 0 6px 12px rgba(148, 163, 184, 0.35);
}

.pomodoro-controls button:hover:not(:disabled) {
  background: #e5edff;
  transform: translateY(-1px);
}

.pomodoro-controls #startPomodoroBtn {
  background: #2563eb;
  color: #f9fafb;
}

.pomodoro-controls #startPomodoroBtn:hover:not(:disabled) {
  background: #1d4ed8;
}

.pomodoro-note {
  font-size: 0.8rem;
  color: #6b7280;
  text-align: center;
}

/* ========== Analytics Panel ========== */

.analytics-panel {
  padding: 16px 18px 14px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.04);
}

.analytics-panel h2 {
  font-size: 1.1rem;
  margin-bottom: 10px;
  color: #111827;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.analytics-table th,
.analytics-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #e5e7eb;
}

.analytics-table th {
  text-align: left;
  font-weight: 600;
  color: #374151;
  background: #e5edff;
}

.analytics-table tr:last-child td {
  border-bottom: none;
}

.analytics-table td:nth-child(2) {
  text-align: right;
  color: #111827;
}

/* ========== Responsive Tweaks ========== */

@media (max-width: 900px) {
  .app {
    margin: 12px;
    padding: 18px 14px 22px;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .add-task-meta {
    grid-template-columns: 1fr;
  }

  .task-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .task-item-right {
    align-items: flex-start;
    min-width: 0;
  }

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

  .pomodoro-screen {
    grid-template-columns: 1fr;
  }
}
