/* ═══════════════════════════════════════════════════════════════════════════
   ASO Society — MC Task Tracker
   Mobile-first design system
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset & Variables ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a237e;
  --primary-light: #283593;
  --accent: #3949ab;
  --success: #2e7d32;
  --warning: #f57f17;
  --danger: #c62828;
  --info: #1565c0;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #333333;
  --text-muted: #888888;
  --border: #e0e0e0;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.06);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --topbar-h: 52px;
  --bottombar-h: 64px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-top: var(--topbar-h);
  padding-bottom: calc(var(--bottombar-h) + var(--safe-bottom));
}

a { color: var(--primary); text-decoration: none; }
a:active { opacity: 0.7; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }

/* ── Top Bar ───────────────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-h);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 2px 12px rgba(26,35,126,.25);
}
.topbar-brand {
  display: flex; align-items: center;
}
.topbar-logo {
  height: 34px; width: auto;
  background: #fff; border-radius: 6px; padding: 3px 8px;
}
.topbar-right {
  display: flex; align-items: center; gap: 12px;
}
.topbar-user {
  font-size: .85em; opacity: .9; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #fff;
}
.topbar-logout { color: rgba(255,255,255,.7); display: flex; align-items: center; margin: 0; }
.topbar-logout:hover { color: #fff; }
.topbar-logout-btn {
  background: none; border: none; padding: 0; margin: 0; cursor: pointer;
  color: inherit; display: flex; align-items: center; font: inherit;
}

/* ── Bottom Bar (mobile nav) ───────────────────────────────────────────── */
.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--bottombar-h);
  background: #fff;
  display: flex; align-items: center; justify-content: space-around;
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
.bottombar-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; color: var(--text-muted); font-size: .7em;
  padding: 6px 12px; border-radius: 8px; transition: color .15s;
  min-width: 56px; text-align: center;
}
.bottombar-item.active { color: var(--primary); font-weight: 600; }
.bottombar-item.fab {
  background: var(--primary); color: #fff;
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-top: -24px; box-shadow: 0 4px 16px rgba(26,35,126,.35);
  font-size: 0;
}
.bottombar-item.fab span { display: none; }

/* ── Main Content ──────────────────────────────────────────────────────── */
.main-content {
  padding: 16px; max-width: 800px; margin: 0 auto;
}

