/* =========================================================
   Shared look (v2) for classic entry forms (form-v2-auto.js adds .v2f):
   DEMAND, PO, GRN, GRN_R, SSALE, QUOT, SQUOT, DC, SALE_RET, STKTRANS, ITEMCONV.
   Same rules as the Sale form (form-v2.css): editable = white + border,
   system-filled = grey without border, compact 29px fields / 24px line cells,
   one primary action, More menu, Delete apart. Colours only from theme tokens.
   !important is used where odoo.css sizes fields with #form-id rules.
   ========================================================= */

html body .o_action.v2f {
  --f-text: var(--qc-text, var(--o-text));
  --f-muted: var(--qc-muted, var(--o-muted));
  --f-page: var(--qc-page, var(--o-bg));
  --f-card: var(--qc-panel, var(--o-panel));
  --f-line: var(--qc-border, var(--o-border));
  --f-line-strong: var(--qc-border-strong, var(--o-input-border));
  --f-field: var(--qc-input-bg, #ffffff);
  --f-ro: var(--qc-readonly-bg, #eef0f2);
  --f-hover: var(--qc-hover, var(--o-hover));
  --f-on-accent: var(--et-on-accent, #ffffff);
  --f-danger: #c42b2b; --f-danger-soft: #fdeaea;
  --f-warn: #a85b06; --f-warn-soft: #fdf1df;
  --f-ok: #157347; --f-ok-soft: #e3f4ea;
  --f-h: 1.8rem;
}
html[data-theme="dark"] body .o_action.v2f {
  --f-field: var(--qc-input-bg, #121a22);
  --f-ro: var(--qc-readonly-bg, #1d2731);
  --f-danger: #ff7b7b; --f-danger-soft: #3c1a1a;
  --f-warn: #f2b54a; --f-warn-soft: #3a2c12;
  --f-ok: #4ccf8a; --f-ok-soft: #163526;
}

/* ---------- Header + toolbar ---------- */
html body .o_action.v2f .o_control_panel {
  padding: 0.4rem 0.75rem;
  background: var(--f-page);
  border: 0;
  border-bottom: 1px solid var(--f-line);
  box-shadow: none;
  position: relative; /* own layer so the More menu paints above the sheet */
  z-index: 30;
}
html body .o_action.v2f .o_breadcrumb { font-size: 0.7rem; color: var(--f-muted); }
html body .o_action.v2f .o_breadcrumb a { color: var(--f-muted); }
html body .o_action.v2f .o_cp_title { font-size: 1.1rem; font-weight: 600; color: var(--f-text); margin: 0; }
html body .o_action.v2f .o_cp_right { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
html body .o_action.v2f .o_cp_right .btn-odoo {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  height: var(--f-h); padding: 0 0.7rem;
  border: 1px solid var(--f-line-strong); border-radius: 6px;
  background: var(--f-card); color: var(--f-text);
  font-size: 0.8rem; font-weight: 500; line-height: 1; box-shadow: none; white-space: nowrap;
}
html body .o_action.v2f .o_cp_right .btn-odoo:hover:not(:disabled) { background: var(--f-hover); }
html body .o_action.v2f .o_cp_right .btn-odoo:disabled { opacity: 0.5; cursor: not-allowed; }
html body .o_action.v2f .o_cp_right .btn-odoo.v2f-primary { background: var(--o-accent); border-color: var(--o-accent); color: var(--f-on-accent); font-weight: 600; }
html body .o_action.v2f .o_cp_right .btn-odoo.v2f-primary:hover { background: var(--o-accent-dark); border-color: var(--o-accent-dark); }
html body .o_action.v2f .o_cp_right .btn-odoo.v2f-danger { background: transparent; border-color: transparent; color: var(--f-danger); }
html body .o_action.v2f .o_cp_right .btn-odoo.v2f-danger:hover { background: var(--f-danger-soft); }
html body .o_action.v2f .o_cp_right .btn-odoo.v2f-ghost { background: transparent; border-color: transparent; color: var(--f-muted); }
html body .o_action.v2f .o_cp_right .btn-odoo.v2f-ghost:hover { background: var(--f-hover); color: var(--f-text); }
html body .o_action.v2f .o_cp_right .btn-odoo.v2f-warn { background: var(--f-warn-soft); border-color: var(--f-warn); color: var(--f-warn); }
html body .o_action.v2f .o_cp_right .btn-odoo.v2f-warn[hidden] { display: none; }
html body .o_action.v2f .v2f-sep { width: 1px; height: 1.4rem; background: var(--f-line-strong); margin: 0 0.2rem; }
html body .o_action.v2f .v2f-more { position: relative; }
html body .o_action.v2f .v2f-more-btn[aria-expanded="true"] { background: var(--f-hover); }
html body .o_action.v2f .v2f-menu {
  position: absolute; right: 0; top: calc(100% + 0.3rem); z-index: 60;
  min-width: 13rem; display: grid; padding: 0.25rem;
  background: var(--f-card); border: 1px solid var(--f-line); border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
}
html body .o_action.v2f .v2f-menu[hidden] { display: none; }
html body .o_action.v2f .o_cp_right .v2f-menu .btn-odoo.v2f-menuitem {
  justify-content: flex-start; width: 100%; height: auto; padding: 0.5rem 0.7rem;
  border: 0; border-radius: 5px; background: transparent; color: var(--f-text);
  font-size: 0.84rem; text-align: left; text-decoration: none;
}
html body .o_action.v2f .o_cp_right .v2f-menu .btn-odoo.v2f-menuitem:hover:not(:disabled),
html body .o_action.v2f .o_cp_right .v2f-menu .btn-odoo.v2f-menuitem:focus-visible { background: var(--f-hover); outline: none; }
html body .o_action.v2f .o_cp_right .v2f-menu .btn-odoo.v2f-menuitem:disabled { color: var(--f-muted); opacity: 0.6; }
html body .o_action.v2f .o_cp_right .v2f-menu .btn-odoo.v2f-menuitem[hidden] { display: none; }

/* ---------- Sheet ---------- */
html body .o_action.v2f > form > .o_content { background: var(--f-page); padding: 0.55rem 0.75rem 1rem; }
html body .o_action.v2f .o_form_sheet_bg {
  background: var(--f-card);
  border: 1px solid var(--f-line);
  border-radius: 10px;
  box-shadow: none;
  padding: 0.65rem 0.75rem 0.75rem;
}
html body .o_action.v2f .o_statusbar { border: 0; background: none; padding: 0; margin: 0 0 0.35rem; }
html body .o_action.v2f .o_status {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.12rem 0.55rem; border-radius: 999px; border: 0;
  font-size: 0.72rem; font-weight: 600;
  background: var(--f-ok-soft); color: var(--f-ok);
}
html body .o_action.v2f .o_status::before { content: ""; width: 0.4rem; height: 0.4rem; border-radius: 50%; background: currentColor; }
html body .o_action.v2f .o_status.draft { background: var(--f-ro); color: var(--f-muted); }

/* ---------- Labels ---------- */
html body .o_action.v2f .o_form_sheet_bg label,
html body .o_action.v2f .quot-footer-field label {
  font-size: 0.71rem !important;
  font-weight: 500;
  letter-spacing: 0 !important;
  text-transform: none !important;
  color: var(--f-muted) !important;
}

/* ---------- Fields: editable = white + border ---------- */
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) input:where(:not([type="checkbox"], [type="radio"], [type="hidden"])),
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) select:not(.klaro-select-native),
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) textarea,
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) .klaro-select-trigger {
  min-height: var(--f-h) !important;
  border: 1px solid var(--f-line-strong) !important;
  border-radius: 6px !important;
  background: var(--f-field) !important;
  color: var(--f-text) !important;
  -webkit-text-fill-color: var(--f-text);
  font-size: 0.82rem !important;
  box-shadow: none !important;
}
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) input:where(:not([type="checkbox"], [type="radio"], [type="hidden"])),
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) select:not(.klaro-select-native),
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) .klaro-select-trigger {
  height: var(--f-h) !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) :is(input, select, textarea):focus {
  outline: none !important;
  border-color: var(--o-accent) !important;
  box-shadow: 0 0 0 3px rgba(var(--o-accent-rgb), 0.2) !important;
}
/* System-filled / locked: grey, no border */
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) input:where(:not([type="checkbox"], [type="radio"], [type="hidden"]))[readonly],
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) input:where(:not([type="checkbox"], [type="radio"], [type="hidden"])):disabled,
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) select:disabled,
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) textarea[readonly],
html body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) .klaro-select-trigger:disabled {
  background: var(--f-ro) !important;
  border-color: transparent !important;
  opacity: 1 !important;
  cursor: default;
}
html body .o_action.v2f .o_form_sheet_bg .lov-btn {
  height: var(--f-h) !important;
  min-width: var(--f-h);
  padding: 0 !important;
  border: 1px solid var(--f-line-strong) !important;
  border-radius: 6px !important;
  background: var(--f-card) !important;
  color: var(--f-muted) !important;
}
html body .o_action.v2f .o_form_sheet_bg .lov-btn:hover { color: var(--o-accent) !important; border-color: var(--o-accent) !important; }

