/* ─── FreelanceFlow — Design System (Full-Screen PWA) ─── */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=DM+Mono:wght@400;500&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --font-sans: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;

  --bg-primary:    #FFFFFF;
  --bg-secondary:  #F5F5F7;
  --bg-tertiary:   #EBEBED;

  --text-primary:   #1C1C1E;
  --text-secondary: #6C6C70;
  --text-tertiary:  #AEAEB2;

  --border-primary:   rgba(0,0,0,0.08);
  --border-secondary: rgba(0,0,0,0.12);

  --blue:       #185FA5;
  --blue-light: #E6F1FB;
  --blue-mid:   #B5D4F4;
  --blue-dark:  #0C447C;

  --green:       #3B6D11;
  --green-light: #EAF3DE;

  --amber:       #854F0B;
  --amber-light: #FAEEDA;

  --red:       #A32D2D;
  --red-light: #FCEBEB;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 30px;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sheet: 0 -8px 32px rgba(0,0,0,0.12);

  /* Safe area for notched phones */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  height: 100%;
  /* prevent iOS bounce / overscroll */
  overscroll-behavior: none;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  height: 100%;
  overflow: hidden;
  /* fills entire screen */
  display: flex;
  flex-direction: column;
}

/* ─── App Shell (replaces .phone / .screen) ─── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  /* full viewport, respecting notch */
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  position: relative;
  overflow: hidden;
  background: var(--bg-secondary);
}

/* ─── Top Bar ─── */
.topbar {
  background: var(--bg-primary);
  padding: 14px 20px 12px;
  border-bottom: 0.5px solid var(--border-primary);
  flex-shrink: 0;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.page-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0.5px solid var(--border-primary);
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 18px;
  transition: background .15s, transform .1s;
}

.icon-btn:active {
  background: var(--bg-secondary);
  transform: scale(0.93);
}

/* ─── Content / Scroll ─── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 84px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

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

/* ─── Pages ─── */
.page { display: none; }
.page.active { display: block; }

/* ─── Sections ─── */
.section {
  padding: 16px 16px 0;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 10px;
}

/* ─── Metric Cards ─── */
.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border-primary);
  padding: 14px;
  box-shadow: var(--shadow-card);
}

.metric-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 5px;
  font-weight: 500;
}

.metric-val {
  font-size: 19px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
}

.metric-change {
  font-size: 11px;
  margin-top: 3px;
  color: var(--text-tertiary);
}

/* ─── Cards & Lists ─── */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border-primary);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--border-primary);
  cursor: pointer;
  transition: background .12s;
}

.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--bg-secondary); }

.li-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-right: 12px;
  flex-shrink: 0;
}

.li-main { flex: 1; min-width: 0; }

.li-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.li-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.li-right {
  text-align: right;
  flex-shrink: 0;
  margin-left: 8px;
}

.li-amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ─── Badges ─── */
.li-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  margin-top: 3px;
}

.badge-paid    { background: var(--green-light); color: var(--green); }
.badge-pending { background: var(--amber-light); color: var(--amber); }
.badge-overdue { background: var(--red-light);   color: var(--red);   }
.badge-foreign { background: var(--blue-light);  color: var(--blue);  }

/* ─── Avatar ─── */
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  margin-right: 12px;
}

/* ─── FAB ─── */
.fab {
  position: fixed;
  bottom: calc(72px + var(--safe-bottom) + 16px);
  right: 18px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(24,95,165,0.4);
  transition: background .15s, transform .1s, box-shadow .15s;
}

.fab:active {
  background: var(--blue-dark);
  transform: scale(0.93);
  box-shadow: 0 2px 8px rgba(24,95,165,0.3);
}

