/* Advertising Platform - Invoice (Revamp v2)
   Scope: .ap-invoice-wrap / .ap-invoice
*/

.ap-invoice-wrap{
  --ap-text:#0f172a;
  --ap-muted:#64748b;
  --ap-border:#e2e8f0;
  --ap-soft:#f8fafc;
  --ap-radius:16px;
  --ap-shadow: 0 10px 25px rgba(2,6,23,.06);
  color: var(--ap-text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  padding: 26px 14px 34px;
}

.ap-invoice{
  max-width: 920px;
  margin: 0 auto;
  background:#fff;
  border:1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  padding: 22px;
  box-shadow: var(--ap-shadow);
}

.ap-invoice-top{
  display:flex;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
  align-items:flex-start;
}

.ap-invoice-brand{ font-size: 20px; font-weight: 900; letter-spacing:-0.02em; }
.ap-invoice-title{ font-size: 18px; font-weight: 900; text-align:right; letter-spacing:-0.02em; }
.ap-invoice-meta{ text-align:right; }
.ap-invoice-muted{ color: var(--ap-muted); font-size: 13px; line-height: 1.45; }

.ap-invoice-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}
@media (max-width: 760px){
  .ap-invoice-grid{ grid-template-columns: 1fr; }
  .ap-invoice-meta{ text-align:left; }
  .ap-invoice-title{ text-align:left; }
}

.ap-inv-card{
  border: 1px solid var(--ap-border);
  border-radius: 14px;
  background: var(--ap-soft);
  padding: 14px;
}

.ap-inv-card h4{
  margin:0 0 10px;
  font-size: 12px;
  color: var(--ap-muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.ap-inv-billto{ font-size: 13px; line-height: 1.55; }
.ap-inv-billto strong{ font-size: 14px; }

.ap-invoice-table{
  width:100%;
  border-collapse: collapse;
  margin-top: 16px;
  overflow:hidden;
  border-radius: 14px;
  border: 1px solid var(--ap-border);
}

.ap-invoice-table th, .ap-invoice-table td{
  padding: 12px 12px;
  border-bottom: 1px solid var(--ap-border);
  font-size: 13px;
  text-align:left;
}
.ap-invoice-table th{
  font-size: 12px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--ap-soft);
}

.ap-invoice-total{
  display:flex;
  justify-content:flex-end;
  gap: 14px;
  margin-top: 14px;
  align-items:center;
}
.ap-invoice-total .ap-total-label{
  color: var(--ap-muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.ap-invoice-total .ap-total-value{
  font-size: 18px;
  font-weight: 900;
}

.ap-invoice-actions{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  margin-top: 18px;
  justify-content: space-between;
}

.ap-invoice-actions .ap-btn,
.ap-invoice-actions .ap-btn-secondary{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #0f172a;
  background:#0f172a;
  color:#fff;
  font-weight: 800;
  font-size: 13px;
  text-decoration:none;
  cursor:pointer;
}

.ap-invoice-actions .ap-btn-secondary{
  border-color: var(--ap-border);
  background:#fff;
  color:#0f172a;
}
.ap-invoice-actions .ap-btn-secondary:hover{ background: var(--ap-soft); }

.ap-inv-badge{
  display:inline-flex;
  align-items:center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid var(--ap-border);
  background: var(--ap-soft);
  color:#334155;
}
.ap-inv-badge.is-paid{ background:#ecfdf5; border-color:#a7f3d0; color:#065f46; }
.ap-inv-badge.is-unpaid{ background:#fff7ed; border-color:#fed7aa; color:#9a3412; }


/* Mobile safety: keep the line-items table readable */
.ap-inv-table-wrap{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
@media (max-width: 640px){
  .ap-invoice-table{ min-width: 520px; }
}


/* Mobile stability: prevent horizontal bleed */
.ap-invoice,
.ap-invoice *{ box-sizing: border-box; }
.ap-invoice{ overflow-x: hidden; }
.ap-invoice table{ width:100%; border-collapse: collapse; }
.ap-invoice .ap-table-wrap{ overflow-x:auto; -webkit-overflow-scrolling: touch; max-width:100%; }

/* -------------------------------------------------
   EXTRA Mobile overflow hardening (v1.7)
   - keep layout within viewport
   - scroll tables inside cards (not page)
-------------------------------------------------- */
html, body{ max-width:100%; overflow-x:hidden; }

.ap-wrap-frontend, .ap-wrap-admin{ max-width:100vw; }
.ap-wrap-frontend *, .ap-wrap-admin *{ box-sizing:border-box; }

@media (max-width: 900px){
  .ap-card, .ap-box{ max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .ap-card table, .ap-box table{ min-width: 680px; }
}

@media (max-width: 520px){
  .ap-card table, .ap-box table{ min-width: 560px; }
}

@media (max-width: 420px){
  .ap-card table, .ap-box table{ min-width: 520px; }
}


/* --- Mobile hard clamp for tables inside cards (prevents bleed) --- */
@media (max-width: 820px){
  .ap-wrap-frontend .ap-card,
  .ap-wrap-frontend .ap-box,
  .ap-wrap-admin .ap-card,
  .ap-wrap-admin .ap-box{
    overflow: hidden; /* keep rounded corners + stop internal bleed */
  }

  /* Any table inside plugin wrappers becomes its own horizontal scroll area */
  .ap-wrap-frontend table,
  .ap-wrap-admin table{
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Keep table layout intact while scrolling */
  .ap-wrap-frontend table thead,
  .ap-wrap-frontend table tbody,
  .ap-wrap-admin table thead,
  .ap-wrap-admin table tbody{
    display: table;
    width: max-content;
    min-width: 100%;
  }

  .ap-wrap-frontend table th,
  .ap-wrap-frontend table td,
  .ap-wrap-admin table th,
  .ap-wrap-admin table td{
    white-space: nowrap;
  }
}



/* v1.9 mobile overflow fix: ap-table min-width caused horizontal bleed */
@media (max-width: 820px){
  .ap-wrap-frontend .ap-table,
  .ap-wrap-admin .ap-table{
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .ap-wrap-frontend .ap-table thead,
  .ap-wrap-frontend .ap-table tbody,
  .ap-wrap-admin .ap-table thead,
  .ap-wrap-admin .ap-table tbody{
    display: table !important;
    width: max-content !important;
    min-width: 100% !important;
  }
  .ap-wrap-frontend .ap-table th,
  .ap-wrap-frontend .ap-table td,
  .ap-wrap-admin .ap-table th,
  .ap-wrap-admin .ap-table td{
    white-space: nowrap !important;
  }
}