/* ---------- Line grids: tighter cells ---------- */
html body .o_action.v2f .o_notebook_content table td { padding-top: 0.08rem !important; padding-bottom: 0.08rem !important; }
html body .o_action.v2f .o_notebook_content table td input:where(:not([type="checkbox"], [type="hidden"])),
html body .o_action.v2f .o_notebook_content table td select,
html body .o_action.v2f .o_notebook_content table td .ln-desc-preview {
  height: 1.5rem !important;
  min-height: 1.5rem !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  line-height: 1.5rem !important;
  border-color: var(--f-line-strong) !important;
  background: var(--f-field) !important;
  color: var(--f-text) !important;
  -webkit-text-fill-color: var(--f-text);
}
html body .o_action.v2f .o_notebook_content table td input[readonly],
html body .o_action.v2f .o_notebook_content table td input:disabled {
  background: var(--f-ro) !important;
  border-color: transparent !important;
  opacity: 1 !important;
}
html body .o_action.v2f .o_notebook_content table td :is(button, .lov-btn, .btn-odoo) {
  height: 1.5rem !important;
  min-height: 1.5rem !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  line-height: 1 !important;
}
html body .o_action.v2f .o_notebook_content table thead th {
  background: var(--qc-head, transparent) !important;
  color: var(--f-muted) !important;
  font-size: 0.7rem !important;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
html body .o_action.v2f .o_notebook_header { border-bottom-color: var(--f-line) !important; }
html body .o_action.v2f .o_notebook_header .o_tab { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--f-muted); border: 0; background: none; }

