:root {
  --bg-1: #eef2ff;
  --bg-2: #f8fafc;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --text: #111827;
  --muted: #6b7280;
  --border: rgba(99, 102, 241, 0.12);
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  --card: rgba(255, 255, 255, 0.72);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Vazirmatn", sans-serif;
  direction: rtl;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(99,102,241,0.14), transparent 25%),
    radial-gradient(circle at bottom left, rgba(139,92,246,0.12), transparent 30%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

.app-shell {
  width: min(1180px, 94%);
  margin: 28px auto 40px;
  display: grid;
  gap: 18px;
}

.hero-card,
.glass-card,
.motivation-card {
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  border-radius: 28px;
}

.hero-card {
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: auto -90px -90px auto;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,.25), transparent 70%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-badge {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.25);
}

.brand h1 {
  font-size: 1.8rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.brand p {
  color: var(--muted);
  font-size: 0.95rem;
}

.score-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 20px;
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(99, 102, 241, 0.12);
}

.score-icon {
  font-size: 1.5rem;
  animation: float 1.8s ease-in-out infinite;
}

.score-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-info span {
  color: var(--muted);
  font-size: 0.85rem;
}

.score-info strong {
  font-size: 1.25rem;
}

.glass-card {
  padding: 20px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start; /* Changed from center to flex-start */
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap; /* Allow wrapping for smaller screens */
}

.section-head h2 {
  font-size: 1.15rem;
  font-weight: 900;
}

.advanced-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap; /* Allow wrapping for smaller screens */
}

.stats-summary {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.stat-item-sm {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-label-sm {
  color: var(--muted);
  font-size: 0.8rem;
}

.stat-value-sm {
  font-weight: 800;
  font-size: 0.95rem;
}

.btn-secondary {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  padding: 10px 16px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.9rem;
  transition: 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(239, 68, 68, 0.18);
  transform: translateY(-1px);
}


.task-form {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #374151;
}

input, select {
  width: 100%;
  border: 1px solid #dbe3ff;
  background: rgba(255,255,255,0.95);
  border-radius: 16px;
  padding: 13px 14px;
  outline: none;
  transition: 0.2s ease;
  font-family: inherit;
}

input::placeholder {
  color: #9ca3af;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.12);
}

.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  border-radius: 16px;
  transition: 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 14px 20px;
  justify-self: start;
  min-width: 180px;
  box-shadow: 0 14px 30px rgba(99, 102, 241, 0.22);
}

.btn-primary:hover,
.filter-btn:hover,
.action-btn:hover {
  transform: translateY(-2px);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-btn {
  border: 1px solid #dbe3ff;
  background: rgba(255,255,255,0.92);
  color: #374151;
  padding: 10px 15px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: 0.2s ease;
}

.filter-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(99,102,241,0.18);
}

.table-wrapper {
  overflow-x: auto;
}

.tasks-table {
  width: 100%;
  min-width: 820px;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.tasks-table thead th {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  padding: 10px;
}

.tasks-table tbody tr {
  background: rgba(255,255,255,0.9);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
  transition: 0.2s ease;
}

.tasks-table tbody tr:hover {
  transform: translateY(-1px);
}

.tasks-table td {
  text-align: center;
  padding: 14px 10px;
  border-top: 1px solid rgba(219, 227, 255, 0.55);
  border-bottom: 1px solid rgba(219, 227, 255, 0.55);
}

.tasks-table td:first-child {
  border-right: 1px solid rgba(219, 227, 255, 0.55);
  border-top-right-radius: 18px;
  border-bottom-right-radius: 18px;
}

.tasks-table td:last-child {
  border-left: 1px solid rgba(219, 227, 255, 0.55);
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px;
}

.task-done {
  opacity: 0.72;
}

.task-done td:nth-child(2) {
  text-decoration: line-through;
  color: #6b7280;
}

.topic-درس { color: #2563eb; font-weight: 800; }
.topic-کار { color: #7c3aed; font-weight: 800; }
.topic-ورزش { color: #059669; font-weight: 800; }
.topic-شخصی { color: #db2777; font-weight: 800; }
.topic-سایر { color: #d97706; font-weight: 800; }

.task-check {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.action-btn {
  border: none;
  cursor: pointer;
  padding: 9px 11px;
  border-radius: 12px;
  margin: 0 3px;
  font-weight: 800;
  transition: 0.2s ease;
}

.edit-btn {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.delete-btn {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

/* Motivation */
.motivation-card {
  padding: 22px;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.motivation-card.hidden {
  display: none !important;
}

.motivation-card.show {
  display: block;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.motivation-card.hide {
  opacity: 0;
  transform: translateY(8px) scale(0.98);
}

.motivation-glow {
  position: absolute;
  inset: auto -60px -60px auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.18), transparent 68%);
  pointer-events: none;
}

.motivation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.motivation-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  font-weight: 800;
  box-shadow: 0 12px 22px rgba(99, 102, 241, 0.22);
}

.close-motivation {
  border: none;
  background: rgba(17,24,39,0.05);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  transition: 0.2s ease;
  color: #4b5563;
}

.close-motivation:hover {
  background: rgba(17,24,39,0.1);
  color: #111827;
}

.motivation-card h3 {
  font-size: 1.25rem;
  font-weight: 900;
  margin-bottom: 8px;
}

.motivation-card p {
  color: var(--muted);
  margin-bottom: 18px;
}

.motivation-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat-item {
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(99, 102, 241, 0.08);
  border-radius: 18px;
  padding: 15px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.stat-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text);
}

.hidden {
  display: none !important;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@media (max-width: 980px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-top {
    flex-direction: column;
    align-items: stretch;
  }

  .score-pill {
    justify-content: center;
  }

  .motivation-stats {
    grid-template-columns: 1fr;
  }

  .section-head {
      align-items: center; /* Center align for smaller screens */
  }

  .advanced-actions {
      margin-top: 10px;
      width: 100%;
      justify-content: center;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(96%, 1000px);
    margin-top: 16px;
  }

  .hero-card,
  .glass-card,
  .motivation-card {
    border-radius: 22px;
  }

  .brand h1 {
    font-size: 1.35rem;
  }

  .brand p {
    font-size: 0.88rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .btn-primary {
    width: 100%;
    justify-self: stretch;
  }

  .section-head {
    flex-direction: column;
    align-items: center; /* Center align for small screens */
    gap: 14px;
  }

  .tasks-table {
    min-width: 760px;
  }

  .stats-summary {
      margin-top: 10px;
  }
}
