/* ============================================================
   Invoices View — Supplier Invoice Management
   CSS prefix: .inv-   |   Accent: #047857 (Emerald 700)
   Azia Light Theme — glassmorphic EPW aesthetic
   ============================================================ */

/* ---- View override ---- */
#invoices-view {
  background: #ECFDF5;
}

/* ---- Body ---- */
.inv-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
}

/* ---- Sections ---- */
.inv-section {
  background: rgba(4, 120, 87, 0.04);
  border: 1px solid rgba(4, 120, 87, 0.14);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 1px 4px rgba(4, 120, 87, 0.06);
}

.inv-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 2px solid #047857;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.inv-section-title {
  color: #047857;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---- KPI Banner (shared .epw-kpi-banner from epw-base) ---- */

/* ---- Filter Row ---- */
.inv-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(4, 120, 87, 0.05);
  border: 1px solid rgba(4, 120, 87, 0.12);
  border-radius: 8px;
}

.inv-filter-input {
  background: #fff;
  color: #334155;
  border: 1px solid rgba(4, 120, 87, 0.25);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  min-width: 120px;
}

.inv-filter-input:focus {
  border-color: #047857;
  box-shadow: 0 0 0 2px rgba(4, 120, 87, 0.12);
}

/* ---- Buttons ---- */
.inv-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid rgba(4, 120, 87, 0.35);
  background: rgba(4, 120, 87, 0.1);
  color: #047857;
  transition: background 0.15s, border-color 0.15s;
}

.inv-action-btn:hover {
  background: rgba(4, 120, 87, 0.18);
  border-color: rgba(4, 120, 87, 0.55);
}

.inv-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.inv-harvest-btn {
  background: rgba(4, 120, 87, 0.12);
  color: #047857;
  border-color: rgba(4, 120, 87, 0.4);
}

.inv-harvest-btn:hover {
  background: rgba(4, 120, 87, 0.22);
}

.inv-ocr-btn {
  background: rgba(3, 105, 161, 0.1);
  color: #0369a1;
  border-color: rgba(3, 105, 161, 0.35);
}

.inv-ocr-btn:hover {
  background: rgba(3, 105, 161, 0.18);
  border-color: rgba(3, 105, 161, 0.55);
}

.inv-export-btn {
  background: rgba(100, 116, 139, 0.1);
  color: #475569;
  border: 1px solid rgba(100, 116, 139, 0.3);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.inv-export-btn:hover {
  background: rgba(100, 116, 139, 0.18);
}

/* ---- Spinner ---- */
.inv-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(4, 120, 87, 0.25);
  border-top-color: #047857;
  border-radius: 50%;
  animation: inv-spin 0.7s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}

@keyframes inv-spin {
  to { transform: rotate(360deg); }
}

/* ---- Table ---- */
.inv-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid rgba(4, 120, 87, 0.12);
}

.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  min-width: 680px;
}

.inv-table thead th {
  background: rgba(4, 120, 87, 0.08);
  color: #047857;
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid rgba(4, 120, 87, 0.18);
  white-space: nowrap;
  user-select: none;
}

.inv-th-sortable {
  cursor: pointer;
}

.inv-th-sortable:hover {
  background: rgba(4, 120, 87, 0.13);
}

.inv-th-num,
.inv-td-num {
  text-align: right;
}

.inv-table-row {
  cursor: pointer;
  transition: background 0.12s;
}

.inv-table-row:nth-child(4n+1),
.inv-table-row:nth-child(4n+2) {
  background: rgba(255, 255, 255, 0.7);
}

.inv-table-row:nth-child(4n+3),
.inv-table-row:nth-child(4n+4) {
  background: rgba(4, 120, 87, 0.03);
}

.inv-table-row:hover {
  background: rgba(4, 120, 87, 0.08) !important;
}

.inv-row-expanded {
  background: rgba(4, 120, 87, 0.06) !important;
}

.inv-table td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(4, 120, 87, 0.07);
  color: #334155;
  vertical-align: top;
}

.inv-mono {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.8rem;
}

.inv-sort-icon {
  font-size: 0.7rem;
  color: #94A3B8;
}

/* ---- VAT Summary table ---- */
.inv-vat-table thead th {
  background: rgba(3, 105, 161, 0.08);
  color: #0369a1;
  border-bottom-color: rgba(3, 105, 161, 0.18);
}

.inv-totals-row td {
  background: rgba(4, 120, 87, 0.08);
  border-top: 2px solid rgba(4, 120, 87, 0.2);
  color: #047857;
}

