/* A197 ENTERPRISE BUTTON SYSTEM - FINAL GLOBAL FIX
   Obiettivo: eliminare definitivamente bottoni bianchi/glass con testo azzurrino poco leggibile.
   Regole: caricato per ultimo tramite after_request, non modifica layout/route/funzioni.
*/
:root{
  --a197-btn-bg:#14233d;
  --a197-btn-bg-2:#0f1b31;
  --a197-btn-hover:#1d355d;
  --a197-btn-primary:#2563eb;
  --a197-btn-primary-hover:#1d4ed8;
  --a197-btn-border:rgba(125,211,252,.42);
  --a197-btn-text:#ffffff;
  --a197-btn-muted:#dbeafe;
  --a197-danger:#b91c1c;
  --a197-danger-hover:#991b1b;
  --a197-success:#047857;
}

/* Pulsanti veri + link styled button + azioni in toolbar/card/table */
html body :is(
  button,
  input[type="submit"],
  input[type="button"],
  input[type="reset"],
  a.btn,
  .btn,
  .button,
  .pro-cta,
  .cta,
  .cta-secondary,
  .action-btn,
  .page-action,
  .toolbar a,
  .toolbar button,
  .table-actions a,
  .table-actions button,
  .actions a,
  .actions button,
  .quick-action,
  .pill-action,
  .a181-small-action,
  .a189-action,
  .a168-action,
  [role="button"]
):not(.nav-toggle):not(.drawer-close):not(.sidebar-toggle):not(.icon-only){
  background:linear-gradient(180deg,var(--a197-btn-bg),var(--a197-btn-bg-2)) !important;
  background-color:var(--a197-btn-bg) !important;
  color:var(--a197-btn-text) !important;
  -webkit-text-fill-color:var(--a197-btn-text) !important;
  border:1px solid var(--a197-btn-border) !important;
  box-shadow:0 10px 24px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.10) !important;
  text-shadow:none !important;
  filter:none !important;
  opacity:1 !important;
  text-decoration:none !important;
  font-weight:800 !important;
  letter-spacing:.01em !important;
  outline:none !important;
}

