/* Shared primitives (field/button/layout) reused across invoice pages & modals. */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: var(--field-padding-y) var(--field-padding-x);
  font-size: var(--field-font-size);
  line-height: 1.4;
  font-family: var(--font-ui);
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.field input,
.field select {
  min-height: var(--field-height);
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--select-padding-end);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--select-arrow-offset) center;
  background-size: var(--select-arrow-size);
  cursor: pointer;
}

:global([dir='rtl']) .field select {
  padding-right: var(--field-padding-x);
  padding-left: var(--select-padding-end);
  background-position: left var(--select-arrow-offset) center;
}

.field textarea {
  min-height: calc(var(--field-height) + 8px);
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb) / 0.12);
}

.span2 {
  grid-column: span 2;
}

.fullField {
  margin-bottom: 12px;
}

.metaGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metaGridTwo {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.formGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.actionsRow {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.totalRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 0 4px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(var(--primary-rgb) / 0.08);
  border: 1px solid rgba(var(--primary-rgb) / 0.2);
}

.totalLabel {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.totalValue {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, color 0.2s;
  white-space: nowrap;
}

.btnPrimary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 4px 14px rgba(var(--primary-rgb) / 0.3);
}

.btnPrimary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btnPrimary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btnGhost {
  color: var(--text-secondary);
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.btnGhost:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-primary);
}

.btnGhost:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.alertError {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #b91c1c;
}

.backLink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.backLink:hover {
  text-decoration: underline;
}

:global([dir='rtl']) .backLink svg {
  transform: scaleX(-1);
}

.section {
  padding: 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-glass));
  -webkit-backdrop-filter: blur(var(--blur-glass));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
}

.sectionSpaced {
  margin-top: 16px;
}

@media (max-width: 900px) {
  .metaGrid {
    grid-template-columns: 1fr;
  }

  .metaGridTwo {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .formGrid {
    grid-template-columns: 1fr;
  }

  .span2 {
    grid-column: span 1;
  }
}
