/* bom-ui.css — Editor de Receita (BOM) + Variações (Material Design 3 light) */

:root {
  --bom-surface: #ffffff;
  --bom-surface-2: #f7f9f7;
  --bom-surface-3: #eef1ee;
  --bom-outline: #d7dcd7;
  --bom-outline-soft: #e7ebe7;
  --bom-on-surface: #1c1f1c;
  --bom-on-surface-var: #44483f;
  --bom-primary: #2e7d32;
  --bom-primary-container: #c8e6c9;
  --bom-on-primary: #ffffff;
  --bom-error: #b3261e;
  --bom-warning: #c27a00;
  --bom-proposed-bg: #fff8e1;
  --bom-proposed-border: #ffd966;
  --bom-radius: 12px;
  --bom-radius-sm: 8px;
  --bom-shadow: 0 8px 30px rgba(0, 0, 0, 0.14);
  --bom-font: 'DM Sans', 'Roboto Flex', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Backdrop */
.bom-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 20, 15, 0.45);
  z-index: 9000;
  display: none;
  backdrop-filter: blur(2px);
}
.bom-backdrop.is-open { display: flex; align-items: center; justify-content: center; }

#bom-modal-root { position: fixed; inset: 0; z-index: 9001; pointer-events: none; }
#bom-modal-root > * { pointer-events: auto; }

/* Modal */
.bom-modal {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 860px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px);
  background: var(--bom-surface);
  border-radius: var(--bom-radius);
  box-shadow: var(--bom-shadow);
  display: flex; flex-direction: column;
  font-family: var(--bom-font);
  color: var(--bom-on-surface);
  overflow: hidden;
}
.bom-modal--wide { width: 920px; }

.bom-modal__header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--bom-outline-soft);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.bom-modal__eyebrow {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--bom-on-surface-var); font-weight: 600;
}
.bom-modal__title {
  margin: 4px 0 0; font-size: 18px; font-weight: 600; line-height: 1.35;
}
.bom-modal__body {
  padding: 16px 24px; overflow: auto; flex: 1 1 auto;
}
.bom-modal__footer {
  padding: 14px 24px;
  border-top: 1px solid var(--bom-outline-soft);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--bom-surface-2);
}

/* Toolbar */
.bom-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.bom-hint {
  font-size: 13px; color: var(--bom-on-surface-var); margin-left: auto;
}
.bom-chk {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--bom-on-surface-var);
}
.bom-chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--bom-surface-3); font-size: 11px; color: var(--bom-on-surface-var);
}
.bom-badge {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  background: var(--bom-proposed-border); color: #6a4a00;
  font-size: 10px; font-weight: 600; margin-left: 6px; vertical-align: middle;
}

/* Buttons */
.bom-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 999px;
  font-family: inherit; font-size: 14px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s, box-shadow .15s, border-color .15s;
  line-height: 1; background: transparent; color: var(--bom-on-surface);
}
.bom-btn .material-icons { font-size: 18px; }
.bom-btn:hover { background: var(--bom-surface-3); }
.bom-btn:disabled { opacity: .55; cursor: not-allowed; }
.bom-btn--primary {
  background: var(--bom-primary); color: var(--bom-on-primary);
  border-color: var(--bom-primary);
}
.bom-btn--primary:hover { background: #1f5f23; border-color: #1f5f23; }
.bom-btn--ghost { border-color: var(--bom-outline); }
.bom-btn--text { background: transparent; }
.bom-btn--sm { padding: 6px 12px; font-size: 13px; }

.bom-iconbtn {
  background: transparent; border: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--bom-on-surface-var);
  transition: background .15s;
}
.bom-iconbtn:hover { background: var(--bom-surface-3); }
.bom-iconbtn--danger:hover { background: #fdecea; color: var(--bom-error); }
.bom-iconbtn .material-icons { font-size: 20px; }

/* Table */
.bom-table-wrap {
  border: 1px solid var(--bom-outline-soft);
  border-radius: var(--bom-radius-sm);
  overflow: hidden;
  background: var(--bom-surface);
}
.bom-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px; color: var(--bom-on-surface);
}
.bom-table th, .bom-table td {
  padding: 8px 10px; text-align: left;
  border-bottom: 1px solid var(--bom-outline-soft);
  vertical-align: middle;
}
.bom-table th {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--bom-on-surface-var); background: var(--bom-surface-2);
  font-weight: 600;
}
.bom-table tbody tr:last-child td { border-bottom: none; }
.bom-table tbody tr.is-proposed {
  background: var(--bom-proposed-bg);
}
.bom-empty {
  text-align: center; padding: 22px !important;
  color: var(--bom-on-surface-var); font-style: italic;
}
.bom-comp-name { font-weight: 500; }
.bom-comp-sku { font-size: 11px; color: var(--bom-on-surface-var); margin-top: 2px; }