html body :is(
  button,
  input[type="submit"],
  input[type="button"],
  input[type="reset"],
  a.btn,
  .btn,
  .button,
  .pro-cta,
  .cta,
  .cta-secondary,
  .action-btn,
  .page-action,
  .toolbar a,
  .toolbar button,
  .table-actions a,
  .table-actions button,
  .actions a,
  .actions button,
  .quick-action,
  .pill-action,
  .a181-small-action,
  .a189-action,
  .a168-action,
  [role="button"]
):not(.nav-toggle):not(.drawer-close):not(.sidebar-toggle):not(.icon-only):hover{
  background:linear-gradient(180deg,var(--a197-btn-hover),#14294d) !important;
  background-color:var(--a197-btn-hover) !important;
  color:#ffffff !important;
  -webkit-text-fill-color:#ffffff !important;
  border-color:rgba(147,197,253,.70) !important;
  box-shadow:0 14px 32px rgba(0,0,0,.38),0 0 0 1px rgba(125,211,252,.16) inset !important;
  opacity:1 !important;
  filter:none !important;
}

/* Primary/submit */
html body :is(
  .btn.primary,
  .btn-primary,
  button.primary,
  button[type="submit"],
  input[type="submit"],
  .pro-cta.strong,
  .cta-primary,
  .primary-action,
  a.primary
):not(.nav-toggle):not(.drawer-close){
  background:linear-gradient(180deg,#3b82f6,var(--a197-btn-primary)) !important;
  background-color:var(--a197-btn-primary) !important;
  color:#ffffff !important;
  -webkit-text-fill-color:#ffffff !important;
  border-color:rgba(191,219,254,.62) !important;
}
html body :is(.btn.primary,.btn-primary,button.primary,button[type="submit"],input[type="submit"],.pro-cta.strong,.cta-primary,.primary-action,a.primary):hover{
  background:linear-gradient(180deg,#2563eb,var(--a197-btn-primary-hover)) !important;
  background-color:var(--a197-btn-primary-hover) !important;
  color:#ffffff !important;
  -webkit-text-fill-color:#ffffff !important;
}

/* Danger/delete */
html body :is(
  .btn.danger,
  .btn-danger,
  button.danger,
  .cta-danger,
  a[href*="elimina"],
  a[href*="delete"],
  form[action*="elimina"] button,
  form[action*="delete"] button,
  button[name*="elimina"],
  button[value*="elimina"],
  button[name*="delete"],
  button[value*="delete"]
):not(.nav-toggle):not(.drawer-close){
  background:linear-gradient(180deg,#ef4444,var(--a197-danger)) !important;
  background-color:var(--a197-danger) !important;
  color:#ffffff !important;
  -webkit-text-fill-color:#ffffff !important;
  border-color:rgba(254,202,202,.55) !important;
}
html body :is(.btn.danger,.btn-danger,button.danger,.cta-danger,a[href*="elimina"],a[href*="delete"],form[action*="elimina"] button,form[action*="delete"] button):hover{
  background:linear-gradient(180deg,#dc2626,var(--a197-danger-hover)) !important;
  color:#ffffff !important;
  -webkit-text-fill-color:#ffffff !important;
}

/* Success */
html body :is(.btn.success,.btn-success,button.success,.cta-success){
  background:linear-gradient(180deg,#10b981,var(--a197-success)) !important;
  background-color:var(--a197-success) !important;
  color:#ffffff !important;
  -webkit-text-fill-color:#ffffff !important;
  border-color:rgba(167,243,208,.50) !important;
}

/* Disabled veri: leggibili ma chiaramente disabilitati, mai bianchi lattiginosi */
html body :is(button,input[type="submit"],input[type="button"],input[type="reset"],.btn,.button,.pro-cta,.cta,.action-btn,.page-action)[disabled],
html body :is(button,input[type="submit"],input[type="button"],input[type="reset"],.btn,.button,.pro-cta,.cta,.action-btn,.page-action):disabled,
html body :is(.btn,.button,.pro-cta,.cta,.action-btn,.page-action).disabled,
html body :is(.btn,.button,.pro-cta,.cta,.action-btn,.page-action)[aria-disabled="true"]{
  background:linear-gradient(180deg,#334155,#1e293b) !important;
  background-color:#1e293b !important;
  color:var(--a197-btn-muted) !important;
  -webkit-text-fill-color:var(--a197-btn-muted) !important;
  border-color:rgba(148,163,184,.35) !important;
  opacity:.92 !important;
  cursor:not-allowed !important;
  box-shadow:none !important;
}

/* Correzione ereditarietà testo dentro span/svg/strong */
html body :is(button,.btn,.button,.pro-cta,.cta,.cta-secondary,.action-btn,.page-action,.toolbar a,.table-actions a,[role="button"]) :is(span,strong,em,b,small){
  color:inherit !important;
  -webkit-text-fill-color:inherit !important;
  opacity:1 !important;
}
html body :is(button,.btn,.button,.pro-cta,.cta,.cta-secondary,.action-btn,.page-action,.toolbar a,.table-actions a,[role="button"]) svg{
  color:inherit !important;
  fill:none;
  stroke:currentColor !important;
  opacity:1 !important;
}

/* Non rompere campi form */
html body input:not([type="submit"]):not([type="button"]):not([type="reset"]),
html body select,
html body textarea{
  -webkit-text-fill-color:currentColor;
}

/* Caso specifico screenshot: header action buttons dentro hero/page top */
html body :is(.hero,.page-hero,.header-actions,.page-actions,.top-actions,.card-actions) :is(a,button,.btn,.pro-cta,.cta):not(.nav-toggle):not(.drawer-close){
  background:linear-gradient(180deg,#1e3a5f,#13243e) !important;
  color:#ffffff !important;
  -webkit-text-fill-color:#ffffff !important;
  border-color:rgba(125,211,252,.50) !important;
  opacity:1 !important;
}