/* ─── Bottom Nav ─── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-primary);
  border-top: 0.5px solid var(--border-primary);
  display: flex;
  padding: 8px 0;
  padding-bottom: calc(8px + var(--safe-bottom));
  z-index: 20;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  padding: 4px 0;
  transition: opacity .1s;
}

.nav-item:active { opacity: 0.6; }

.nav-icon {
  font-size: 22px;
  color: var(--text-tertiary);
  transition: color .15s;
}

.nav-label {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 500;
  transition: color .15s;
}

.nav-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--blue);
  margin: 0 auto;
  display: none;
}

.nav-item.active .nav-icon,
.nav-item.active .nav-label { color: var(--blue); }
.nav-item.active .nav-dot   { display: block; }

/* ─── Quick Actions ─── */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.qa-btn {
  background: var(--bg-primary);
  border: 0.5px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background .12s;
  box-shadow: var(--shadow-card);
}

.qa-btn:active { background: var(--bg-secondary); }

.qa-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.qa-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ─── Chart ─── */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 160px;
  padding: 0 16px 16px;
}

.seg-ctrl {
  display: flex;
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 3px;
  margin: 10px 16px;
}

.seg-opt {
  flex: 1;
  text-align: center;
  padding: 5px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
}

.seg-opt.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 0.5px solid var(--border-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ─── Bottom Sheets ─── */
.sheet-bg {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
}

.sheet-bg.open { display: flex; flex-direction: column; justify-content: flex-end; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sheet {
  position: relative;
  background: var(--bg-primary);
  border-radius: 26px 26px 0 0;
  padding: 20px 20px 24px;
  padding-bottom: calc(24px + var(--safe-bottom));
  box-shadow: var(--shadow-sheet);
  max-height: 85vh;
  overflow-y: auto;
  z-index: 1;
}

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

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  margin: 0 auto 18px;
}

.sheet-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Form Fields ─── */
.field { margin-bottom: 13px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  height: 44px;
  border: 0.5px solid var(--border-secondary);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 16px; /* 16px prevents iOS zoom on focus */
  font-family: var(--font-sans);
  padding: 0 12px;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}

.field textarea {
  height: 68px;
  padding: 10px 12px;
  resize: none;
  font-size: 16px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24,95,165,0.1);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ─── Buttons ─── */
.cta-btn {
  width: 100%;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--blue);
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  margin-top: 6px;
  letter-spacing: -0.1px;
  transition: background .15s, transform .1s;
}

.cta-btn:active {
  background: var(--blue-dark);
  transform: scale(0.98);
}

.cta-btn:disabled {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
}

.sec-btn {
  width: 100%;
  height: 44px;
  border-radius: var(--radius-md);
  background: none;
  border: 0.5px solid var(--border-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  margin-top: 10px;
  transition: background .15s;
}

.sec-btn:active { background: var(--bg-secondary); }

/* ─── Empty States ─── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-tertiary);
}

.empty-icon {
  font-size: 30px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.5;
}

.empty-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ─── Banner ─── */
.banner {
  background: var(--blue-light);
  border-radius: var(--radius-md);
  padding: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.banner-icon { font-size: 18px; color: var(--blue); flex-shrink: 0; margin-top: 1px; }
.banner-text { font-size: 12px; color: var(--blue-dark); line-height: 1.5; }

/* ─── Screen reader only ─── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ─── Desktop layout (≥ 600px) ─── */
@media (min-width: 600px) {
  body {
    background: #1C1C1E;
    align-items: center;
    justify-content: center;
  }

  #app {
    width: 390px;
    height: 844px;
    max-height: 100vh;
    border-radius: 46px;
    overflow: hidden;
    box-shadow:
      0 32px 80px rgba(0,0,0,0.6),
      0 8px 24px rgba(0,0,0,0.4);
    padding-top: 0;
    padding-bottom: 0;
  }

  .bottom-nav {
    position: absolute;
  }

  .fab {
    position: absolute;
    bottom: calc(72px + 16px);
  }

  .sheet-bg {
    position: absolute;
  }
}

/* ─── Large desktop (≥ 1024px) — side-by-side ─── */
@media (min-width: 1024px) {
  body {
    padding: 40px;
  }
}
