/* Invoice Upload & OCR Styles */

.invoice-upload-wrapper {
  padding: 4px 0;
}

.invoice-upload-header {
  margin-bottom: 16px;
}

/* Drop Zone */
.invoice-dropzone {
  border: 2px dashed var(--color-grey-800);
  border-radius: var(--radius-lg);
  padding: var(--space-10);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-standard);
  background: var(--color-grey-700);
}

.invoice-dropzone:hover,
.invoice-dropzone.dragover {
  border-color: var(--color-information-500);
  background: var(--color-information-100);
}

.invoice-dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Progress */
.invoice-progress {
  margin-top: 16px;
}

.invoice-progress-bar {
  height: 6px;
  background: var(--color-grey-800);
  border-radius: 3px;
  overflow: hidden;
}

.invoice-progress-fill {
  height: 100%;
  background: var(--color-information-500);
  border-radius: 3px;
  transition: width 0.5s ease;
  width: 0%;
}

.invoice-progress-text {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--color-text-500);
}

/* Result Card */
.invoice-result-card {
  margin-top: 16px;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-grey-800);
  background: var(--color-grey-700);
}

.invoice-result-card.success {
  border-color: var(--color-success-200);
  background: var(--color-success-100);
}

.invoice-result-card.error {
  border-color: var(--color-danger-200);
  background: var(--color-danger-100);
}

/* Parsed Data Grid */
.invoice-parsed-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.invoice-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.invoice-field label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.invoice-field span {
  font-size: 13px;
  color: var(--color-text-800);
}

/* Items Table */
.invoice-items-table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  font-size: 13px;
}

.invoice-items-table th {
  padding: 8px 10px;
  background: var(--color-grey-700);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-600);
  border-bottom: 1px solid var(--color-grey-800);
  text-align: left;
}

.invoice-items-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-grey-700);
  color: var(--color-text-700);
}

/* Match Badges */
.invoice-match-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

.invoice-match-badge.matched {
  background: var(--color-success-100);
  color: var(--color-success-700);
  border: 1px solid var(--color-success-200);
}

.invoice-match-badge.suggestion {
  background: var(--color-warning-100);
  color: var(--color-warning-700);
  border: 1px solid var(--color-warning-200);
}

.invoice-match-badge.unmatched {
  background: var(--color-grey-700);
  color: var(--color-text-600);
  border: 1px solid var(--color-grey-800);
}

.invoice-match-detail {
  display: flex;
  gap: 16px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--color-text-600);
}

/* Invoice List Table */
.invoice-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.invoice-list-table th {
  padding: 10px 12px;
  background: var(--color-grey-700);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-600);
  border-bottom: 2px solid var(--color-grey-800);
  text-align: left;
}

.invoice-list-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-grey-700);
  color: var(--color-text-700);
}

.invoice-list-table tbody tr:hover {
  background: var(--color-grey-700);
}

/* Sortable table headers */
.invoice-sortable-th {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
  white-space: nowrap;
}

.invoice-sortable-th:hover {
  color: var(--color-information-600);
}

.sort-icon {
  font-size: 10px;
  margin-left: 2px;
  line-height: 1;
}

/* Overdue row highlight */
.invoice-row-overdue td {
  background: var(--color-danger-100);
}

.invoice-row-overdue:hover td {
  background: var(--color-danger-100) !important;
}

/* Inline edit button */
.invoice-inline-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-600);
  opacity: 0;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}

.invoice-modal-body:hover .invoice-inline-edit-btn {
  opacity: 0.5;
}

.invoice-inline-edit-btn:hover {
  opacity: 1 !important;
  color: var(--color-information-500);
  background: var(--color-information-100);
}

/* Clickable invoice rows */
.invoice-row-clickable {
  cursor: pointer;
  transition: background 0.15s ease;
}

.invoice-row-clickable:hover {
  background: var(--color-information-100) !important;
}

.invoice-row-clickable:active {
  background: var(--color-information-100) !important;
}

/* Invoice Detail Modal */
.invoice-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(2px);
}

.invoice-modal-overlay.active {
  opacity: 1;
}

.invoice-modal-panel {
  width: 580px;
  max-height: 85vh;
  background: var(--color-neutral-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
}

.invoice-modal-overlay.active .invoice-modal-panel {
  transform: translateY(0) scale(1);
}

.invoice-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-grey-800);
  flex-shrink: 0;
}

.invoice-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-500);
  transition: all 0.15s ease;
}

.invoice-modal-close:hover {
  background: var(--color-grey-700);
  color: var(--color-text-800);
}

.invoice-modal-body {
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  overflow-y: auto;
  flex: 1;
}

.invoice-modal-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-grey-700);
}

.invoice-modal-inv-number {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-900);
}