/* ── Flash Messages ────────────────────────────────────────────────────── */
.flash-container {
  position: fixed; top: calc(var(--topbar-h) + 8px); left: 16px; right: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.flash {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: .9em; font-weight: 500;
  animation: slideDown 0.25s ease-out;
  box-shadow: var(--shadow);
}
.flash-success { background: #e8f5e9; color: var(--success); border: 1px solid #a5d6a7; }
.flash-error { background: #ffebee; color: var(--danger); border: 1px solid #ef9a9a; }
.flash-info { background: #e3f2fd; color: var(--info); border: 1px solid #90caf9; }
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Page Header ───────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.page-header h1 { font-size: 1.4em; color: var(--primary); }
.page-header .subtitle { font-size: .85em; color: var(--text-muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; }

/* ── Stat Strip ────────────────────────────────────────────────────────── */
.stat-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 20px;
}
.stat-item {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 8px; text-align: center; box-shadow: var(--shadow);
}
.stat-val { font-size: 1.6em; font-weight: 800; display: block; line-height: 1.1; }
.stat-label { font-size: .72em; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }
.stat-open .stat-val { color: #e65100; }
.stat-overdue .stat-val { color: var(--danger); }
.stat-resolved .stat-val { color: var(--success); }
.stat-total .stat-val { color: var(--primary); }

/* ── Tile Grid ─────────────────────────────────────────────────────────── */
.tile-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.tile {
  background: var(--card); border-radius: var(--radius);
  padding: 20px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: flex-start;
  transition: transform .1s, box-shadow .1s;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  position: relative; overflow: hidden;
}
.tile:active { transform: scale(0.97); }
.tile-icon { font-size: 1.8em; margin-bottom: 8px; }
.tile-title { font-weight: 700; font-size: .95em; color: var(--text); margin-bottom: 2px; }
.tile-sub { font-size: .78em; color: var(--text-muted); }
.tile-primary { border-top: 3px solid var(--primary); }
.tile-accent { border-top: 3px solid var(--accent); }
.tile-warning { border-top: 3px solid var(--warning); }
.tile-danger { border-top: 3px solid var(--danger); }
.tile-info { border-top: 3px solid var(--info); }
.tile-analytics { border-top: 3px solid var(--success); }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card h3 { font-size: 1em; color: var(--primary); margin-bottom: 12px; }
.card-body { font-size: .9em; line-height: 1.6; white-space: pre-wrap; }

/* ── Task List ─────────────────────────────────────────────────────────── */
.task-count { font-size: .82em; color: var(--text-muted); margin-bottom: 10px; }
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
  display: block; transition: transform .1s;
  border-left: 3px solid var(--border);
}
.task-card:active { transform: scale(0.98); }
.task-card.overdue { border-left-color: var(--danger); }
.task-card.due-soon { border-left-color: var(--warning); }
.task-card.on-track { border-left-color: var(--success); }
.task-card.resolved { border-left-color: var(--text-muted); opacity: .85; }
.task-card-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap;
}
.task-id { font-size: .78em; color: var(--text-muted); font-weight: 600; }
.task-category {
  font-size: .72em; background: #e8eaf6; color: var(--primary);
  padding: 2px 8px; border-radius: 8px; font-weight: 600;
}
.task-comments { font-size: .78em; color: var(--text-muted); margin-left: auto; }
.task-card-title {
  font-size: .92em; font-weight: 600; color: var(--text);
  margin-bottom: 8px; line-height: 1.4;
}
.task-card-footer {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: .78em;
}
.task-due { color: var(--text-muted); }
.task-due.due-overdue { color: var(--danger); font-weight: 600; }
.task-due.due-soon { color: var(--warning); font-weight: 600; }
.task-assignee { color: var(--text-muted); margin-left: auto; }

/* ── Priority Dots & Badges ────────────────────────────────────────────── */
.priority-dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.priority-critical { background: var(--danger); }
.priority-high { background: #e65100; }
.priority-medium { background: var(--warning); }
.priority-low { background: var(--success); }
.priority-badge {
  font-size: .72em; padding: 2px 8px; border-radius: 8px; font-weight: 700;
}
.priority-badge.priority-critical { background: #ffebee; color: var(--danger); }
.priority-badge.priority-high { background: #fff3e0; color: #e65100; }
.priority-badge.priority-medium { background: #fff8e1; color: var(--warning); }
.priority-badge.priority-low { background: #e8f5e9; color: var(--success); }

/* ── Status Chips ──────────────────────────────────────────────────────── */
.task-status, .status-chip {
  display: inline-block;
  font-size: .72em; padding: 3px 10px; border-radius: 10px; font-weight: 700;
}
.status-pending { background: #f5f5f5; color: #666; }
.status-told-pms { background: #e3f2fd; color: var(--info); }
.status-in-progress { background: #fff3e0; color: #e65100; }
.status-resolved { background: #e8f5e9; color: var(--success); }
.status-verified { background: #e8eaf6; color: var(--primary); }
.status-closed { background: #f5f5f5; color: #999; }

/* ── Filter Bar ────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center;
}
.filter-search {
  flex: 1; min-width: 120px;
  padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .9em; outline: none;
  background: var(--card); -webkit-appearance: none;
}
.filter-search:focus { border-color: var(--primary); }
.filter-select {
  padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .85em; outline: none;
  background: var(--card); color: var(--text); -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}
.filter-toggle {
  font-size: .82em; display: flex; align-items: center; gap: 4px;
  color: var(--text-muted); cursor: pointer;
}

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: .82em; font-weight: 600;
  color: var(--text-muted); margin-bottom: 4px;
}
.form-input, .form-textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: .92em; outline: none; background: var(--card);
  transition: border-color .15s; -webkit-appearance: none;
}
.form-input:focus, .form-textarea:focus { border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 12px; }
.form-half { flex: 1; }
select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 20px; border-radius: var(--radius);
  font-size: .9em; font-weight: 600; border: none; cursor: pointer;
  transition: opacity .15s, transform .1s; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: .82em; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }

/* ── Status Update Buttons ─────────────────────────────────────────────── */
.status-form { margin-top: 4px; }
.status-buttons {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.status-btn {
  flex: 1; min-width: 70px;
  padding: 8px 6px; border-radius: 8px;
  font-size: .72em; font-weight: 700; border: 1.5px solid var(--border);
  background: var(--card); color: var(--text-muted);
  cursor: pointer; transition: all .15s; text-align: center;
}
.status-btn.active {
  border-color: var(--primary); background: var(--primary); color: #fff;
}
.status-btn.status-btn-pending { color: #666; }
.status-btn.status-btn-told-pms { color: var(--info); }
.status-btn.status-btn-in-progress { color: #e65100; }
.status-btn.status-btn-resolved { color: var(--success); }
.status-btn.status-btn-verified { color: var(--primary); }
.status-btn.status-btn-closed { color: #999; }
.status-btn:hover:not(:disabled):not(.active) {
  border-color: currentColor; background: #f5f5f5;
}

/* ── Action Bar ────────────────────────────────────────────────────────── */
.action-bar {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}

/* ── Task Detail Header ────────────────────────────────────────────────── */
.task-detail-header { margin-bottom: 16px; }
.back-link {
  display: inline-block; font-size: .85em; color: var(--text-muted);
  margin-bottom: 10px; font-weight: 500;
}
.task-detail-meta {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap;
}
.task-id-big { font-size: .82em; color: var(--text-muted); font-weight: 700; }
.task-detail-title { font-size: 1.2em; font-weight: 700; margin-bottom: 8px; color: var(--text); line-height: 1.3; }
.task-detail-info {
  display: flex; gap: 10px; flex-wrap: wrap; font-size: .78em; color: var(--text-muted);
}
.text-danger { color: var(--danger) !important; font-weight: 600; }

/* ── Timeline ──────────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 16px; display: flex; gap: 10px; }
.timeline-item:last-child { margin-bottom: 0; }
.timeline-marker { width: 16px; flex-shrink: 0; display: flex; justify-content: center; padding-top: 4px; }
.marker-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 2px var(--border);
}
.marker-status { background: var(--primary); }
.marker-comment { background: var(--info); }
.timeline-content { flex: 1; min-width: 0; }
.timeline-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 4px; flex-wrap: wrap;
}
.timeline-head strong { font-size: .85em; }
.timeline-date { font-size: .72em; color: var(--text-muted); white-space: nowrap; }
.timeline-task-link { font-weight: 600; font-size: .88em; }
.timeline-status-change {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.timeline-note { font-size: .82em; color: var(--text-muted); }
.timeline-comment-text { font-size: .85em; line-height: 1.5; margin-bottom: 4px; }
.timeline-role-badge {
  font-size: .65em; padding: 1px 6px; border-radius: 6px; font-weight: 700;
}
.role-mc { background: #e8eaf6; color: var(--primary); }
.role-pms { background: #e3f2fd; color: var(--info); }
.role-admin { background: #fff3e0; color: var(--warning); }
.timeline-empty { text-align: center; color: var(--text-muted); padding: 20px 0; font-size: .9em; }
.timeline-detail { font-size: .85em; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── Reminders ─────────────────────────────────────────────────────────── */
.reminder-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.reminder-chip {
  font-size: .75em; padding: 4px 10px; border-radius: 12px;
  background: #fff3e0; color: #e65100; font-weight: 500;
}
.reminder-chip.sent { background: #f5f5f5; color: #999; }
.inline-form { display: flex; gap: 8px; align-items: center; }

/* ── Empty State ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 20px;
}
.empty-icon { font-size: 3em; margin-bottom: 12px; }
.empty-state p { font-size: .95em; color: var(--text-muted); margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }

/* ── Error Page ────────────────────────────────────────────────────────── */
.error-page { text-align: center; padding: 60px 20px; }
.error-code { font-size: 5em; font-weight: 900; color: var(--primary); opacity: .2; line-height: 1; }
.error-page h1 { font-size: 1.3em; color: var(--text); margin: 12px 0; }
.error-page p { color: var(--text-muted); margin-bottom: 20px; }

/* ── Auth Page (Login) ─────────────────────────────────────────────────── */
.auth-page {
  background: linear-gradient(135deg, #1a237e, #283593);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-container { width: 100%; max-width: 380px; }
.auth-card {
  background: #fff; border-radius: 16px; padding: 32px 24px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25); text-align: center;
}
.auth-logo { margin-bottom: 12px; }
.auth-card h1 { color: var(--primary); font-size: 1.4em; margin-bottom: 2px; }
.auth-card .subtitle { color: var(--text-muted); font-size: .9em; margin-bottom: 24px; }
.auth-card .form-group { margin-bottom: 14px; text-align: left; }
.auth-card .form-group label { font-size: .8em; }
.auth-card .form-input { font-size: .95em; padding: 13px 16px; }
.auth-footer { font-size: .75em; color: var(--text-muted); margin-top: 20px; }

/* ── Role Badge ────────────────────────────────────────────────────────── */
.role-badge {
  font-size: .7em; padding: 3px 10px; border-radius: 10px; font-weight: 800;
  letter-spacing: .5px;
}
.role-mc { background: #e8eaf6; color: var(--primary); }
.role-pms { background: #e3f2fd; color: var(--info); }
.role-admin { background: #fff3e0; color: var(--warning); }

/* ── Mobile Header ─────────────────────────────────────────────────────── */
.mobile-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.mobile-header h1 { font-size: 1.3em; color: var(--primary); }

/* ── Section ───────────────────────────────────────────────────────────── */
.section { margin-bottom: 24px; }
.section-title { font-size: .95em; color: var(--primary); margin-bottom: 10px; font-weight: 700; }

/* ── Activity List (recent) ────────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 1px; }
.activity-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--card); border-radius: 8px;
  font-size: .82em; transition: background .1s;
}
.activity-item:active { background: #f5f5f5; }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--text-muted);
}
.activity-dot.status-in-progress { background: #e65100; }
.activity-dot.status-resolved { background: var(--success); }
.activity-dot.status-verified { background: var(--primary); }
.activity-dot.status-closed { background: #999; }
.activity-dot.status-pending { background: #bbb; }
.activity-dot.status-told-pms { background: var(--info); }
.activity-body { flex: 1; min-width: 0; }
.activity-title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-meta { display: block; color: var(--text-muted); font-size: .88em; margin-top: 1px; }
.activity-time { font-size: .78em; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (min-width: 768px) {
  .main-content { padding: 24px; }
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-strip { grid-template-columns: repeat(4, 1fr); }
  .stat-val { font-size: 2em; }
  .bottombar-item { font-size: .75em; }
  .task-detail-title { font-size: 1.4em; }
}

@media (min-width: 1024px) {
  .main-content { max-width: 900px; }
}