/* ============================================================
   PI Team App — Shared Stylesheet
   Design tokens match peoplesinitiative.org
   ============================================================ */

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

:root {
  --navy:   #1B2A6B;
  --navy2:  #2a3f96;
  --red:    #C8102E;
  --red2:   #a50d26;
  --bg:     #F4F6FA;
  --white:  #ffffff;
  --border: #dde2f0;
  --text:   #222;
  --muted:  #666;
  --success:#16a34a;
  --warn:   #d97706;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(27,42,107,.10);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ── Layout ─────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-rows: 60px 1fr;
  min-height: 100vh;
}

.main-content {
  padding: 28px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ── Top Nav ─────────────────────────────────────────────── */
.top-nav {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
}

.top-nav .logo {
  height: 36px;
  width: auto;
}

.top-nav .app-name {
  color: var(--white);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: .02em;
  flex: 1;
  min-width: 0;
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  color: rgba(255,255,255,.78);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 600;
  transition: background .15s, color .15s;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,.15);
  color: var(--white);
}

.nav-bell {
  position: relative;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 1.15rem;
  transition: background .15s;
}

.nav-bell:hover { background: rgba(255,255,255,.15); }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--red);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.nav-logout {
  color: rgba(255,255,255,.7);
  background: none;
  border: 1px solid rgba(255,255,255,.3);
  padding: 5px 14px;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
}

.nav-logout:hover {
  background: rgba(255,255,255,.12);
  color: var(--white);
}

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
}

.page-header p {
  font-size: .9rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Stat tiles ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--navy);
}

.stat-card.red   { border-color: var(--red); }
.stat-card.green { border-color: var(--success); }
.stat-card.amber { border-color: var(--warn); }

.stat-card .stat-label {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}

.stat-card.red .stat-value   { color: var(--red); }
.stat-card.green .stat-value { color: var(--success); }
.stat-card.amber .stat-value { color: var(--warn); }

/* ── Cards / Panels ──────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ── Table ───────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  background: #f0f3fa;
  color: var(--navy);
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f3f8;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8f9fd; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
}

.badge-navy   { background: #e8eaf5; color: var(--navy); }
.badge-red    { background: #fde8ec; color: var(--red); }
.badge-green  { background: #dcfce7; color: var(--success); }
.badge-amber  { background: #fef3c7; color: var(--warn); }
.badge-gray   { background: #e5e7eb; color: #555; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}

.btn:hover  { opacity: .88; }
.btn:active { transform: scale(.97); }

.btn-primary { background: linear-gradient(135deg, var(--navy), var(--navy2)); color: #fff; }
.btn-red     { background: linear-gradient(135deg, var(--red), var(--red2));   color: #fff; }
.btn-ghost   { background: transparent; border: 1.5px solid var(--border); color: var(--navy); }
.btn-ghost:hover { background: #f0f3fa; }
.btn-sm      { padding: 5px 12px; font-size: .8rem; }
.btn-danger  { background: #fde8ec; color: var(--red); }
.btn-danger:hover { background: #fbd1da; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: .9rem;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s;
  appearance: auto;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--navy);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-error {
  color: var(--red);
  font-size: .82rem;
  margin-top: 4px;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.48);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,.22);
  transform: translateY(16px);
  transition: transform .2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--navy);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-close:hover { background: var(--bg); }

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Alert / Toast ───────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: #dcfce7; color: #15803d; border-left: 4px solid var(--success); }
.alert-error   { background: #fde8ec; color: var(--red); border-left: 4px solid var(--red); }
.alert-info    { background: #e8eaf5; color: var(--navy); border-left: 4px solid var(--navy); }

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 20px;
}

.filter-bar .form-group {
  margin-bottom: 0;
  min-width: 160px;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: .95rem;
}

/* ── Pending / Confirmed earnings ────────────────────────── */
.earnings-pending   { color: var(--warn);    font-weight: 700; }
.earnings-confirmed { color: var(--success); font-weight: 700; }

/* ── Notification items ──────────────────────────────────── */
.notif-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: background .12s;
}

