@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;700&family=IBM+Plex+Sans:wght@400;500&display=swap');

:root {
  --teal: #1B4D3E;
  --teal-light: #E1F5EE;
  --teal-mid: #B7DDD0;
  --marigold: #E8A33D;
  --marigold-text: #4A2E0A;
  --bg: #F7F5F0;
  --ink: #1C1C1C;
  --muted: #6B6B63;
  --line: #E4E1D6;
  --success: #1F7A44;
  --success-light: #E3F3E8;
  --marigold-light: #FBEBD2;
  --pending: #A87F2E;
  --danger: #B54A3F;
  --card-radius: 14px;
  --control-radius: 8px;
  --font-heading: 'Manrope', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 84px; /* space for bottom nav */
}

h1, h2, h3, .heading {
  font-family: var(--font-heading);
  font-weight: 500;
  margin: 0;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
}

/* Passbook balance header */
.passbook-header {
  background: var(--teal);
  padding: 20px 18px 24px;
  position: relative;
}
.passbook-header .greeting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.passbook-header .greeting span { color: var(--teal-light); font-size: 13px; font-family: var(--font-heading); }
.avatar-badge {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--marigold);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 500; color: var(--marigold-text);
}
.balance-label { color: var(--teal-mid); font-size: 12px; margin-bottom: 4px; }
.balance-amount { color: #fff; font-size: 34px; font-weight: 500; font-family: var(--font-heading); letter-spacing: -0.5px; }
.balance-usd { color: var(--teal-mid); font-size: 12px; margin-top: 2px; }
.perforation {
  height: 10px;
  background: repeating-linear-gradient(90deg, var(--bg) 0 6px, transparent 6px 12px);
  margin-top: -10px;
  position: relative;
  z-index: 1;
}

/* Buttons */
.btn {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 13px;
  border: none;
  border-radius: var(--control-radius);
  padding: 10px 18px;
  cursor: pointer;
}
.btn-primary { background: var(--marigold); color: var(--marigold-text); }
.btn-outline { background: transparent; border: 1px solid var(--teal); color: var(--teal); }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tab-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.tab-btn.active { background: var(--teal); border-color: var(--teal); color: #fff; }

/* Ledger list */
.ledger-section { padding: 16px 18px 20px; }
.ledger-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ledger-title-row .heading { font-size: 13px; }
.ledger-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 0.5px solid var(--line);
}
.ledger-row:last-child { border-bottom: none; }
.ledger-desc { font-size: 13px; color: var(--ink); }
.ledger-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ledger-amount { font-size: 13px; font-weight: 500; text-align: right; }
.amount-approved { color: var(--success); }
.amount-pending { color: var(--pending); }
.amount-negative { color: var(--danger); }

/* Task / status stamp */
.stamp {
  display: inline-block; font-size: 10px; font-weight: 500;
  padding: 2px 8px; border-radius: 20px; font-family: var(--font-heading);
}
.stamp-approved { background: #E4F2E8; color: var(--success); }
.stamp-pending { background: #F7EBD6; color: var(--pending); }
.stamp-rejected { background: #F5E1DE; color: var(--danger); }

/* Cards */
.card {
  background: #fff;
  border: 0.5px solid var(--line);
  border-radius: var(--card-radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card-title { font-size: 14px; font-weight: 500; font-family: var(--font-heading); }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-family: var(--font-heading); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--control-radius);
  font-family: var(--font-body); background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 80px; }
.error-text { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-top: none;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -4px 20px rgba(28, 28, 28, 0.09);
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  text-decoration: none;
  color: #A6A498;
  font-size: 11px;
  font-family: var(--font-heading);
}
.bottom-nav a.active { color: var(--teal); font-weight: 500; }
.bottom-nav .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 32px;
  border-radius: 16px;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.bottom-nav a.active .nav-icon {
  background: var(--teal-light);
  transform: translateY(-1px);
}
.bottom-nav i { font-size: 24px; line-height: 1; }

.page-content { padding: 16px 18px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 13px; }

/* Top header bar (brand + logout) — user dashboard pages */
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 0.5px solid var(--line);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 15px;
  color: var(--teal);
}
.topbar-brand .topbar-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--marigold);
  display: inline-block;
}
.topbar-logout {
  display: flex; align-items: center; gap: 6px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font-heading);
  font-size: 12px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--control-radius);
}
.topbar-logout i { font-size: 16px; }
.topbar-logout:hover { background: var(--teal-light); color: var(--teal); }

/* Slot progress bar (task listings) */
.slot-progress { margin: 8px 0; }
.slot-progress-bar {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.slot-progress-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.slot-progress-fill.full { background: var(--danger); }
.slot-progress-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* Task type category badges */
.task-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 10px;
  font-size: 15px;
  flex-shrink: 0;
}
.task-type-badge.type-social { background: var(--teal-light); color: var(--teal); }
.task-type-badge.type-keyword { background: var(--marigold-light); color: var(--marigold); }
.task-type-badge.type-ai { background: var(--success-light); color: var(--success); }

