/* ========================================
   INVOICE FORM - Slick Editor Styles
   Designed for high-volume invoice processing
   All styles scoped under .invoice-form
   ======================================== */

/* Main invoice form container */
.invoice-form {
  max-width: 1100px;
}

/* Section cards */
.invoice-form .invoice-section {
  background: var(--bulma-scheme-main);
  border: 1px solid var(--bulma-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.invoice-form .invoice-section:focus-within {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

[data-theme="dark"] .invoice-form .invoice-section:focus-within {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.invoice-form .invoice-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--bulma-border);
}

.invoice-form .invoice-section-header .icon {
  color: var(--primary);
  font-size: 1.1rem;
}

.invoice-form .invoice-section-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bulma-text-weak);
  margin: 0;
}

/* Header area with invoice number and status */
.invoice-form .invoice-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-darker) 100%);
  border-radius: 8px;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

[data-theme="dark"] .invoice-form .invoice-editor-header {
  background: linear-gradient(135deg, #1e3a5f 0%, #0f2744 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.invoice-form .invoice-editor-header h1 {
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.invoice-form .invoice-editor-header .invoice-number {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.invoice-form .invoice-editor-header .buttons {
  margin-bottom: 0;
}

.invoice-form .invoice-editor-header .buttons .button {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.invoice-form .invoice-editor-header .buttons .button:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Line items table - optimized for fast data entry */
.invoice-form .line-items-section {
  padding: 0;
  overflow: hidden;
}

.invoice-form .line-items-section .invoice-section-header {
  padding: 1rem 1.5rem 0.75rem;
  margin-bottom: 0;
  border-bottom: none;
}

.invoice-form .line-items-table-wrapper {
  overflow-x: auto;
}

.invoice-form .line-items-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.invoice-form .line-items-table thead th {
  background: var(--bulma-scheme-main-bis);
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bulma-text-weak);
  border-bottom: 2px solid var(--bulma-border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.invoice-form .line-items-table thead th:first-child {
  padding-left: 1.5rem;
}

.invoice-form .line-items-table thead th:last-child {
  padding-right: 1.5rem;
}

.invoice-form .line-items-table tbody tr {
  transition: background-color 0.15s ease;
}

.invoice-form .line-items-table tbody tr:hover {
  background: var(--bulma-scheme-main-bis);
}

.invoice-form .line-items-table tbody tr:focus-within {
  background: rgba(59, 130, 246, 0.05);
}

[data-theme="dark"] .invoice-form .line-items-table tbody tr:focus-within {
  background: rgba(59, 130, 246, 0.1);
}

.invoice-form .line-items-table tbody td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--bulma-border-weak);
  vertical-align: middle;
}

.invoice-form .line-items-table tbody td:first-child {
  padding-left: 1.5rem;
}

.invoice-form .line-items-table tbody td:last-child {
  padding-right: 1.5rem;
}

/* Compact inputs in line items */
.invoice-form .line-items-table .input,
.invoice-form .line-items-table .select select {
  font-size: 0.95rem;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  height: 2.25rem;
}

.invoice-form .line-items-table .select {
  height: 2.25rem;
}

/* Amount input styling */
.invoice-form .line-items-table .amount-input {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-weight: 500;
}

/* Remove button - subtle until hovered */
.invoice-form .line-items-table .remove-btn {
  opacity: 0.4;
  transition: opacity 0.15s ease, color 0.15s ease;
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
}

.invoice-form .line-items-table tbody tr:hover .remove-btn,
.invoice-form .line-items-table .remove-btn:focus {
  opacity: 1;
}

.invoice-form .line-items-table .remove-btn:hover {
  color: var(--bulma-danger);
}

/* Table footer with totals */
.invoice-form .line-items-table tfoot {
  background: var(--bulma-scheme-main-bis);
}

.invoice-form .line-items-table tfoot td {
  padding: 1rem;
  border-top: 2px solid var(--bulma-border);
}

.invoice-form .line-items-table tfoot td:first-child {
  padding-left: 1.5rem;
}

.invoice-form .line-items-table tfoot td:last-child {
  padding-right: 1.5rem;
}

/* Add line item row */
.invoice-form .add-line-row td {
  padding-top: 0.75rem !important;
  padding-bottom: 0.75rem !important;
  border-bottom: none !important;
}

.invoice-form .add-line-btn,
.invoice-form .add-line-btn:hover,
.invoice-form .add-line-btn:focus,
.invoice-form .add-line-btn:active {
  font-size: 0.875rem !important;
  padding: 0.5rem 1rem !important;
  border-width: 1px !important;
  transition: none !important;
  transform: none !important;
  animation: none !important;
  box-shadow: none !important;
}

/* Code column width */
.invoice-form .line-items-table th:nth-child(2),
.invoice-form .line-items-table td:nth-child(2) {
  min-width: 140px;
}

/* Running total - prominent display */
.invoice-form .running-total-row td {
  padding-top: 1rem !important;
  padding-bottom: 1rem !important;
}

.invoice-form .running-total {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

.invoice-form .running-total-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bulma-text-weak);
}

.invoice-form .running-total-amount {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  color: var(--primary);
  letter-spacing: -0.5px;
  transition: transform 0.15s ease;
}

.invoice-form .running-total-amount.updated {
  animation: invoiceFormTotalPulse 0.3s ease;
}

@keyframes invoiceFormTotalPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Status toggles section */
.invoice-form .status-toggles {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.invoice-form .status-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 6px;
  background: var(--bulma-scheme-main-bis);
  transition: background-color 0.15s ease;
  cursor: pointer;
}

.invoice-form .status-toggle:hover {
  background: var(--bulma-scheme-main-ter);
}

.invoice-form .status-toggle input[type="checkbox"] {
  margin-top: 0.15rem;
}

.invoice-form .status-toggle-content {
  flex: 1;
}

.invoice-form .status-toggle-label {
  font-weight: 500;
  color: var(--bulma-text);
  margin-bottom: 0.25rem;
}

.invoice-form .status-toggle-help {
  font-size: 0.85rem;
  color: var(--bulma-text-weak);
}

/* Action footer */
.invoice-form .invoice-actions {
  background: var(--bulma-scheme-main);
  border: 1px solid var(--bulma-border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .invoice-form .invoice-actions {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.invoice-form .invoice-actions .buttons {
  margin-bottom: 0;
}

/* Primary action button enhancement */
.invoice-form .invoice-actions .button.is-primary {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  font-weight: 600;
}

/* Keyboard shortcut hints */
.invoice-form .kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.5rem;
  font-size: 0.7rem;
  color: var(--bulma-text-weak);
}

.invoice-form .kbd-hint kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  font-size: 0.65rem;
  font-family: inherit;
  background: var(--bulma-scheme-main-bis);
  border: 1px solid var(--bulma-border);
  border-radius: 3px;
  box-shadow: 0 1px 0 var(--bulma-border);
}

/* Invoice info grid - dates and account */
.invoice-form .invoice-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Account display when editing (locked) */
.invoice-form .account-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.75rem;
  height: 2.5em;
  background: var(--bulma-scheme-main-bis);
  border: 1px solid var(--bulma-border);
  border-radius: var(--bulma-radius);
  font-size: 1rem;
}

.invoice-form .account-display .icon {
  color: var(--primary);
}

.invoice-form .account-display .account-name {
  font-weight: 500;
}

.invoice-form .account-display .locked-hint {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--bulma-text-weak);
}

/* Bill to and message side by side on larger screens */
.invoice-form .details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* Field with help text inline */
.invoice-form .field-with-help .help {
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

/* Quick stats in header area */
.invoice-form .invoice-quick-stats {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.invoice-form .quick-stat {
  text-align: center;
}

.invoice-form .quick-stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: white;
}

.invoice-form .quick-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.7);
}

