/* Pangea Biodiesel PWA — app.css */
/* Mobile-first. Pangea green + amber palette. */

:root {
  --green-dark:   #2D5A27;
  --green-mid:    #4A7C3F;
  --green-light:  #EAF2E8;
  --amber:        #C8860A;
  --amber-light:  #FDF4E3;
  --red:          #C0392B;
  --blue:         #1a3d5c;
  --gray-dark:    #1C1C1E;
  --gray-mid:     #555;
  --gray-light:   #F2F2F7;
  --white:        #FFFFFF;
  --radius:       12px;
  --shadow:       0 2px 12px rgba(0,0,0,0.10);
  --nav-height:   64px;
  --header-height: 56px;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --safe-top:     env(safe-area-inset-top, 0px);
}

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

/* ── App container ─────────────────────────────────────────────────────────── */
/* Override any theme styles inside our container */
#pbd-app {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--gray-dark);
  background: var(--gray-light);
  min-height: 100vh;
  padding-top: var(--header-height);
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

#pbd-app *, #pbd-app *::before, #pbd-app *::after {
  box-sizing: border-box;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.pbd-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--green-dark);
  padding-top: var(--safe-top);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.pbd-header-inner {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 16px;
  gap: 8px;
}

.pbd-logo { font-size: 22px; }
.pbd-header-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  color: var(--white);
  text-align: center;
}
.pbd-header-user {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  white-space: nowrap;
}

.pbd-back-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.9);
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  white-space: nowrap;
}

/* ── Bottom Navigation ─────────────────────────────────────────────────────── */
.pbd-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  height: calc(var(--nav-height) + var(--safe-bottom));
  background: var(--white);
  border-top: 1px solid #ddd;
  display: flex;
  padding-bottom: var(--safe-bottom);
}

.pbd-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-mid);
  font-size: 11px;
  padding: 6px 4px;
  transition: color 0.15s;
}
.pbd-nav-btn.active {
  color: var(--green-dark);
}
.pbd-nav-icon { font-size: 22px; line-height: 1; }
.pbd-nav-label { font-size: 10px; font-weight: 500; }

/* ── Main content ───────────────────────────────────────────────────────────── */
.pbd-main {
  padding: 12px 0 24px;
  max-width: 640px;
  margin: 0 auto;
}

/* ── Sections ───────────────────────────────────────────────────────────────── */
.pbd-section {
  background: var(--white);
  margin: 0 12px 12px;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.pbd-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.pbd-section-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-dark);
}
.pbd-section-header h3 { font-size: 14px; font-weight: 600; color: var(--gray-mid); }
.pbd-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-mid);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pbd-section-desc {
  font-size: 14px;
  color: var(--gray-mid);
  margin-bottom: 16px;
}

/* ── Stat Cards ─────────────────────────────────────────────────────────────── */
.pbd-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pbd-stat-card {
  border-radius: 10px;
  padding: 14px 12px;
  color: var(--white);
}
.pbd-stat-card--green       { background: var(--green-dark); }
.pbd-stat-card--green-light { background: var(--green-mid); }
.pbd-stat-card--amber       { background: var(--amber); }
.pbd-stat-card--blue        { background: var(--blue); }

.pbd-stat-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}
.pbd-stat-label {
  font-size: 11px;
  opacity: 0.85;
  margin-top: 4px;
  font-weight: 500;
}

/* ── Monthly Chart ──────────────────────────────────────────────────────────── */
.pbd-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 100px;
  padding: 0 4px;
  gap: 4px;
}
.pbd-chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 4px;
}
.pbd-chart-bar-label-top {
  font-size: 9px;
  color: var(--gray-mid);
  text-align: center;
  white-space: nowrap;
}
.pbd-chart-bar {
  width: 100%;
  background: var(--green-mid);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s;
}
.pbd-chart-bar-label {
  font-size: 10px;
  color: var(--gray-mid);
  text-align: center;
}

/* ── List items ─────────────────────────────────────────────────────────────── */
.pbd-list { display: flex; flex-direction: column; gap: 1px; }

.pbd-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--white);
  border-radius: 8px;
  gap: 10px;
}
.pbd-list-item--tappable { cursor: pointer; }
.pbd-list-item--tappable:active { background: var(--green-light); }

