/* ============================================================
   TaskAgent Mini App — Telegram Theme-aware CSS
   ============================================================ */

:root {
  --tg-bg: var(--tg-theme-bg-color, #ffffff);
  --tg-text: var(--tg-theme-text-color, #000000);
  --tg-hint: var(--tg-theme-hint-color, #999999);
  --tg-button: var(--tg-theme-button-color, #2481cc);
  --tg-button-text: var(--tg-theme-button-text-color, #ffffff);
  --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #f1f1f1);
  --tg-link: var(--tg-theme-link-color, #2481cc);
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--tg-bg);
  color: var(--tg-text);
  font-size: 15px;
  line-height: 1.5;
}

.tg-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 80px; /* space for bottom-bar */
}

/* ---- User Card ---- */
.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--tg-secondary-bg);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--tg-button);
  color: var(--tg-button-text);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-context {
  font-size: 12px;
  color: var(--tg-hint);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-badge {
  background: var(--tg-button);
  color: var(--tg-button-text);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---- Section Header ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}

.section-title {
  font-weight: 700;
  font-size: 16px;
}

.section-count {
  font-size: 13px;
  color: var(--tg-hint);
}

/* ---- Tasks List ---- */
.tasks-list {
  flex: 1;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- Task Card ---- */
.task-card {
  background: var(--tg-secondary-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
  position: relative;
  animation: fadeIn 0.25s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.task-card.removing {
  opacity: 0;
  transform: translateX(30px);
  pointer-events: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.task-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.task-badge-type {
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 1px;
}

.task-title {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.task-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--tg-hint);
  padding: 0 2px;
  transition: color 0.15s;
  flex-shrink: 0;
}

.task-delete:hover {
  color: #e53935;
}

.task-description {
  font-size: 13px;
  color: var(--tg-hint);
  padding-left: 23px;
  font-style: italic;
  margin-bottom: 6px;
  word-break: break-word;
}

.task-footer {
  display: flex;
  justify-content: flex-end;
  padding-left: 23px;
  font-size: 11px;
  color: var(--tg-hint);
  margin-top: 4px;
}

/* ---- States ---- */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0;
  color: var(--tg-hint);
  gap: 12px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--tg-secondary-bg);
  border-top-color: var(--tg-button);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--tg-hint);
  gap: 8px;
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 15px;
  font-weight: 500;
}

.empty-state small {
  font-size: 13px;
  color: var(--tg-hint);
}

/* ---- Bottom Bar ---- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--tg-bg);
  border-top: 1px solid rgba(0,0,0,0.07);
  z-index: 20;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

.bar-btn {
  flex: 1;
  padding: 12px 0;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--tg-button);
  color: var(--tg-button-text);
  transition: opacity 0.15s, transform 0.1s;
}

.bar-btn:active {
  opacity: 0.8;
  transform: scale(0.97);
}

.bar-btn-danger {
  background: var(--tg-secondary-bg);
  color: #e53935;
}

/* ---- Error Overlay ---- */
.error-overlay {
  position: fixed;
  inset: 0;
  background: var(--tg-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.error-card {
  text-align: center;
  padding: 32px 24px;
  max-width: 300px;
}

.error-icon {
  font-size: 52px;
  margin-bottom: 16px;
}

.error-card h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.error-card p {
  color: var(--tg-hint);
  margin-bottom: 24px;
  font-size: 14px;
}

.tg-btn {
  display: inline-block;
  background: var(--tg-button);
  color: var(--tg-button-text);
  text-decoration: none;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
}
