/* =====================================================================
   GaliVue V5.1.150 — UNIFIED CONFIRMATION ACTIONS

   UI-only owner for the shared #confirmDialog action area.
   Goal: keep the approved phone action hierarchy on compact/tablet widths,
   remove empty two-column slots when an optional action is hidden, and let
   every standard confirmation action use the full available width.

   No workflow, project, storage, delivery, auth or backend logic lives here.
   ===================================================================== */

/* Shared safety: hidden optional actions must never reserve a grid slot. */
#confirmDialog .confirm-actions > .hidden{
  display:none!important;
}

#confirmDialog .confirm-actions > button{
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
}

/*
   Compact + tablet owner (phones, iPad/tablet, narrow desktop windows).
   Existing phone dialogs already use this visual language; V5.1.150 extends
   it through 1100px so tablet no longer falls back to desktop two-column
   confirmation grids.
*/
@media (max-width:1100px){
  #confirmDialog .confirm-actions,
  #confirmDialog.gv3917-confirm-dialog .confirm-actions,
  #confirmDialog.gv3917-email-dialog .confirm-actions,
  #confirmDialog.gv3917-leave-dialog .confirm-actions,
  #confirmDialog.client-selection-confirm-dialog .confirm-actions,
  #confirmDialog.gv3947-delete-project-dialog .confirm-actions,
  html[data-language] #confirmDialog .confirm-actions,
  html[data-language] #confirmDialog.gv3917-email-dialog .confirm-actions,
  html[data-language] #confirmDialog.gv3917-leave-dialog .confirm-actions,
  html[data-language] #confirmDialog.client-selection-confirm-dialog .confirm-actions,
  html[data-language] #confirmDialog.gv3947-delete-project-dialog .confirm-actions{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-auto-flow:row!important;
    align-items:stretch!important;
    gap:12px!important;
  }

  #confirmDialog .confirm-actions > button:not(.hidden),
  #confirmDialog.gv3917-email-dialog .confirm-actions > button:not(.hidden),
  #confirmDialog.gv3917-leave-dialog .confirm-actions > button:not(.hidden),
  #confirmDialog.client-selection-confirm-dialog .confirm-actions > button:not(.hidden),
  #confirmDialog.gv3947-delete-project-dialog .confirm-actions > button:not(.hidden),
  html[data-language] #confirmDialog .confirm-actions > button:not(.hidden){
    width:100%!important;
    max-width:none!important;
    min-height:50px!important;
    grid-column:auto!important;
    justify-self:stretch!important;
  }

  /* Preserve the approved leave-project hierarchy from phone:
     choice/action(s) first, Continue working last as the calm text action. */
  #confirmDialog.gv3917-leave-dialog #confirmDangerChoice:not(.hidden){order:1!important}
  #confirmDialog.gv3917-leave-dialog #confirmAccept:not(.hidden){order:2!important}
  #confirmDialog.gv3917-leave-dialog #confirmCancel:not(.hidden){
    order:3!important;
    grid-column:auto!important;
    min-height:44px!important;
    background:transparent!important;
    border-color:transparent!important;
    box-shadow:none!important;
    text-decoration:underline!important;
  }

  /* Client-selection confirmation already uses primary-first on phone. */
  #confirmDialog.client-selection-confirm-dialog #confirmAccept:not(.hidden){order:1!important}
  #confirmDialog.client-selection-confirm-dialog #confirmCancel:not(.hidden){order:2!important}

  /* Generic destructive confirmations keep the decision button and the
     safe back/cancel action as two clear full-width rows. */
  #confirmDialog.gv3947-delete-project-dialog #confirmAccept:not(.hidden){order:1!important}
  #confirmDialog.gv3947-delete-project-dialog #confirmCancel:not(.hidden){order:2!important}
}

/* Desktop safety for the exact optional-action failure seen in New Project:
   if Save project & leave is hidden, never keep its old second grid column. */
@media (min-width:1101px){
  #confirmDialog.gv3917-leave-dialog .confirm-actions:has(#confirmAccept.hidden){
    grid-template-columns:minmax(0,1fr)!important;
  }
  #confirmDialog.gv3917-leave-dialog .confirm-actions:has(#confirmAccept.hidden) #confirmDangerChoice:not(.hidden){
    width:min(360px,100%)!important;
    justify-self:start!important;
  }
  #confirmDialog.gv3917-leave-dialog .confirm-actions:has(#confirmAccept.hidden) #confirmCancel:not(.hidden){
    width:auto!important;
    justify-self:center!important;
    grid-column:auto!important;
  }
}