.pbd-list-item-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.pbd-list-item-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pbd-list-item-sub {
  font-size: 12px;
  color: var(--gray-mid);
}
.pbd-list-item-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.pbd-list-arrow {
  font-size: 20px;
  color: #ccc;
  margin-left: 4px;
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.pbd-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.pbd-badge--lg { font-size: 13px; padding: 4px 12px; }
.pbd-badge--green  { background: #d4edda; color: #155724; }
.pbd-badge--amber  { background: #fdf3cd; color: #856404; }
.pbd-badge--red    { background: #f8d7da; color: #721c24; }
.pbd-badge--blue   { background: #d1ecf1; color: #0c5460; }
.pbd-badge--gray   { background: #e9ecef; color: #495057; }

/* ── Batch Detail ───────────────────────────────────────────────────────────── */
.pbd-detail-card { padding: 0; }
.pbd-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.pbd-detail-header h2 { font-size: 22px; font-weight: 700; }
.pbd-detail-date { font-size: 14px; color: var(--gray-mid); }

.pbd-kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pbd-kv-item {
  background: var(--gray-light);
  border-radius: 8px;
  padding: 10px 12px;
}
.pbd-kv-item--amber { background: var(--amber-light); }
.pbd-kv-item--green { background: var(--green-light); }

.pbd-kv-label { display: block; font-size: 11px; color: var(--gray-mid); font-weight: 500; }
.pbd-kv-value { display: block; font-size: 17px; font-weight: 700; margin-top: 2px; }

/* ── QC Tests ───────────────────────────────────────────────────────────────── */
.pbd-qc-list { display: flex; flex-direction: column; gap: 10px; }

.pbd-qc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--gray-light);
  border-radius: 10px;
}
.pbd-qc-info { display: flex; flex-direction: column; gap: 2px; }
.pbd-qc-name { font-size: 14px; font-weight: 600; }
.pbd-qc-desc { font-size: 11px; color: var(--gray-mid); max-width: 180px; }

.pbd-qc-controls { display: flex; gap: 6px; flex-shrink: 0; }

.pbd-qc-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 2px solid var(--green-mid);
  background: var(--white);
  color: var(--green-mid);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.pbd-qc-btn.active-pass {
  background: var(--green-mid);
  color: var(--white);
}
.pbd-qc-btn--fail {
  border-color: var(--red);
  color: var(--red);
}
.pbd-qc-btn--fail.active-fail {
  background: var(--red);
  color: var(--white);
}

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.pbd-form { display: flex; flex-direction: column; gap: 0; }

.pbd-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.pbd-form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-mid);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pbd-form-group input,
.pbd-form-group select,
.pbd-form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  font-size: 16px;
  color: var(--gray-dark);
  background: var(--white);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}
.pbd-form-group input:focus,
.pbd-form-group select:focus,
.pbd-form-group textarea:focus {
  outline: none;
  border-color: var(--green-mid);
}

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

.pbd-form-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 6px 0 10px;
  padding-top: 6px;
  border-top: 1px solid #eee;
}

.pbd-form-actions { margin-top: 4px; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.pbd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.pbd-btn:active { transform: scale(0.98); opacity: 0.85; }
.pbd-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pbd-btn--primary { background: var(--green-dark); color: var(--white); }
.pbd-btn--secondary { background: var(--gray-light); color: var(--gray-dark); border: 1.5px solid #ddd; }
.pbd-btn--full { width: 100%; }
.pbd-btn--sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }

.pbd-btn-link {
  background: none;
  border: none;
  color: var(--green-mid);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

/* ── Count badge ────────────────────────────────────────────────────────────── */
.pbd-count { font-size: 13px; color: var(--gray-mid); font-weight: 400; }

/* ── Empty states ───────────────────────────────────────────────────────────── */
.pbd-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-mid);
  font-size: 15px;
  background: var(--white);
  border-radius: var(--radius);
  margin: 12px;
  box-shadow: var(--shadow);
}
.pbd-empty-small {
  text-align: center;
  padding: 16px;
  color: var(--gray-mid);
  font-size: 13px;
}

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.pbd-toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  background: var(--gray-dark);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  max-width: 90vw;
  text-overflow: ellipsis;
  overflow: hidden;
}
.pbd-toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }
.pbd-toast--error { background: var(--red); }
.pbd-toast--info  { background: var(--blue); }

/* ── Loading ────────────────────────────────────────────────────────────────── */
.pbd-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  gap: 16px;
  color: var(--gray-mid);
}
.pbd-spinner-wrap {
  display: flex;
  justify-content: center;
  padding: 40px;
}
.pbd-loading-spinner,
.pbd-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--green-light);
  border-top-color: var(--green-dark);
  border-radius: 50%;
  animation: pbd-spin 0.8s linear infinite;
}
@keyframes pbd-spin { to { transform: rotate(360deg); } }