.invoice-modal-amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-900);
}

.invoice-modal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.invoice-modal-section {
  margin-bottom: 20px;
}

.invoice-modal-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-500);
  margin: 0 0 10px;
}

.invoice-modal-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--color-grey-700);
  border: 1px solid var(--color-grey-800);
  color: var(--color-information-600);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
}

.invoice-modal-attachment:hover {
  background: var(--color-information-100);
  border-color: var(--color-information-200);
}

.invoice-modal-footer-meta {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--color-grey-700);
  font-size: 11px;
  color: var(--color-text-600);
}

.invoice-modal-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--color-grey-800);
  border-top-color: var(--color-information-500);
  border-radius: var(--radius-full);
  animation: invoice-spin 0.7s linear infinite;
  margin: 0 auto;
}

@keyframes invoice-spin {
  to { transform: rotate(360deg); }
}

/* Invoice document preview */
.invoice-modal-preview {
  border: 1px solid var(--color-grey-800);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-grey-700);
}

.invoice-modal-preview-img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
  transition: opacity 0.15s ease;
}

.invoice-modal-preview-img:hover {
  opacity: 0.9;
}

.invoice-modal-preview-pdf {
  width: 100%;
  height: 400px;
  border: none;
  display: block;
}

.invoice-modal-no-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border: 1px dashed var(--color-grey-800);
  border-radius: var(--radius-sm);
  color: var(--color-text-500);
  font-size: 13px;
}

/* Match suggestions */
.invoice-suggestion-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--color-grey-800);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background: var(--color-grey-700);
  transition: border-color 0.15s ease;
}

.invoice-suggestion-row:hover {
  border-color: var(--color-information-300);
}

.invoice-suggestion-info {
  flex: 1;
  min-width: 0;
}

.invoice-suggestion-confidence {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-md);
  white-space: nowrap;
}

/* Status Badges */
.invoice-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.invoice-status-badge.matched {
  background: var(--color-success-100);
  color: var(--color-success-700);
}

.invoice-status-badge.pending {
  background: var(--color-warning-100);
  color: var(--color-warning-700);
}

.invoice-status-badge.overdue {
  background: var(--color-danger-100);
  color: var(--color-danger-700);
}

.invoice-status-badge.failed {
  background: var(--color-danger-100);
  color: var(--color-danger-700);
}

/* Batch Summary Grid */
.batch-summary-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.batch-summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--color-grey-700);
  min-width: 80px;
}

.batch-summary-item.success {
  background: var(--color-success-100);
}

.batch-summary-item.matched {
  background: var(--color-information-100);
}

.batch-summary-item.failed {
  background: var(--color-danger-100);
}

.batch-summary-item.skipped {
  background: var(--color-warning-100);
}

.batch-summary-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  color: var(--color-text-800);
}

.batch-summary-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* Batch File List (progress view) */
.batch-file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.batch-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-grey-700);
  font-size: 13px;
}

.batch-file-icon {
  flex-shrink: 0;
}

.batch-file-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-file-size {
  font-size: 12px;
  color: var(--color-text-500);
}

.batch-file-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-md);
}

.batch-file-status.pending {
  background: var(--color-grey-800);
  color: var(--color-text-600);
}

/* ============================================
   MOBILE CARD LAYOUT
   ============================================ */

/* Desktop: show table, hide cards */
.invoice-desktop-table { display: block; }
.invoice-mobile-cards { display: none; }

/* Mobile card styles */
.inv-card {
  padding: 14px 16px;
  border: 1px solid var(--color-grey-800);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  background: var(--color-neutral-white);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.inv-card:active {
  border-color: var(--color-information-300);
  box-shadow: 0 0 0 2px var(--color-information-100);
}

.inv-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.inv-card-left {
  flex: 1;
  min-width: 0;
}

.inv-card-number {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-card-customer {
  font-size: 13px;
  color: var(--color-text-500);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-card-right {
  text-align: right;
  flex-shrink: 0;
}

.inv-card-amount {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-900);
  margin-bottom: 4px;
}

.inv-card-bottom {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-grey-700);
}

.inv-card-date {
  font-size: 12px;
  color: var(--color-text-500);
}

.inv-card-bank {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--color-information-100);
  border: 1px solid var(--color-information-200);
}

.inv-card-bank-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-information-600);
  margin-bottom: 3px;
}

.inv-card-bank-desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-card-bank-meta {
  font-size: 12px;
  color: var(--color-text-500);
  margin-top: 2px;
}

