/* ========================================
   El Caporal — Social Media Post Tracker
   ======================================== */

:root {
  --bg: #f5f3ef;
  --card: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.1);
  --accent: #2d5016;
  --accent-light: #3d6b20;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --not-started: #9ca3af;
  --not-started-bg: #f3f4f6;
  --working: #f59e0b;
  --working-bg: #fef3c7;
  --done: #10b981;
  --done-bg: #d1fae5;
  --posted: #6366f1;
  --posted-bg: #e0e7ff;
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ========== LOGIN ========== */

.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow-hover);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  margin: 0 16px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.login-logo p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
}

.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,80,22,0.1);
}

.login-error {
  display: block;
  font-size: 13px;
  color: #dc2626;
  margin-top: 6px;
  min-height: 18px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-group label {
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--accent-light); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ========== HEADER ========== */

.header {
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-subtitle {
  font-size: 13px;
  opacity: 0.8;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 20px;
}

.progress-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.progress-bar-mini {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #fff;
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}

.progress-text {
  font-size: 13px;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}

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

.online-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  background: rgba(255,255,255,0.15);
  padding: 4px 8px;
  border-radius: 12px;
}

.online-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.btn-icon {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-icon:hover { background: rgba(255,255,255,0.25); }

.btn-logout {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-logout:hover { background: rgba(220,38,38,0.8); }

/* ========== MONTH NAV ========== */

.month-nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  position: sticky;
  top: 52px;
  z-index: 90;
}

.month-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
}

.month-pills::-webkit-scrollbar { display: none; }

.month-pill {
  flex-shrink: 0;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.month-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.month-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.month-pill .pill-progress {
  font-size: 11px;
  opacity: 0.7;
  margin-left: 4px;
}

.month-pill.active .pill-progress { opacity: 0.85; }

/* ========== FILTER BAR ========== */

.filter-bar {
  display: flex;
  gap: 6px;
  padding: 10px 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.filter-btn {
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.filter-btn:hover { border-color: #999; }

.filter-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* ========== WEEK CARDS ========== */

.week-container {
  padding: 16px 20px 80px;
  max-width: 900px;
  margin: 0 auto;
}

.week-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  margin-bottom: 12px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.week-card:hover { box-shadow: var(--card-shadow-hover); }

.week-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  gap: 14px;
}

.week-header:hover { background: rgba(0,0,0,0.01); }

.week-chevron {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 0.2s;
  color: var(--text-muted);
}

.week-card.expanded .week-chevron { transform: rotate(90deg); }

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

.week-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.week-theme {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.week-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.week-progress-bar {
  width: 80px;
  height: 5px;
  background: var(--not-started-bg);
  border-radius: 3px;
  overflow: hidden;
}

.week-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
  background: linear-gradient(90deg, var(--done), var(--posted));
}

.week-progress-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
}

.week-counts {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.count-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

.count-badge.working { background: var(--working-bg); color: #92400e; }
.count-badge.done { background: var(--done-bg); color: #065f46; }
.count-badge.posted { background: var(--posted-bg); color: #3730a3; }

/* ========== TASK LIST ========== */

.week-tasks {
  display: none;
  border-top: 1px solid var(--border);
}

.week-card.expanded .week-tasks { display: block; }

.task-group {
  padding: 0;
}

.task-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.task-group-header .type-icon {
  width: 16px;
  height: 16px;
}

.task-row {
  display: flex;
  align-items: center;
  padding: 8px 18px;
  gap: 12px;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.15s;
}

.task-row:hover { background: #fafaf8; }

.task-row:last-child { border-bottom: none; }

.task-name {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
  min-width: 0;
}

.task-specs {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Reference Pills ---- */
.task-refs {
  display: inline-flex;
  gap: 4px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.ref-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  letter-spacing: 0.3px;
  line-height: 16px;
}

.ref-pill:hover {
  transform: scale(1.08);
  filter: brightness(0.92);
}

.ref-pill.ref-graphic {
  background: #dbeafe;
  color: #1e40af;
}

.ref-pill.ref-video {
  background: #fce7f3;
  color: #9d174d;
}

.ref-pill.ref-caption {
  background: #fef3c7;
  color: #92400e;
}

.ref-pill.ref-story {
  background: #e0e7ff;
  color: #3730a3;
}

.ref-pill svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

/* ---- Highlight Animation ---- */
.task-row.highlight {
  animation: highlightPulse 1.5s ease;
}

@keyframes highlightPulse {
  0% { background: #fef08a; }
  100% { background: transparent; }
}

.status-badge {
  flex-shrink: 0;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-badge:active { transform: scale(0.95); }

.status-badge.not_started {
  background: var(--not-started-bg);
  color: var(--not-started);
}

.status-badge.working {
  background: var(--working-bg);
  color: #92400e;
}

.status-badge.done {
  background: var(--done-bg);
  color: #065f46;
}

.status-badge.posted {
  background: var(--posted-bg);
  color: #3730a3;
}

/* Task row filtered out */
.task-row.filtered-out { display: none; }

/* ========== COMMENTS ========== */

.task-row {
  flex-wrap: wrap;
}

.comment-toggle {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 3px 8px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  transition: all 0.15s;
  line-height: 1;
}

.comment-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.comment-toggle.has-comments {
  border-color: var(--accent);
  color: var(--accent);
}

.comment-count {
  font-size: 11px;
  font-weight: 700;
  min-width: 14px;
  text-align: center;
}

.comment-section {
  display: none;
  flex-basis: 100%;
  padding: 8px 0 4px;
  margin-top: 4px;
  border-top: 1px dashed var(--border);
}

.task-row.comments-open .comment-section {
  display: block;
}

.comment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
}

.comment-text {
  flex: 1;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}

.comment-date {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.comment-delete {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.15s;
}

.comment-delete:hover {
  color: #dc2626;
  background: #fef2f2;
}

.comment-input-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.comment-input {
  flex: 1;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.comment-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(45,80,22,0.08);
}

.comment-add-btn {
  flex-shrink: 0;
  padding: 5px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

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

/* ========== EMPTY STATE ========== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
}

/* ========== RESPONSIVE ========== */

@media (max-width: 768px) {
  .header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .header-center {
    order: 3;
    flex-basis: 100%;
    padding: 4px 0 0;
  }

  .progress-summary { min-width: unset; width: 100%; }

  .header-title { font-size: 17px; }
  .header-subtitle { display: none; }

  .month-nav {
    padding: 10px 14px;
    top: 82px;
  }

  .week-container { padding: 12px 14px 80px; }

  .week-header { padding: 12px 14px; gap: 10px; }

  .week-title { font-size: 14px; }

  .week-progress-bar { width: 50px; }

  .week-counts { display: none; }

  .task-row { padding: 8px 14px; gap: 8px; }

  .task-group-header { padding: 8px 14px 4px; }

  .status-badge {
    padding: 4px 10px;
    font-size: 10px;
  }

  .comment-toggle {
    padding: 2px 6px;
    font-size: 12px;
  }

  .comment-input {
    font-size: 14px;  /* prevent iOS zoom */
    padding: 6px 10px;
  }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 24px; }

  .header-right { gap: 4px; }

  .btn-icon { width: 30px; height: 30px; }

  .btn-logout {
    padding: 5px 10px;
    font-size: 12px;
  }

  .online-badge { padding: 3px 6px; font-size: 11px; }

  .month-pill { padding: 6px 12px; font-size: 12px; }

  .filter-btn { padding: 4px 10px; font-size: 11px; }
}

/* ========== TOAST ========== */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1a1a1a;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
