:root {
  --primary-darker: #4b340f;
  --primary-dark: #e5b73e;
  --primary-base: #f1c34a;
  --primary-light: #ffebc2;
  --primary-lighter: #fef7ec;
  --secondary: #6d6043;
  --bg-strong-900: #000000;
  --bg-surface-700: #1e1e1e;
  --bg-soft-200: #e8e8e8;
  --bg-weak-100: #f2f2f2;
  --bg-white-0: #ffffff;
  --text-main-900: #000000;
  --text-sub-500: #404040;
  --text-soft-400: #686868;
  --text-disabled-300: #929292;
  --text-white-0: #ffffff;
  --stroke-strong-900: #000000;
  --stroke-sub-300: #bebebe;
  --stroke-soft-200: #e8e8e8;
  --stroke-disabled-100: #f2f2f2;
  --stroke-white-0: #ffffff;
  --icon-strong: #000000;
  --icon-sub: #404040;
  --icon-soft: #686868;
  --icon-disabled: #929292;
  --icon-white: #ffffff;
  --yellow: #f1c34a;
  --cream: #fff9ea;
  --brown: #6d6043;
  --light-brown: #f2ebd1;
  --dark-red: #721c24;
  --dark-green: #1a9459;
  --border-radius-small: 8px;
  --border-radius-medium: 12px;
  --border-radius-large: 16px;
  --state-success: #00c851;
  --state-warning: #ff8800;
  --state-error: #ff3547;
  --state-information: #2196f3;
  --state-wait: #ffbb00;
  --state-feature: #8c0bff;
  --state-neutral: #686868;
  --state-verified: #00b8d4;
  --price-color: #555;
  --old-price-color: #999;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border-color: #e5e5e5;
  --border-light: #f0f0f0;
  --success-color: #22c55e;
  --error-color: #ef4444;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --shadow-sm: 0 1px 8px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 16px -1px rgb(0 0 0 / 0.1), 0 2px 16px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 16px -3px rgb(0 0 0 / 0.1),
    0 4px 16px -4px rgb(0 0 0 / 0.1);
  --border-raduis-small: 8px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  /* Aliases for cross-file compatibility */
  --text-main: var(--text-main-900);
  --text-sub: var(--text-sub-500);
  --text-white: var(--text-white-0);
  --stroke-soft: var(--stroke-soft-200);
  --bg-white: var(--bg-white-0);
  --bg-weak: var(--bg-weak-100);
  --text-soft: var(--text-soft-400);
  --text-disabled: var(--text-disabled-300);
  --stroke-sub: var(--stroke-sub-300);
  --transition-speed: 0.2s;
  --box-shadow: var(--shadow-md);
  --black: #000000;
  --border-radius: var(--radius-md);
  --gray-light: var(--gray-100);
  --gray: var(--gray-300);
  --gray-dark: var(--gray-700);
  --danger-color: var(--error-color);
  --primary-color: var(--primary-base);
  --secondary-color: var(--yellow);
  --secondary-hover: var(--primary-dark);
  --shadow-light: var(--shadow-sm);
  --shadow-medium: var(--shadow-md);
  --shadow-hover: var(--shadow-md);
}

/* Reusable components */

/* Buttons */
.fbm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  text-decoration: none;
  /* Ensure equal visual height for <a> and <button> (outlined vs filled) */
  box-sizing: border-box;
  height: 48px;
}

.fbm-btn-primary {
  background: var(--primary-base);
  color: var(--text-primary);
}

.fbm-btn-primary:hover:not(:disabled) {
  color: #fff;
  box-shadow: var(--shadow-md);
}

.fbm-btn-primary:disabled {
  background: var(--gray-300);
  color: var(--gray-500);
  cursor: not-allowed;
}

.fbm-btn-secondary {
  background: var(--secondary);
  color: var(--white);
}

.fbm-btn-full {
  width: 100%;
}

.fbm-btn-outlined {
  background: transparent;
  border: 1px solid var(--primary-base);
  color: var(--primary-base);
}

.fbm-btn-outlined:hover {
  background: var(--primary-base);
  color: #fff;
}

/* New: Secondary outlined button */
.fbm-btn-outlined-secondary {
  background: transparent;
  border: 1px solid var(--secondary);
  color: var(--secondary);
}
.fbm-btn-outlined-secondary:hover:not(:disabled) {
  background: var(--secondary);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}