/* ---------- Totals footer: read-only figures, not boxes ---------- */
html body .o_action.v2f .quot-footer { background: transparent !important; border: 0 !important; box-shadow: none !important; }
html body .o_action.v2f .quot-footer-field input[readonly] {
  height: auto !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--f-text) !important;
  -webkit-text-fill-color: var(--f-text);
  font-size: 0.92rem !important;
  font-weight: 600 !important;
  text-align: left;
  box-shadow: none !important;
}
html body .o_action.v2f .quot-footer-row-grand .quot-footer-value input[readonly] {
  color: var(--o-accent) !important;
  -webkit-text-fill-color: var(--o-accent);
  font-size: 1.25rem !important;
}

/* ---------- Dark mode: app-workbench-orange.css forces inputs with !important ---------- */
html[data-theme="dark"] body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) input:where(:not([type="checkbox"], [type="radio"], [type="hidden"])),
html[data-theme="dark"] body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) select:not(.klaro-select-native),
html[data-theme="dark"] body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) textarea,
html[data-theme="dark"] body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) .klaro-select-trigger,
html[data-theme="dark"] body .o_action.v2f .o_notebook_content table td input:where(:not([type="checkbox"], [type="hidden"])) {
  background: var(--f-field) !important;
  border-color: var(--f-line-strong) !important;
  color: var(--f-text) !important;
  -webkit-text-fill-color: var(--f-text) !important;
}
html[data-theme="dark"] body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) input[readonly],
html[data-theme="dark"] body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) input:disabled,
html[data-theme="dark"] body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) select:disabled,
html[data-theme="dark"] body .o_action.v2f .o_form_sheet_bg :is(.o_field, .quot-master, .o_group) .klaro-select-trigger:disabled,
html[data-theme="dark"] body .o_action.v2f .o_notebook_content table td input[readonly],
html[data-theme="dark"] body .o_action.v2f .o_notebook_content table td input:disabled {
  background: var(--f-ro) !important;
  border-color: transparent !important;
}
html[data-theme="dark"] body .o_action.v2f .quot-footer-field input[readonly] {
  background: transparent !important;
  border-color: transparent !important;
}
html[data-theme="dark"] body .o_action.v2f .o_control_panel { background: var(--f-page) !important; border-color: var(--f-line) !important; }
html[data-theme="dark"] body .o_action.v2f .o_cp_right .btn-odoo.v2f-ghost,
html[data-theme="dark"] body .o_action.v2f .o_cp_right .btn-odoo.v2f-danger { background: transparent !important; border-color: transparent !important; }

/* -webkit-text-fill-color above also paints placeholders: keep them muted, and hidden on read-only totals. */
html body .o_action.v2f :is(input, textarea)::placeholder { -webkit-text-fill-color: var(--f-muted) !important; color: var(--f-muted) !important; opacity: 0.8; }
html body .o_action.v2f .quot-footer-field input[readonly]::placeholder { -webkit-text-fill-color: transparent !important; color: transparent !important; }