/* Responsive — main breakpoints consolidated in responsive.css */
@media (max-width: 768px) {
  .invoice-parsed-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .invoice-field[style*="grid-column: span 2"] {
    grid-column: span 2;
  }

  .invoice-modal-top-row {
    flex-direction: column;
    gap: 12px;
  }

  .invoice-modal-top-row > div:last-child {
    text-align: left;
  }

  .batch-summary-grid {
    gap: 10px;
  }

  .batch-summary-item {
    padding: 10px 14px;
    min-width: 60px;
  }

  .batch-summary-value {
    font-size: 20px;
  }

  /* Switch from table to cards on mobile */
  .invoice-desktop-table { display: none; }
  .invoice-mobile-cards { display: block; }
}

/* Dark Mode */
body.dark-mode .invoice-dropzone {
  background: var(--color-grey-800);
  border-color: var(--color-grey-600);
}

body.dark-mode .invoice-dropzone:hover,
body.dark-mode .invoice-dropzone.dragover {
  border-color: var(--color-information-400);
  background: var(--color-grey-700);
}

body.dark-mode .invoice-result-card {
  background: var(--color-grey-800);
  border-color: var(--color-grey-600);
}

body.dark-mode .invoice-result-card.success {
  background: var(--color-success-100);
  border-color: var(--color-success-200);
}

body.dark-mode .invoice-result-card.error {
  background: var(--color-danger-100);
  border-color: var(--color-danger-200);
}

body.dark-mode .invoice-items-table th,
body.dark-mode .invoice-list-table th {
  background: var(--color-grey-700);
  color: var(--color-text-600);
}

body.dark-mode .invoice-items-table td,
body.dark-mode .invoice-list-table td {
  border-color: var(--color-grey-700);
  color: var(--color-text-700);
}

body.dark-mode .invoice-list-table tbody tr:hover {
  background: var(--color-grey-700);
}

/* Dark Mode - Modal */
body.dark-mode .invoice-modal-overlay {
  background: rgba(0, 0, 0, 0.65);
}

body.dark-mode .invoice-modal-panel {
  background: var(--color-grey-800);
  box-shadow: var(--shadow-lg);
}

body.dark-mode .invoice-modal-header {
  border-color: var(--color-grey-700);
}

body.dark-mode .invoice-modal-close:hover {
  background: var(--color-grey-700);
  color: var(--color-text-800);
}

body.dark-mode .invoice-modal-inv-number,
body.dark-mode .invoice-modal-amount {
  color: var(--color-text-900);
}

body.dark-mode .invoice-modal-top-row {
  border-color: var(--color-grey-700);
}

body.dark-mode .invoice-modal-attachment {
  background: var(--color-grey-700);
  border-color: var(--color-grey-600);
  color: var(--color-information-400);
}

body.dark-mode .invoice-modal-attachment:hover {
  background: var(--color-grey-600);
}

body.dark-mode .invoice-modal-footer-meta {
  border-color: var(--color-grey-700);
  color: var(--color-text-500);
}

body.dark-mode .invoice-modal-header::before {
  background: var(--color-grey-600);
}

body.dark-mode .invoice-row-clickable:hover {
  background: var(--color-grey-700) !important;
}

body.dark-mode .invoice-row-clickable:active {
  background: var(--color-grey-600) !important;
}

body.dark-mode .invoice-row-overdue td {
  background: var(--color-danger-100);
}

body.dark-mode .invoice-row-overdue:hover td {
  background: var(--color-danger-200) !important;
}

body.dark-mode .invoice-sortable-th:hover {
  color: var(--color-information-400);
}

body.dark-mode .invoice-inline-edit-btn:hover {
  color: var(--color-information-400);
  background: var(--color-information-200);
}

/* Dark Mode - Preview & Suggestions */
body.dark-mode .invoice-modal-preview {
  border-color: var(--color-grey-600);
  background: var(--color-grey-900);
}

body.dark-mode .invoice-modal-no-preview {
  border-color: var(--color-grey-600);
  color: var(--color-text-600);
}

body.dark-mode .invoice-suggestion-row {
  background: var(--color-grey-700);
  border-color: var(--color-grey-600);
}

body.dark-mode .invoice-suggestion-row:hover {
  border-color: var(--color-information-400);
}

/* Dark Mode - Mobile Cards */
body.dark-mode .inv-card {
  background: var(--color-grey-800);
  border-color: var(--color-grey-600);
}

body.dark-mode .inv-card:active {
  border-color: var(--color-information-400);
  box-shadow: 0 0 0 2px var(--color-information-200);
}

body.dark-mode .inv-card-number {
  color: var(--color-text-900);
}

body.dark-mode .inv-card-amount {
  color: var(--color-text-900);
}

body.dark-mode .inv-card-bottom {
  border-color: var(--color-grey-700);
}

body.dark-mode .inv-card-bank {
  background: var(--color-information-100);
  border-color: var(--color-information-200);
}

body.dark-mode .inv-card-bank-desc {
  color: var(--color-text-800);
}
