/* Mini App - Telegram Tasks Viewer */
/* Refactored from index.html - Story TECH-1 */

:root {
  --tg-theme-bg-color: #ffffff;
  --tg-theme-text-color: #000000;
  --tg-theme-hint-color: #999999;
  --tg-theme-button-color: #50a8eb;
  --tg-theme-button-text-color: #ffffff;
  --tg-theme-secondary-bg-color: #f0f0f0;
  --tg-theme-destructive-color: #e53935;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--tg-theme-bg-color);
  color: var(--tg-theme-text-color);
  padding-bottom: 160px;
  font-size: 14px;
}

.sticky-header {
  position: sticky;
  top: 0;
  background: var(--tg-theme-bg-color);
  z-index: 10;
  padding: 8px 12px 0;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

/* Floating view toggle button */
.view-toggle {
  position: fixed;
  bottom: 16px;
  left: 12px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: linear-gradient(145deg, var(--tg-theme-button-color), color-mix(in srgb, var(--tg-theme-button-color) 85%, black));
  color: var(--tg-theme-button-text-color);
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow:
    0 4px 12px rgba(0,0,0,0.25),
    0 2px 4px rgba(0,0,0,0.15),
    inset 0 1px 1px rgba(255,255,255,0.2);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}

.view-toggle:active {
  transform: scale(0.92);
  box-shadow:
    0 2px 6px rgba(0,0,0,0.2),
    inset 0 1px 2px rgba(0,0,0,0.1);
}

.header h1 { font-size: 17px; font-weight: 600; }

.counter {
  background: linear-gradient(145deg, var(--tg-theme-button-color), color-mix(in srgb, var(--tg-theme-button-color) 85%, black));
  color: var(--tg-theme-button-text-color);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.counter.overdue {
  background: linear-gradient(145deg, var(--tg-theme-destructive-color), color-mix(in srgb, var(--tg-theme-destructive-color) 85%, black));
}

/* Tab bar */
.tabs {
  display: flex;
  gap: 6px;
  padding: 8px 0 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-text-color);
  border: none;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.tab.active {
  background: linear-gradient(145deg, var(--tg-theme-button-color), color-mix(in srgb, var(--tg-theme-button-color) 85%, black));
  color: var(--tg-theme-button-text-color);
  box-shadow:
    0 2px 6px rgba(0,0,0,0.2),
    inset 0 1px 1px rgba(255,255,255,0.15);
}

.tab.overdue-tab.active {
  background: linear-gradient(145deg, var(--tg-theme-destructive-color), color-mix(in srgb, var(--tg-theme-destructive-color) 85%, black));
  box-shadow:
    0 2px 6px rgba(0,0,0,0.2),
    inset 0 1px 1px rgba(255,255,255,0.15);
}

.tab .badge {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.8;
}

/* Area filter pills */
.area-filter {
  display: flex;
  gap: 6px;
  padding: 0 0 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.area-filter::-webkit-scrollbar { display: none; }

.area-pill {
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-text-color);
  border: none;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.area-pill.active {
  background: linear-gradient(145deg, var(--tg-theme-button-color), color-mix(in srgb, var(--tg-theme-button-color) 85%, black));
  color: var(--tg-theme-button-text-color);
  box-shadow:
    0 2px 6px rgba(0,0,0,0.2),
    inset 0 1px 1px rgba(255,255,255,0.15);
}

/* Project filter pills */
.project-filter {
  display: flex;
  gap: 6px;
  padding: 0 0 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.project-filter::-webkit-scrollbar { display: none; }

.project-pill {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-text-color);
  border: none;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.project-pill.active {
  background: linear-gradient(145deg, var(--tg-theme-button-color), color-mix(in srgb, var(--tg-theme-button-color) 85%, black));
  color: var(--tg-theme-button-text-color);
  box-shadow:
    0 2px 6px rgba(0,0,0,0.2),
    inset 0 1px 1px rgba(255,255,255,0.15);
}

/* Selected project name */
.selected-project {
  padding: 0 0 10px;
  font-size: 12px;
  color: var(--tg-theme-hint-color);
}

.selected-project a {
  color: var(--tg-theme-button-color);
  text-decoration: none;
}

.selected-project a:active {
  opacity: 0.7;
}

/* Task project icon */
.task-icon {
  font-size: 12px;
  margin-right: 3px;
}

/* Content */
.content {
  padding: 0 12px;
}

.section {
  margin-bottom: 12px;
  background: var(--tg-theme-secondary-bg-color);
  border-radius: 10px;
  overflow: hidden;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.section-header:active { opacity: 0.7; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title .icon { font-size: 14px; }

.section-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.chevron {
  font-size: 12px;
  color: var(--tg-theme-hint-color);
  transition: transform 0.2s;
}

.section.collapsed .chevron { transform: rotate(-90deg); }
.section.collapsed .section-content { max-height: 0; }

.section-content {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

/* Section header colors */
.section.overdue .section-header { background: rgba(229, 57, 53, 0.1); }
.section.overdue .section-title { color: var(--tg-theme-destructive-color); }

.section.today .section-header { background: rgba(80, 168, 235, 0.12); }
.section.today .section-title { color: var(--tg-theme-button-color); }

.section.dated .section-header { background: rgba(100, 180, 100, 0.1); }
.section.nodate .section-header { background: rgba(150, 150, 150, 0.08); }

/* Task item */
.task-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 10px;
  border-top: 1px solid rgba(0,0,0,0.04);
}

.task-item:first-child { border-top: none; }
.task-item.checked { opacity: 0.5; }
.task-item.checked .task-name { text-decoration: line-through; }
/* Parent task separator - subtle line between task groups */
.task-item.parent-task {
  margin-top: 6px;
  padding-top: 8px;
  padding-bottom: 4px;
  border-top: 1px solid rgba(128,128,128,0.2);
}
.task-item.parent-task:first-child {
  margin-top: 0;
  border-top: none;
}

/* Subtask styling - tighter spacing, indented with left border */
.task-item.sub-task {
  padding: 4px 12px 4px 34px;
  margin-left: 18px;
  background: rgba(0,0,0,0.02);
  border-left: 2px solid var(--tg-theme-hint-color);
  border-top: none;
}

.checkbox {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--tg-theme-button-color);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.checkbox.checked { background: var(--tg-theme-button-color); }
.checkbox.checked::after {
  content: '✓';
  color: white;
  font-size: 11px;
  font-weight: bold;
}

.task-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.task-name {
  font-size: 14px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta {
  font-size: 11px;
  color: var(--tg-theme-hint-color);
  display: flex;
  gap: 8px;
}

.notion-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 6px;
  background: rgba(0,0,0,0.05);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.notion-btn:active { background: rgba(0,0,0,0.1); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--tg-theme-hint-color);
}

.empty-state .icon { font-size: 36px; margin-bottom: 8px; }

.error-state {
  text-align: center;
  padding: 30px 16px;
  color: var(--tg-theme-destructive-color);
}

.error-state p { margin-bottom: 12px; }

.refresh-btn {
  padding: 8px 20px;
  background: var(--tg-theme-button-color);
  color: var(--tg-theme-button-text-color);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.loading {
  padding: 12px;
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-task { height: 36px; margin: 4px 0; }

/* Notes toolbar */
.notes-toolbar {
  display: flex;
  padding: 0 0 10px;
}

.sort-toggle {
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-text-color);
  border: none;
  -webkit-tap-highlight-color: transparent;
}

.sort-toggle:active { opacity: 0.7; }

.load-more-hint {
  text-align: center;
  padding: 16px 0;
  font-size: 12px;
  color: var(--tg-theme-hint-color);
}

/* Notes view */
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note-card {
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 8px;
  background: linear-gradient(145deg, var(--tg-theme-secondary-bg-color), color-mix(in srgb, var(--tg-theme-secondary-bg-color) 92%, black));
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 1px 4px rgba(0,0,0,0.1),
    inset 0 1px 1px rgba(255,255,255,0.15);
}

.note-card:active { opacity: 0.7; }

.note-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.note-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--tg-theme-button-color);
}

.note-excerpt {
  font-size: 13px;
  color: var(--tg-theme-text-color);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-meta {
  font-size: 11px;
  color: var(--tg-theme-hint-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-project {
  display: flex;
  align-items: center;
  gap: 3px;
}

