/* main/static/main/tasks.css */

/* =========================
   1) Design system
   ========================= */
:root {
  --bg-app: #f8f9fa;
  --bg-card: #ffffff;
  --bg-muted: #f1f4f9;
  --bg-item: #ffffff;

  --text-main: #1f2937;
  --text-muted: #6b7280;

  --accent: #22c55e;
  --accent-hover: #16a34a;

  --danger: #ae1a1a;
  --danger-hover: #8c1313;

  --border: #e5e7eb;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 30px rgba(17, 24, 39, 0.10);

  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;

  --focus: 0 0 0 3px rgba(56, 110, 180, 0.25);
}

/* =========================
   Base / reset
   ========================= */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text-main);
  background: #F8FAFC;
  line-height: 1.35;
}

a { color: inherit; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius-sm);
}

/* =========================
   Header (supports both old and new markup)
   ========================= */
header,
.site-header {
  background: #ffffff;
  color: #1f2937;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border);
}

.site-title,
header .site-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.site-title a {
  color: #1f2937;
  text-decoration: none;
}

/* Old nav structure: header nav a */
header nav a {
  color: rgba(31, 41, 55, 0.90);
  text-decoration: none;
  margin-left: 16px;
  font-size: 0.98rem;
  opacity: 0.9;
  transition: opacity 0.15s ease;
}
header nav a:hover { opacity: 1; }

/* New nav structure: .main-nav ul/li/a */
.site-header .main-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}
.site-header .main-nav ul {
  list-style: none;
  display: flex;
  gap: 14px;
  margin: 0;
  padding: 0;
  align-items: center;
}
.site-header .main-nav a {
  color: rgba(31, 41, 55, 0.90);
  text-decoration: none;
  font-size: 0.98rem;
  opacity: 0.9;
  transition: opacity 0.15s ease;
}
.site-header .main-nav a:hover { opacity: 1; }

.site-header .nav-user {
  margin-left: 10px;
  font-style: italic;
  opacity: 0.9;
}

/* =========================
   Main container / headings
   ========================= */
main {
  max-width: 1500px !important;
  margin: 24px auto !important;
  padding: 0 32px !important;
}

h1, h2 { margin: 0 0 12px 0; }
h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

/* =========================
   Messages (if you still render them)
   ========================= */
.messages { margin: 12px 0; }
.message {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #ecfdf3;
  color: #166534;
}
.message.error {
  background: #fef2f2;
  color: #991b1b;
}
.message.success {
  background: #ecfdf3;
  color: #166534;
}

/* =========================
   Forms (Add/Edit/Delete)
   ========================= */
.add-task-section,
.edit-task-section,
.delete-task-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}

.add-task-form div,
.edit-task-form div {
  margin-bottom: 12px;
}

/* Slightly tighter spacing in the inline add-task panel */
.add-task-form div {
  margin-bottom: 10px;
}

/* Labels: calmer + more modern */
.add-task-form label,
.edit-task-form label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

/* Add-task label tuning (only add form) */
.add-task-form label {
  font-weight: 500;
  font-size: 0.9rem;
}

/* Inputs */
.add-task-form input[type="text"],
.edit-task-form input[type="text"],
.add-task-form textarea,
.edit-task-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-main);
  font-size: 1rem;
  font-family: inherit; /* fixes textarea looking “different” */
}

.add-task-form input[type="text"],
.edit-task-form input[type="text"] {
  height: 42px; /* consistent modern input height */
}

.add-task-form textarea,
.edit-task-form textarea {
  min-height: 96px;
  resize: vertical;
}

.add-task-form input[type="text"]:focus,
.edit-task-form input[type="text"]:focus,
.add-task-form textarea:focus,
.edit-task-form textarea:focus {
  border-color: rgba(56, 110, 180, 0.55);
  box-shadow: var(--focus);
}

/* Buttons */
.add-task-form button,
.edit-task-form button {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, transform 0.05s ease;
}
.add-task-form button:hover,
.edit-task-form button:hover {
  background: var(--accent-hover);
}
.add-task-form button:active,
.edit-task-form button:active {
  transform: translateY(1px);
}

/* Add-task primary button tuning (only add form) */
.add-task-form button {
  padding: 9px 14px;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
}

/* Delete confirmation button style (if still used elsewhere) */
.delete-task-section button.danger {
  background: var(--danger);
}
.delete-task-section button.danger:hover {
  background: var(--danger-hover);
}
.delete-task-section a {
  margin-left: 14px;
}