/* ── PWA Install Banner ──────────────────────────────────────────────────────── */
.pbd-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  background: var(--green-dark);
  color: var(--white);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 20px rgba(0,0,0,0.35);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.pbd-install-banner--visible {
  transform: translateY(0);
}
/* Push above the app's bottom nav when logged in */
.pbd-install-banner--above-nav {
  bottom: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: 12px;
}
.pbd-install-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 640px;
  margin: 0 auto;
}
.pbd-install-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}
.pbd-install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.pbd-install-text strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--white);
}
.pbd-install-text span {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.35;
}
.pbd-install-text span strong {
  font-size: 12px;
}
.pbd-install-cta {
  flex-shrink: 0;
  background: var(--white);
  color: var(--green-dark);
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.pbd-install-cta:active { opacity: 0.8; }
.pbd-install-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: rgba(255,255,255,0.65);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}
.pbd-install-dismiss:hover { color: var(--white); }

/* ── Partner Cards ──────────────────────────────────────────────────────────── */
.pbd-partner-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pbd-partner-card {
  background: var(--gray-light);
  border-radius: 12px;
  padding: 14px 14px 10px;
  border-left: 4px solid var(--green-mid);
}

.pbd-partner-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.pbd-partner-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-dark);
}

.pbd-partner-card-meta {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.pbd-partner-freq,
.pbd-partner-contact {
  font-size: 12px;
  color: var(--gray-mid);
  font-weight: 500;
}

.pbd-partner-card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pbd-partner-action {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 8px;
  padding: 8px 10px;
  line-height: 1.35;
  transition: opacity 0.15s;
}
.pbd-partner-action:active { opacity: 0.7; }

.pbd-partner-action--map {
  background: #e8f4fd;
  color: #1a5276;
}
.pbd-partner-action--map:hover { background: #d1e9f9; }

.pbd-partner-action--phone {
  background: var(--green-light);
  color: var(--green-dark);
}
.pbd-partner-action--phone:hover { background: #d5ead3; }

.pbd-partner-action--email {
  background: #fdf3cd;
  color: #6d4c0f;
}
.pbd-partner-action--email:hover { background: #fbe8a0; }

.pbd-partner-notes {
  font-size: 12px;
  color: var(--gray-mid);
  font-style: italic;
  padding: 4px 2px;
  line-height: 1.4;
}

/* ── Login Screen ───────────────────────────────────────────────────────────── */
.pbd-login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--green-dark);
  padding: 24px 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.pbd-login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 32px 28px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}

.pbd-login-header {
  text-align: center;
  margin-bottom: 28px;
}
.pbd-login-logo {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 10px;
}
.pbd-login-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--green-dark);
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.pbd-login-sub {
  font-size: 14px;
  color: var(--gray-mid);
  margin: 0;
}

.pbd-login-error {
  background: #fdf0f0;
  border: 1px solid #f5c6c6;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--red);
  margin-bottom: 16px;
  text-align: center;
}

.pbd-login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pbd-login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pbd-login-field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pbd-login-field input {
  padding: 13px 14px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  font-size: 16px;
  color: var(--gray-dark);
  background: var(--white);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.pbd-login-field input:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(74,124,63,0.15);
}

.pbd-password-wrap {
  position: relative;
}
.pbd-password-wrap input {
  padding-right: 48px;
}
.pbd-toggle-pw {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.6;
}
.pbd-toggle-pw:hover { opacity: 1; }

.pbd-login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pbd-login-remember label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--gray-mid);
  cursor: pointer;
}
.pbd-login-remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--green-dark);
  cursor: pointer;
}

.pbd-login-btn {
  width: 100%;
  padding: 15px;
  background: var(--green-dark);
  color: var(--white);
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.02em;
}
.pbd-login-btn:hover  { background: var(--green-mid); }
.pbd-login-btn:active { transform: scale(0.98); }

.pbd-login-footer {
  text-align: center;
  margin-top: 16px;
}
.pbd-login-footer a {
  font-size: 13px;
  color: var(--green-mid);
  text-decoration: none;
}
.pbd-login-footer a:hover { text-decoration: underline; }

.pbd-login-brand {
  margin-top: 20px;
  text-align: center;
}
.pbd-login-brand a {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  letter-spacing: 0.03em;
}
.pbd-login-brand a:hover { color: rgba(255,255,255,0.8); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (min-width: 480px) {
  .pbd-card-grid { grid-template-columns: repeat(4, 1fr); }
  .pbd-section { margin: 0 16px 16px; padding: 20px; }
}

@media (min-width: 640px) {
  .pbd-main { padding: 20px 0 32px; }
}