/* Inputs */
.bom-inp {
  width: 100%; box-sizing: border-box;
  padding: 7px 10px; font-family: inherit; font-size: 13px;
  border: 1px solid var(--bom-outline);
  border-radius: var(--bom-radius-sm);
  background: var(--bom-surface);
  color: var(--bom-on-surface);
  transition: border-color .15s, box-shadow .15s;
}
.bom-inp:focus {
  outline: none; border-color: var(--bom-primary);
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.15);
}
.bom-inp--sm { max-width: 200px; }
select.bom-inp { appearance: none; padding-right: 24px; background-repeat: no-repeat; background-position: right 8px center; }

/* Add row / typeahead */
.bom-add-row {
  margin-top: 14px;
  padding: 12px;
  background: var(--bom-surface-2);
  border: 1px dashed var(--bom-outline);
  border-radius: var(--bom-radius-sm);
}
.bom-ta { position: relative; }
.bom-ta-input {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px; font-size: 14px;
  border: 1px solid var(--bom-outline); border-radius: var(--bom-radius-sm);
  background: var(--bom-surface); color: var(--bom-on-surface);
}
.bom-ta-input:focus { outline: none; border-color: var(--bom-primary); }
.bom-ta-drop {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px;
  max-height: 280px; overflow: auto;
  background: var(--bom-surface);
  border: 1px solid var(--bom-outline);
  border-radius: var(--bom-radius-sm);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
  z-index: 10;
}
.bom-ta-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--bom-outline-soft); }
.bom-ta-item:last-child { border-bottom: none; }
.bom-ta-item:hover { background: var(--bom-surface-2); }
.bom-ta-name { font-size: 13px; font-weight: 500; }
.bom-ta-meta { display: flex; gap: 8px; margin-top: 2px; font-size: 11px; color: var(--bom-on-surface-var); }
.bom-ta-tag { padding: 1px 6px; border-radius: 4px; background: var(--bom-surface-3); }
.bom-ta-empty { padding: 10px 12px; font-size: 12px; color: var(--bom-on-surface-var); font-style: italic; }

/* Switch */
.bom-switch {
  position: relative; display: inline-block; width: 40px; height: 22px;
}
.bom-switch input { opacity: 0; width: 0; height: 0; }
.bom-switch span {
  position: absolute; inset: 0;
  background: var(--bom-outline); border-radius: 22px;
  cursor: pointer; transition: background .2s;
}
.bom-switch span::before {
  content: ''; position: absolute;
  height: 18px; width: 18px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.bom-switch input:checked + span { background: var(--bom-primary); }
.bom-switch input:checked + span::before { transform: translateX(18px); }

/* Spin */
.bom-spin { animation: bom-rotate 1s linear infinite; }
@keyframes bom-rotate {
  from { transform: rotate(0deg); } to { transform: rotate(360deg); }
}

/* Var modal specifics */
.var-modal { width: 860px; }

/* Responsive */
@media (max-width: 720px) {
  .bom-modal, .bom-modal--wide, .var-modal {
    width: calc(100vw - 16px); max-height: calc(100vh - 24px);
  }
  .bom-modal__body { padding: 12px 14px; }
  .bom-modal__header, .bom-modal__footer { padding: 12px 14px; }
  .bom-table th, .bom-table td { padding: 6px 8px; }
}