/* Error text */
.form-error {
  color: var(--danger);
  font-size: 0.95rem;
  margin-top: 6px;
}

/* =========================
   Tasks layout
   ========================= */
.tasks-container {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

/* Cards */
.tasks-list {
  flex: 1 1 360px;
  min-width: 300px;

  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.tasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--space-4);

  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.tasks-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

/* "+" button */
.add-task-btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 9999px; /* Pill shape */
  border: none;
  background: var(--accent);

  color: #ffffff;
  font-size: 14px;
  font-weight: 600;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  cursor: pointer;
  box-shadow: var(--shadow-sm);

  transition:
    background 0.15s ease,
    transform 0.05s ease;
}

.add-task-btn:hover {
  background: var(--accent-hover);
}

.add-task-btn:active {
  transform: translateY(1px);
}



.tasks-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* List items */
.tasks-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;

  background: var(--bg-item);
  border-bottom: 1px solid var(--border);
  padding: 14px 12px;
}
.tasks-list li:last-child {
  border-bottom: none;
}

/* =========================
   Checkbox (normalized)
   ========================= */
.task-checkbox {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  width: 18px;
  height: 18px;

  border: 1.5px solid #9ca3af;
  border-radius: 4px;
  background: #fff;

  display: inline-grid;
  place-content: center;

  cursor: pointer;
  flex-shrink: 0;
}
.task-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.task-checkbox:checked::after {
  content: "";
  width: 9px;
  height: 9px;
  background: #fff;
  border-radius: 2px;
}

/* =========================
   Step 3: Task row structure
   ========================= */
.task-item {
  align-items: flex-start;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}
.task-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.task-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.task-label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.task-title {
  font-weight: 500;
  font-size: 1rem;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: auto; /* bilingual polish */
}

.task-desc {
  width: 100%;
  margin-left: 32px;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.95rem;
  white-space: pre-line;
  word-break: break-word;
  direction: auto; /* bilingual polish */
}

.task-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;

  opacity: 0.4;
  transition: opacity 0.15s ease;
}
.task-item:hover .task-actions { opacity: 1; }

.task-action-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-decoration: none;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.task-action-link:hover {
  color: var(--danger);
  background: #fef2f2;
}

/* Backward-compat */
.tasks-list a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
  opacity: 0.9;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.tasks-list a:hover {
  color: var(--danger);
  opacity: 1;
}

.task-empty {
  padding: 12px;
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-muted);
}

/* =========================
   Add form container (inside lists) - polished
   ========================= */
.add-task-form-container {
  margin-top: 14px;

  /* calmer container */
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  padding-top: 56px; /* room for the close button */
  box-shadow: none;

  position: relative;
}

/* Close "×" button - smaller, neutral (doesn't dominate) */
.close-form-btn {
  position: absolute;
  width: 32px;
  height: 32px;
  top: 16px;
  right: 16px;

  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;

  box-shadow: var(--shadow-sm);
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  transition: background 0.15s ease, color 0.15s ease, transform 0.05s ease;
}

.close-form-btn:hover {
  background: var(--bg-muted);
  color: var(--text-main);
}

.close-form-btn:active {
  transform: translateY(1px);
}

/* =========================
   Anchor button
   ========================= */
.anchor-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: transform 0.08s ease, background 0.15s ease, color 0.15s ease;
}
.anchor-btn:hover { 
  background: var(--bg-muted); 
}
.anchor-btn:active { 
  transform: scale(0.92); 
}

.anchored { color: #f59e0b; }
.not-anchored { color: var(--text-muted); }

/* =========================
   Animation helpers
   ========================= */
.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* =========================
   Assistant button priority (safe: applies only if class exists)
   ========================= */
.assistant-toggle {
  opacity: 0.85;
  transition: opacity 0.15s ease, transform 0.08s ease;
}
.assistant-toggle:hover { opacity: 1; }
.assistant-toggle:active { transform: translateY(1px); }

/* =========================
   Delete form (Option A)
   ========================= */
.task-delete-form {
  display: inline;
  margin: 0;
}

.task-action-link.task-action-danger {
  border: none;
  background: transparent;
  cursor: pointer;
}

.task-action-link.task-action-danger:hover {
  color: var(--danger);
  background: #fef2f2;
}

/* =========================
   Responsive
   ========================= */
@media (max-width: 800px) {
  .tasks-container {
    flex-direction: column;
    gap: 14px;
  }
  .tasks-list {
    min-width: 0;
  }

  /* On mobile, actions should be fully visible (no hover) */
  .task-actions {
    opacity: 1;
  }
}
