/* ============================================================
   EXCEL Church PO & Receipt Portal — Portal Stylesheet
   ============================================================ */

:root {
  --navy:      #1a3a5c;
  --navy-dk:   #122840;
  --navy-lt:   #eaf0fb;
  --blue:      #2563eb;
  --green:     #10b981;
  --amber:     #f59e0b;
  --red:       #ef4444;
  --red-dk:    #dc2626;
  --gray-50:   #f9fafb;
  --gray-100:  #f3f4f6;
  --gray-200:  #e5e7eb;
  --gray-400:  #9ca3af;
  --gray-600:  #4b5563;
  --gray-800:  #1f2937;
  --radius:    6px;
  --shadow:    0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
}

/* ── Wrapper ── */
.eprm-portal {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 0 60px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  line-height: 1.5;
}

/* ── View-As Bar (admin only) ── */
.eprm-view-as-bar {
  background: #fff3cd;
  border-bottom: 2px solid #ffc107;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 600;
  color: #856404;
}
.eprm-va-btn {
  background: #fff;
  border: 1px solid #ffc107;
  color: #856404;
  padding: 3px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all .15s;
}
.eprm-va-btn:hover,
.eprm-va-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* ── Header ── */
.eprm-portal-header {
  background: var(--navy);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.eprm-portal-title {
  display: flex;
  align-items: center;
  gap: 14px;
}
.eprm-logo {
  font-size: 28px;
  color: #fff;
  opacity: .85;
}
.eprm-portal-title h1 {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}
.eprm-portal-title p {
  color: rgba(255,255,255,.7);
  margin: 0;
  font-size: 13px;
}
.eprm-logout-link {
  color: rgba(255,255,255,.7);
  font-size: 12px;
  text-decoration: none;
}
.eprm-logout-link:hover { color: #fff; }

/* ── Section ── */
.eprm-section {
  padding: 24px 20px 0;
}

/* ── Dashboard ── */
.eprm-dashboard {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.eprm-dash-section {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.eprm-dash-heading {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--navy);
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}

/* ── KPI Row ── */
.eprm-kpi-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.eprm-kpi {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px 16px;
  text-align: center;
  min-width: 90px;
  flex: 1;
}
.kpi-num {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
}
.kpi-label {
  display: block;
  font-size: 11px;
  color: var(--gray-600);
  margin-top: 2px;
}

/* ── Dashboard Links ── */
.eprm-dash-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}
.eprm-link {
  color: var(--navy);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.eprm-link:hover { color: var(--blue); text-decoration: underline; }

/* ── Alerts ── */
.eprm-alert {
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.eprm-alert-warning { background: #fffbeb; border: 1px solid #fcd34d; color: #78350f; }
.eprm-alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }
.eprm-alert-success { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.eprm-alert-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #7f1d1d; }

/* ── Panel Header (back + title) ── */
.eprm-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gray-200);
}
.eprm-back-btn {
  background: none;
  border: none;
  color: var(--navy);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.eprm-panel-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
}

/* ── Form ── */
.eprm-form-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.eprm-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.eprm-field-row.full { grid-template-columns: 1fr; }
.eprm-field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.eprm-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.eprm-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.eprm-field input,
.eprm-field select,
.eprm-field textarea {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 14px;
  color: var(--gray-800);
  background: #fff;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .15s;
}
.eprm-field input:focus,
.eprm-field select:focus,
.eprm-field textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26,58,92,.1);
}
.eprm-field input[readonly] {
  background: var(--gray-50);
  color: var(--gray-600);
}
.eprm-field textarea { resize: vertical; min-height: 72px; }
.eprm-field-hint { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ── Section Divider ── */
.eprm-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--navy);
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--navy-lt);
}

/* ── Vendor Block ── */
.eprm-vendor-block {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  position: relative;
}
.eprm-vendor-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.eprm-vendor-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.eprm-remove-vendor {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
}
.eprm-remove-vendor:hover { color: var(--red); }
.eprm-add-vendor-btn {
  background: none;
  border: 1px dashed var(--gray-400);
  color: var(--gray-600);
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
  transition: all .15s;
}
.eprm-add-vendor-btn:hover {
  border-color: var(--navy);
  color: var(--navy);
  background: var(--navy-lt);
}
.eprm-total-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--gray-200);
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
}