/* ---- PDF link ---- */
.inv-pdf-link {
  color: #047857;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.8rem;
  border: 1px solid rgba(4, 120, 87, 0.3);
  border-radius: 4px;
  padding: 2px 7px;
  transition: background 0.12s;
}

.inv-pdf-link:hover {
  background: rgba(4, 120, 87, 0.1);
  text-decoration: none;
}

/* ---- Status Badges ---- */
.inv-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.inv-badge-downloaded {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
  border: 1px solid rgba(100, 116, 139, 0.25);
}

.inv-badge-ocr_pending {
  background: rgba(3, 105, 161, 0.1);
  color: #0369a1;
  border: 1px solid rgba(3, 105, 161, 0.25);
}

.inv-badge-ocr_complete {
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
  border: 1px solid rgba(22, 163, 74, 0.25);
}

.inv-badge-verified {
  background: rgba(4, 120, 87, 0.12);
  color: #047857;
  border: 1px solid rgba(4, 120, 87, 0.28);
}

.inv-badge-error {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.25);
}

/* ---- Expand Row (OCR details) ---- */
.inv-expand-row {
  background: rgba(4, 120, 87, 0.04) !important;
  cursor: default;
}

.inv-expand-cell {
  padding: 12px 20px 16px !important;
}

.inv-ocr-panel {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(4, 120, 87, 0.15);
  border-radius: 8px;
  padding: 12px 16px;
}

.inv-ocr-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #047857;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.inv-ocr-text {
  font-size: 0.82rem;
  color: #475569;
  line-height: 1.5;
  white-space: pre-wrap;
  margin-bottom: 8px;
}

.inv-ocr-json {
  font-size: 0.78rem;
  color: #334155;
  background: rgba(4, 120, 87, 0.04);
  border: 1px solid rgba(4, 120, 87, 0.1);
  border-radius: 6px;
  padding: 10px;
  overflow-x: auto;
  margin: 0;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

.inv-ocr-empty {
  font-size: 0.82rem;
  color: #94A3B8;
  font-style: italic;
}

/* ---- Pagination ---- */
.inv-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  padding: 8px 0;
}

.inv-page-btn {
  background: rgba(4, 120, 87, 0.08);
  color: #047857;
  border: 1px solid rgba(4, 120, 87, 0.25);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
}

.inv-page-btn:hover:not(:disabled) {
  background: rgba(4, 120, 87, 0.16);
}

.inv-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.inv-page-info {
  font-size: 0.82rem;
  color: #64748B;
}

/* ---- Provider Cards ---- */
.inv-prov-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.inv-prov-card {
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid;
  transition: box-shadow 0.15s;
}

.inv-prov-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.inv-prov-fresh {
  background: rgba(4, 120, 87, 0.07);
  border-color: rgba(4, 120, 87, 0.22);
}

.inv-prov-warn {
  background: rgba(217, 119, 6, 0.07);
  border-color: rgba(217, 119, 6, 0.22);
}

.inv-prov-stale {
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.2);
}

.inv-prov-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: #1E293B;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-prov-count {
  font-size: 0.82rem;
  color: #64748B;
  margin-bottom: 2px;
}

.inv-prov-last {
  font-size: 0.78rem;
  color: #94A3B8;
}

.inv-prov-age {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 6px;
}

.inv-prov-fresh .inv-prov-age  { color: #047857; }
.inv-prov-warn  .inv-prov-age  { color: #D97706; }
.inv-prov-stale .inv-prov-age  { color: #dc2626; }

/* ---- Actions Grid ---- */
.inv-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.inv-action-card {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(4, 120, 87, 0.14);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(4, 120, 87, 0.05);
}

.inv-action-card-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: #1E293B;
}

.inv-action-card-desc {
  font-size: 0.80rem;
  color: #64748B;
  line-height: 1.45;
  flex: 1;
}

.inv-last-harvest {
  margin-top: 12px;
  font-size: 0.8rem;
  color: #94A3B8;
}

/* ---- Loading ---- */
.wip-loading {
  padding: 16px;
  color: #94A3B8;
  font-size: 0.85rem;
  font-style: italic;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .inv-body {
    padding: 12px 14px;
  }

  .inv-filter-row {
    flex-direction: column;
    align-items: stretch;
  }

  .inv-filter-input {
    width: 100%;
    min-width: unset;
  }

  .inv-prov-grid {
    grid-template-columns: 1fr 1fr;
  }

  .inv-actions-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .inv-prov-grid {
    grid-template-columns: 1fr;
  }
}