/* Smooth transitions for table row animations */
.invoice-form .line-items-table tbody tr {
  animation: invoiceFormFadeSlideIn 0.2s ease;
}

@keyframes invoiceFormFadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Removing row animation */
.invoice-form .line-items-table tbody tr.removing {
  animation: invoiceFormFadeSlideOut 0.2s ease forwards;
}

@keyframes invoiceFormFadeSlideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Preview modal styles */
.invoice-form .modal-card {
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .invoice-form .modal-card {
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.invoice-form .invoice-preview-content {
  font-size: 1rem;
}

.invoice-form .invoice-preview-content .table {
  margin-top: 1.5rem;
}

.invoice-form .invoice-preview-content .table th {
  background: var(--bulma-scheme-main-bis);
}

.invoice-form .invoice-preview-content .table tfoot td {
  background: var(--bulma-scheme-main-bis);
  font-size: 1.1rem;
}

/* Make "Networks" text white in dark mode for invoice preview */
[data-theme="dark"] .invoice-form .invoice-preview-content .logo-networks {
  fill: #ffffff;
}

/* Tablet responsive adjustments (iPad portrait, etc.) */
@media screen and (max-width: 1024px) {
  .invoice-form .line-items-section {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .invoice-form .line-items-section .invoice-section-header {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .invoice-form .line-items-table thead th:first-child,
  .invoice-form .line-items-table tbody td:first-child,
  .invoice-form .line-items-table tfoot td:first-child {
    padding-left: 0.5rem;
  }

  .invoice-form .line-items-table thead th:last-child,
  .invoice-form .line-items-table tbody td:last-child,
  .invoice-form .line-items-table tfoot td:last-child {
    padding-right: 0.5rem;
  }

  .invoice-form .running-total-amount {
    font-size: 1.25rem;
  }
}

/* Mobile responsive adjustments */
@media screen and (max-width: 768px) {
  .invoice-form .invoice-editor-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .invoice-form .invoice-editor-header .buttons {
    width: 100%;
    justify-content: flex-start;
  }

  .invoice-form .details-grid {
    grid-template-columns: 1fr;
  }

  .invoice-form .status-toggles {
    flex-direction: column;
    gap: 1rem;
  }

  .invoice-form .invoice-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .invoice-form .invoice-actions .buttons {
    justify-content: center;
  }

  .invoice-form .invoice-actions .button.is-danger {
    width: auto;
    align-self: center;
  }

  .invoice-form .line-items-table-wrapper {
    margin: 0 -1rem;
  }

  .invoice-form .line-items-table thead th:first-child,
  .invoice-form .line-items-table tbody td:first-child,
  .invoice-form .line-items-table tfoot td:first-child {
    padding-left: 1rem;
  }

  .invoice-form .line-items-table thead th:last-child,
  .invoice-form .line-items-table tbody td:last-child,
  .invoice-form .line-items-table tfoot td:last-child {
    padding-right: 1rem;
  }
}