.fbm-btn-outlined-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* New: Danger button */
.fbm-btn-danger {
  background: var(--error-color);
  color: var(--white);
}
.fbm-btn-danger:hover:not(:disabled) {
  filter: brightness(0.95);
  box-shadow: var(--shadow-md);
}
.fbm-btn-danger:disabled {
  background: #fecaca;
  color: #b91c1c;
  cursor: not-allowed;
}

/* Card */
.fbm-card {
  background: var(--white);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-md);
  padding: 24px;
}

/* New: Card header/footer (hyphen and underscore variants) */
.fbm-card-header{
  background: var(--cream);
  padding: 14px 20px;
}
.fbm-card-header-title{
  color: var(--brown);
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fbm-card-content{
  padding: 24px;
}
.fbm-card-footer{
  padding: 12px 20px;
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
}

/* Form Components */
/* Variables for form controls (scoped for easy theming) */
:root {
  --fbm-input-bg: var(--white);
  --fbm-input-color: var(--text-primary);
  --fbm-input-border: var(--border-color);
  --fbm-input-placeholder: var(--text-muted);
  --fbm-input-radius: var(--radius-md);
  --fbm-input-padding-y: 12px;
  --fbm-input-padding-x: 16px;
  --fbm-input-font-size: 16px;
  --fbm-focus-ring: 0 0 0 3px rgba(241, 164, 40, 0.1);
}

/* Group and labels */
.fbm-form-group {
  margin-bottom: 16px;
}
.fbm-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}
.fbm-help-text {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

/* Text inputs, selects, textarea */
.fbm-input,
.fbm-select,
.fbm-textarea {
  width: 100%;
  padding: var(--fbm-input-padding-y) var(--fbm-input-padding-x) !important;
  border: 1px solid var(--fbm-input-border) !important;
  border-radius: var(--fbm-input-radius);
  font-size: var(--fbm-input-font-size);
  transition: 0.2s;
  background: var(--fbm-input-bg);
  color: var(--fbm-input-color) !important;
}
.fbm-input::placeholder,
.fbm-textarea::placeholder {
  color: var(--fbm-input-placeholder);
}
.fbm-input:focus,
.fbm-select:focus,
.fbm-textarea:focus {
  border-color: var(--primary-base);
  outline: 0;
  box-shadow: var(--fbm-focus-ring);
}
.fbm-input:disabled,
.fbm-select:disabled,
.fbm-textarea:disabled {
  background: var(--gray-100);
  color: var(--text-soft);
  cursor: not-allowed;
}
.fbm-input[readonly],
.fbm-textarea[readonly] {
  background: var(--gray-50);
  color: var(--text-secondary);
}

/* Select appearance fix with simple arrow */
.fbm-select {
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(
      45deg,
      transparent 50%,
      var(--text-muted) 50%
    ),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 3px),
    calc(100% - 11px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 40px; /* room for arrow */
}

/* Sizes */
.fbm-input-sm,
.fbm-select-sm,
.fbm-textarea-sm {
  padding: 8px 12px;
  font-size: 14px;
}
.fbm-input-lg,
.fbm-select-lg,
.fbm-textarea-lg {
  padding: 14px 18px;
  font-size: 18px;
}

/* Validation states */
.fbm-input.is-error,
.fbm-select.is-error,
.fbm-textarea.is-error {
  border-color: var(--error-color) !important;
  background-color: #fef2f2 !important;
}
.fbm-input.is-error:focus,
.fbm-select.is-error:focus,
.fbm-textarea.is-error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}
.fbm-input.is-success,
.fbm-select.is-success,
.fbm-textarea.is-success {
  border-color: var(--success-color) !important;
  background-color: #f8fff8 !important;
}
.fbm-input.is-success:focus,
.fbm-select.is-success:focus,
.fbm-textarea.is-success:focus {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15) !important;
}

.fbm-error-message {
  color: var(--error-color);
  font-size: 12px;
  margin-top: 4px;
  display: block;
  font-weight: 500;
  animation: 0.3s fbmErrorSlideIn;
}
.fbm-validation-message {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0.95;
  transition: 0.3s;
}
@keyframes fbmErrorSlideIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Inputs with icons */
.fbm-input-container {
  position: relative;
  display: flex;
  align-items: center;
}
.fbm-input-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  opacity: 0.9;
  pointer-events: none;
}
.fbm-input-icon--left {
  left: 12px;
}
.fbm-input-icon--right {
  right: 12px;
}
.fbm-input.has-icon-left {
  padding-left: 44px;
}
.fbm-input.has-icon-right {
  padding-right: 44px;
}