/* Skeleton loading placeholders */
@keyframes tr-skeleton {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.skeleton-block {
  background: linear-gradient(90deg, var(--line) 25%, #efece0 37%, var(--line) 63%);
  background-size: 400% 100%;
  animation: tr-skeleton 1.4s ease infinite;
  border-radius: 6px;
}
.skeleton-card .skeleton-block { margin-bottom: 8px; }
.skeleton-card .skeleton-block:last-child { margin-bottom: 0; }
.skeleton-line-title { height: 14px; width: 55%; }
.skeleton-line-sub { height: 11px; width: 35%; }
.skeleton-line-text { height: 11px; width: 92%; }
.skeleton-line-btn { height: 36px; width: 100%; border-radius: var(--control-radius); margin-top: 10px; }
.skeleton-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--line);
}
.skeleton-row .skeleton-block:first-child { width: 55%; height: 13px; }
.skeleton-row .skeleton-block:last-child { width: 48px; height: 13px; }

/* Toast notifications */
@keyframes tr-toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes tr-toast-out { to { opacity: 0; transform: translateY(-10px); } }
.toast-container {
  position: fixed;
  top: 16px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 420px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 40;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 0.5px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: var(--control-radius);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(28, 28, 28, 0.12);
  pointer-events: auto;
  cursor: pointer;
  animation: tr-toast-in 0.2s ease-out;
}
.toast.toast-out { animation: tr-toast-out 0.16s ease-in forwards; }
.toast i { font-size: 18px; flex-shrink: 0; }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-success i { color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-error i { color: var(--danger); }

/* Loading spinner */
@keyframes tr-spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: tr-spin 0.7s linear infinite;
  vertical-align: -4px;
  margin-right: 6px;
}
.spinner.spinner-lg { width: 28px; height: 28px; border-width: 3px; }
.btn .spinner { border-color: rgba(255,255,255,0.4); border-top-color: #fff; margin-right: 8px; }
.btn-outline .spinner { border-color: var(--teal-mid); border-top-color: var(--teal); }

/* Modal (used by TaskRewardUI.confirm / .prompt and page-level modals) */
@keyframes tr-modal-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 24, 22, 0.42);
  backdrop-filter: blur(6px) saturate(140%);
  -webkit-backdrop-filter: blur(6px) saturate(140%);
  padding: 20px;
  z-index: 30;
}
.modal-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--card-radius);
  padding: 20px;
  width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(28, 28, 28, 0.18);
  animation: tr-modal-in 0.16s ease-out;
}
.modal-title { font-size: 16px; margin-bottom: 6px; }
.modal-message { font-size: 13px; color: var(--muted); margin-bottom: 16px; line-height: 1.5; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn { flex: 1; }

/* Site footer */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 18px 18px 8px;
}
/* Pages with the fixed bottom nav (user dashboard, mobile/tablet)
   need extra clearance so the footer text isn't pinched against the
   floating nav card. */
body.has-sidebar .site-footer { margin-bottom: 24px; }

/* ============================================================
   Responsive layout — tablet and desktop
   Mobile (default, up to 767px): unchanged single-column app
   with a fixed bottom nav bar.
   ============================================================ */

/* Tablet: 768px and up */
@media (min-width: 768px) {
  .app { max-width: 720px; }
  .page-content { padding: 24px 32px; }
  .passbook-header { padding: 28px 32px 32px; }
  .ledger-section { padding: 20px 32px 24px; }
  .topbar { padding: 16px 32px; }

  /* Login/register cards get a bit more breathing room and don't
     stretch edge-to-edge on a wider viewport */
  .auth-content { padding-top: 80px; max-width: 420px; margin: 0 auto; }

  /* Let card grids breathe on tablet */
  #tab-available, #cashouts-list, #submissions-list, #review-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    align-items: start;
  }
  #tab-available .card, #cashouts-list .card, #submissions-list .card, #review-list .card {
    margin-bottom: 0;
  }
}

/* Desktop: 1024px and up */
@media (min-width: 1024px) {
  /* Only pages that actually render a sidebar nav (body.has-sidebar,
     set via bodyClass on pages that include bottom-nav.ejs) get the
     left gutter. Admin (top tabs, no sidebar) and auth pages are
     unaffected, so they no longer get a blank 232px left margin. */
  body.has-sidebar { padding-bottom: 0; padding-left: 232px; }
  body.has-sidebar .site-footer { margin-bottom: 0; }

  .app { max-width: 960px; margin: 0 auto; }

  /* Turn the bottom tab bar into a fixed left sidebar */
  body.has-sidebar .bottom-nav {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: none;
    width: 232px; max-width: 232px;
    height: 100vh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    border-top: none;
    border-right: 0.5px solid var(--line);
    padding: 28px 14px;
  }
  body.has-sidebar .bottom-nav a {
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    font-size: 14px;
    padding: 10px 14px;
    border-radius: var(--control-radius);
  }
  body.has-sidebar .bottom-nav a.active { background: var(--teal-light); }
  body.has-sidebar .bottom-nav i { font-size: 18px; margin-bottom: 0; }
  body.has-sidebar .bottom-nav .nav-icon {
    width: auto; height: auto; border-radius: 0;
    background: transparent !important; transform: none;
  }

  .page-content { padding: 32px 40px; }
  .passbook-header { padding: 36px 40px 40px; }
  .ledger-section { padding: 24px 40px 28px; }
  .topbar { padding: 18px 40px; }

  /* Wider, more spacious card grids */
  #tab-available, #cashouts-list, #submissions-list, #review-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  /* Admin nav can spread out instead of forcing horizontal scroll */
  .admin-nav-tabs { overflow-x: visible; flex-wrap: wrap; }
}

/* Large desktop: 1440px and up */
@media (min-width: 1440px) {
  .app { max-width: 1140px; }
}