.notif-item:last-child { border-bottom: none; }
.notif-item.unread { border-left: 3px solid var(--navy); background: #f5f7ff; }
.notif-item.unread:hover { background: #eff2ff; }
.notif-item.read   { border-left: 3px solid transparent; }

.notif-icon { font-size: 1.3rem; flex-shrink: 0; }

.notif-body .notif-title {
  font-weight: 700;
  font-size: .9rem;
  color: var(--navy);
}

.notif-body .notif-text {
  font-size: .83rem;
  color: var(--muted);
  margin-top: 2px;
}

.notif-body .notif-time {
  font-size: .75rem;
  color: #aaa;
  margin-top: 4px;
}

/* ── Shift card (user view) ──────────────────────────────── */
.shift-card {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  background: var(--white);
  transition: box-shadow .15s;
}

.shift-card:hover { box-shadow: 0 4px 16px rgba(27,42,107,.10); }

.shift-date-block {
  text-align: center;
  background: var(--navy);
  color: var(--white);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 52px;
  flex-shrink: 0;
}

.shift-date-block .shift-month { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .8; }
.shift-date-block .shift-day   { font-size: 1.4rem; font-weight: 800; line-height: 1; }

.shift-info { flex: 1; }
.shift-info .shift-location { font-weight: 700; font-size: .95rem; color: var(--navy); }
.shift-info .shift-time     { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.shift-info .shift-address  { font-size: .78rem; color: #999; margin-top: 1px; }

/* ── Chart containers ────────────────────────────────────── */
.chart-wrap { position: relative; height: 280px; }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(27,42,107,.2);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 10px;
  color: var(--muted);
}

/* ── Hamburger (hidden on desktop) ───────────────────────── */
.nav-hamburger { display: none; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 700px) {
  .main-content { padding: 14px 12px; }

  /* ── Nav ── */
  .top-nav { padding: 0 12px; gap: 8px; }
  .top-nav .logo { height: 28px; }
  .top-nav .app-name { font-size: .9rem; }
  .nav-hamburger {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 6px;
    flex-shrink: 0;
  }
  .nav-bell { font-size: 1rem; padding: 4px 6px; flex-shrink: 0; }
  .nav-logout { font-size: .72rem; padding: 4px 8px; flex-shrink: 0; white-space: nowrap; }
  .nav-links { display: none; }
  .nav-links.mobile-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--navy);
    padding: 12px 16px;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    z-index: 99;
  }
  .nav-links.mobile-open a { padding: 10px 12px; font-size: .9rem; }

  /* ── Page header ── */
  .page-header { margin-bottom: 16px; }
  .page-header h1 { font-size: 1.2rem; }
  .page-header .btn { font-size: .78rem; padding: 6px 12px; }

  /* ── Cards ── */
  .card { padding: 16px; margin-bottom: 14px; }
  .card-title { font-size: .9rem; }

  /* ── Stats ── */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 14px 16px; }
  .stat-card .stat-value { font-size: 1.4rem; }
  .stat-card .stat-label { font-size: .7rem; }

  /* ── Tables ── */
  .table-wrap { margin: 0 -16px; border-radius: 0; border-left: none; border-right: none; }
  table { font-size: .8rem; }
  thead th { padding: 8px 10px; font-size: .68rem; }
  tbody td { padding: 10px; }

  /* ── Forms ── */
  .form-row { grid-template-columns: 1fr; }
  .filter-bar { gap: 8px; }
  .filter-bar .form-group { min-width: 100%; }

  /* ── Modals ── */
  .modal-overlay { padding: 10px; }
  .modal { border-radius: 12px; }
  .modal-header { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }
  .modal-header h2 { font-size: 1rem; }

  /* ── Shifts ── */
  .shift-card { padding: 12px; gap: 12px; }

  /* ── Notifications ── */
  .notif-item { padding: 12px; }

  /* ── Charts ── */
  .chart-wrap { height: 220px; }
}

@media (max-width: 400px) {
  .stat-grid { grid-template-columns: 1fr; }
  .top-nav .app-name { display: none; }
  .modal-footer { flex-direction: column; }
  .modal-footer .btn { width: 100%; justify-content: center; }
}