/* Input group with addons */
.fbm-input-group {
  display: flex;
  width: 100%;
}
.fbm-input-addon {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: var(--gray-100);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.fbm-input-group > .fbm-input-addon:first-child {
  border-right: 0;
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
}
.fbm-input-group > .fbm-input-addon:last-child {
  border-left: 0;
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}
.fbm-input-group > .fbm-input {
  border-radius: 0;
}
.fbm-input-group > .fbm-input:first-child {
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
}
.fbm-input-group > .fbm-input:last-child {
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

/* Checkbox */
.fbm-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.fbm-checkbox-input {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
  position: relative;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}
.fbm-checkbox-input:hover {
  border-color: #d1d5db;
}
.fbm-checkbox-input:focus {
  outline: 0;
  border-color: var(--primary-base);
}
.fbm-checkbox-input:checked {
  background: var(--primary-base);
  border-color: var(--primary-base);
}

.fbm-checkbox-input[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Radio */
.fbm-radio {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.fbm-radio-input {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #e5e7eb;
  border-radius: 50%;
  background: #fff;
  position: relative;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}
.fbm-radio-input:hover {
  border-color: #d1d5db;
}
.fbm-radio-input:focus {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(241, 195, 74, 0.25);
  border-color: var(--primary-base);
}
.fbm-radio-input:checked {
  border-color: var(--primary-base);
}
.fbm-radio-input:checked::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--primary-base);
  border-radius: 50%;
}

/* Switch (toggle) */
.fbm-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.fbm-switch-input {
  display: none;
}
.fbm-switch-track {
  width: 40px;
  height: 22px;
  background: var(--gray-300);
  border-radius: 9999px;
  position: relative;
  transition: 0.2s;
}
.fbm-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}
.fbm-switch-input:checked + .fbm-switch-track {
  background: var(--primary-base);
}
.fbm-switch-input:checked + .fbm-switch-track .fbm-switch-thumb {
  transform: translateX(18px);
}

/* Form layout helpers */
.fbm-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.fbm-form-row--3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.fbm-form-row--4 {
  grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 768px) {
  .fbm-form-row,
  .fbm-form-row--3,
  .fbm-form-row--4 {
    grid-template-columns: 1fr;
  }
}

/* Generic message styles */
.fbm-message {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  display: block;
}
.fbm-message-success,
.fbm-message.success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.fbm-message-error,
.fbm-message.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.fbm-message-warning,
.fbm-message.warning {
  background: #fefce8;
  color: #a16207;
  border: 1px solid #fde047;
}
.fbm-message-info,
.fbm-message.info {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #dbeafe;
}

/* Autocomplete (reusable) */
.fbm-autocomplete-wrapper {
  position: relative;
}
.fbm-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e1e5e9;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  display: none;
}
.fbm-autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  font-size: 14px;
  color: #333;
  transition: background-color 0.2s;
  background: #fff;
}
.fbm-autocomplete-item.highlighted,
.fbm-autocomplete-item:hover {
  background-color: #f8f9fa;
  color: var(--brown);
}

/* Back-compat helpers for existing JS hooks */
.input-error {
  border-color: var(--error-color) !important;
  background-color: #fef2f2 !important;
}
.input-error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
  outline: 0 !important;
}
.validation-message {
  color: var(--error-color);
  font-size: 12px;
  margin-top: 4px;
  font-weight: 500;
}

/* Modal Component */
.fbm_modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 99999;
  max-width: 480px !important;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
}
.fbm_modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.fbm_modal-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.fbm_modal-header-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: 0.2s;
}
.fbm_modal-header-close:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}
.fbm_modal-body {
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.fbm_modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: var(--gray-50);
}
.fbm_modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99998;
}
.fbm_show {
  display: flex !important;
}
.fbm_hide {
  display: none !important;
}

/* Validation Modal Specific Styles */
#fbm_invoice_validation_modal .fbm_modal-body {
  padding: 24px;
}
.fbm-validation-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  text-align: left;
}
.fbm-validation-modal-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}
.fbm-validation-modal-list {
  list-style: none;
  padding: 0;
  margin: 16px 0;
}
.fbm-validation-modal-list li {
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
}
.fbm-validation-modal-list li:last-child {
  padding-bottom: 0;
}