/* ── Buttons ── */
.eprm-btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}
.eprm-btn {
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  line-height: 1.4;
}
.eprm-btn-primary   { background: var(--navy); color: #fff; }
.eprm-btn-primary:hover { background: var(--navy-dk); }
.eprm-btn-secondary { background: #fff; color: var(--navy); border-color: var(--navy); }
.eprm-btn-secondary:hover { background: var(--navy-lt); }
.eprm-btn-danger    { background: #fff; color: var(--red-dk); border-color: var(--red-dk); }
.eprm-btn-danger:hover { background: #fef2f2; }
.eprm-btn-green     { background: var(--green); color: #fff; }
.eprm-btn-green:hover { background: #059669; }
.eprm-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Status Badge ── */
.eprm-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.badge-draft     { background: #f3f4f6; color: #374151; }
.badge-pending   { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.badge-more_info { background: #fef2f2; color: #7f1d1d; border: 1px solid #fca5a5; }
.badge-approved  { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.badge-denied    { background: #fef2f2; color: #7f1d1d; }

/* ── PO Card (list view) ── */
.eprm-po-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.eprm-po-card-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  flex-wrap: wrap;
}
.eprm-po-card-summary:hover { background: var(--gray-50); }
.eprm-po-num {
  font-weight: 700;
  color: var(--navy);
  font-size: 13px;
  min-width: 110px;
}
.eprm-po-dept {
  color: var(--gray-600);
  font-size: 13px;
  flex: 1;
  min-width: 100px;
}
.eprm-po-amount {
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-800);
}
.eprm-po-date {
  font-size: 12px;
  color: var(--gray-400);
}
.eprm-po-expand-icon { color: var(--gray-400); font-size: 12px; margin-left: auto; }
.eprm-po-detail {
  border-top: 1px solid var(--gray-200);
  padding: 16px;
  background: var(--gray-50);
  display: none;
}
.eprm-po-detail.open { display: block; }
.eprm-po-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
  margin-bottom: 14px;
}
.eprm-detail-item label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gray-400);
  letter-spacing: .4px;
  display: block;
}
.eprm-detail-item span {
  font-size: 13px;
  color: var(--gray-800);
}
.eprm-vendor-list {
  margin: 10px 0;
}
.eprm-vendor-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.eprm-vendor-row .v-name { font-weight: 600; flex: 1; min-width: 120px; }
.eprm-vendor-row .v-amt  { color: var(--gray-600); font-size: 13px; }
.eprm-vendor-row .v-method { font-size: 11px; color: var(--gray-400); background: var(--gray-100); padding: 2px 8px; border-radius: 10px; }
.eprm-vendor-row .v-receipt-tag { font-size: 11px; font-weight: 700; }
.v-has-receipt { color: var(--green); }
.v-no-receipt  { color: var(--amber); }
.eprm-po-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.eprm-more-info-box {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.eprm-more-info-box strong { color: #92400e; }

/* ── Receipt Upload ── */
.eprm-upload-area {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: var(--gray-50);
  position: relative;
}
.eprm-upload-area:hover,
.eprm-upload-area.dragover {
  border-color: var(--navy);
  background: var(--navy-lt);
}
.eprm-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.eprm-upload-icon { font-size: 32px; display: block; margin-bottom: 8px; }
.eprm-upload-label { font-size: 14px; font-weight: 600; color: var(--navy); display: block; }
.eprm-upload-hint  { font-size: 12px; color: var(--gray-400); margin-top: 4px; display: block; }
.eprm-upload-heic-tip {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  color: #1e40af;
  margin-top: 10px;
  display: none;
}
.eprm-file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-top: 10px;
}
.eprm-file-preview img { max-width: 60px; max-height: 60px; object-fit: cover; border-radius: 3px; }
.eprm-file-preview .f-name { font-size: 13px; font-weight: 500; flex: 1; }
.eprm-file-preview .f-clear { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 18px; }

/* ── Receipt Grid ── */
.eprm-receipt-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.eprm-receipt-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.eprm-receipt-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  border-radius: 4px;
  font-size: 24px;
  flex-shrink: 0;
}
.eprm-receipt-info { flex: 1; min-width: 160px; }
.eprm-receipt-info .r-po   { font-weight: 700; color: var(--navy); font-size: 13px; }
.eprm-receipt-info .r-vendor { font-size: 13px; color: var(--gray-800); }
.eprm-receipt-info .r-meta  { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.eprm-receipt-actions { display: flex; gap: 8px; }

/* ── Approvals Table ── */
.eprm-approval-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.eprm-approval-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  flex-wrap: wrap;
}
.eprm-approval-header .a-num  { font-weight: 700; color: var(--navy); font-size: 14px; }
.eprm-approval-header .a-who  { color: var(--gray-600); font-size: 13px; flex: 1; }
.eprm-approval-header .a-amt  { font-weight: 600; font-size: 14px; }
.eprm-approval-body   { padding: 14px 16px; }
.eprm-approval-actions { padding: 12px 16px; border-top: 1px solid var(--gray-200); display: flex; gap: 8px; }

/* ── Reconciliation ── */
.eprm-reconcile-kpi {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 20px 0;
}
.eprm-reconcile-kpi-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.rk-num   { font-size: 30px; font-weight: 700; color: var(--navy); display: block; line-height: 1.1; }
.rk-label { font-size: 12px; color: var(--gray-600); display: block; margin-top: 4px; }
.eprm-receipt-row-matched { border-left: 3px solid var(--green); }
.eprm-receipt-row-missing { border-left: 3px solid var(--red); background: #fff8f8; }

/* ── Modal ── */
.eprm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.eprm-modal {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.eprm-modal h3 { margin-top: 0; color: var(--navy); font-size: 16px; margin-bottom: 14px; }
.eprm-modal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--gray-400); line-height: 1;
}
.eprm-modal-close:hover { color: var(--gray-800); }

/* ── Spinner ── */
.eprm-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#eprm-toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 10000;
  opacity: 0;
  transform: translateY(8px);
  transition: all .25s;
  pointer-events: none;
  max-width: 320px;
}
#eprm-toast.show { opacity: 1; transform: translateY(0); }
#eprm-toast.toast-error { background: var(--red-dk); }
#eprm-toast.toast-success { background: var(--green); }

/* ── Empty State ── */
.eprm-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}
.eprm-empty-icon { font-size: 40px; margin-bottom: 10px; display: block; }
.eprm-empty p { font-size: 14px; margin: 0 0 14px; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .eprm-portal { padding-bottom: 40px; }
  .eprm-field-row { grid-template-columns: 1fr; }
  .eprm-field-row.three { grid-template-columns: 1fr; }
  .eprm-reconcile-kpi { grid-template-columns: 1fr 1fr; }
  .eprm-po-card-summary { flex-direction: column; align-items: flex-start; }
  .eprm-kpi { min-width: 70px; }
  .eprm-portal-title h1 { font-size: 16px; }
  .eprm-modal { padding: 18px; }
}
