/*
 GreenEco — Enterprise Documents Archive
 Screen: أرشيف الوثائق / المستندات

 Requirements:
 1) Commands = one equal horizontal row
 2) Filters  = one equal horizontal row
 3) Compact X button at far left of row 1
 4) No side columns / strange stretching / hover jitter
 5) Title + commands + filters fixed
 6) Table headers fixed; table body only scrolls

 No app.js / business logic / print changes.
 Version: 3.3.16.44.2.539
*/

@media screen {

  /* Exact archive route only; activated by the safe adapter. */
  .app-shell:has(.enterprise-documents-page.enterprise-documents-archive-screen){
    height:100vh!important;
    min-height:100vh!important;
    max-height:100vh!important;
    overflow:hidden!important;
  }

  .app-shell:has(.enterprise-documents-page.enterprise-documents-archive-screen)
  > .app-workspace{
    flex:1 1 auto!important;
    min-height:0!important;
    height:auto!important;
    max-height:none!important;
    overflow:hidden!important;
    position:relative!important;
    z-index:1!important;
  }

  .enterprise-documents-page.enterprise-documents-archive-screen{
    width:min(var(--theme-page-width,1180px),100%)!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    margin:0 auto!important;
    padding:0 0 6px!important;

    display:flex!important;
    flex-direction:column!important;
    flex-wrap:nowrap!important;

    overflow:hidden!important;
    box-sizing:border-box!important;
  }

  /* Fixed screen chrome. */
  .enterprise-documents-archive-screen > .page-title,
  .enterprise-documents-archive-screen > .enterprise-documents-toast,
  .enterprise-documents-archive-screen > .enterprise-documents-toolbar,
  .enterprise-documents-archive-screen > .enterprise-documents-filterbar{
    flex:0 0 auto!important;
  }

  /* ---------------------------------------------------------
     ROW 1 — equal command buttons + compact X at far left
     --------------------------------------------------------- */

  .enterprise-documents-archive-screen
  > .enterprise-documents-toolbar{
    direction:rtl!important;

    display:flex!important;
    flex-direction:row!important;
    flex-wrap:nowrap!important;
    align-items:stretch!important;
    justify-content:stretch!important;
    gap:6px!important;

    width:100%!important;
    min-width:0!important;
    max-width:100%!important;

    min-height:52px!important;
    margin:0 0 6px!important;
    padding:6px!important;

    border:1px solid #b9c4c9!important;
    border-radius:0!important;
    background:#f7f9fa!important;
    box-shadow:none!important;

    overflow:visible!important;
    box-sizing:border-box!important;

    position:relative!important;
    top:auto!important;

    transform:none!important;
    translate:none!important;
    scale:none!important;
  }

  /* Flatten the native actions wrapper into the row. */
  .enterprise-documents-archive-screen
  > .enterprise-documents-toolbar
  > .toolbar-actions{
    display:contents!important;
  }

  /* Old spacer is not needed. */
  .enterprise-documents-archive-screen
  > .enterprise-documents-toolbar
  > .enterprise-documents-toolbar-spacer{
    display:none!important;
  }

  /* All native archive commands are equal width. */
  .enterprise-documents-archive-screen
  > .enterprise-documents-toolbar
  > .toolbar-actions > button{
    flex:1 1 0!important;

    width:auto!important;
    min-width:0!important;
    max-width:none!important;

    height:40px!important;
    min-height:40px!important;
    max-height:40px!important;

    margin:0!important;
    padding:5px 9px!important;

    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    gap:6px!important;

    border-radius:0!important;
    box-sizing:border-box!important;

    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;

    transform:none!important;
    translate:none!important;
    scale:none!important;
    box-shadow:none!important;
    filter:none!important;
  }

  /*
   * Existing Exit behavior is preserved; the adapter only changes its
   * presentation to X and gives it this class.
   * It is a compact control, separate from equal business-command cells.
   */
  .enterprise-documents-archive-screen
  > .enterprise-documents-toolbar
  > button.secondary-button{
    order:99!important;
    flex:0 0 40px!important;

    width:40px!important;
    min-width:40px!important;
    max-width:40px!important;

    height:40px!important;
    min-height:40px!important;
    max-height:40px!important;

    margin:0!important;
    padding:0!important;

    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;

    border:1px solid #87969c!important;
    border-radius:0!important;
    background:#fff!important;
    color:#1b3340!important;

    /* Hide the native "خروج" text visually only; keep DOM/function intact. */
    font-size:0!important;
    line-height:1!important;

    box-sizing:border-box!important;

    transform:none!important;
    translate:none!important;
    scale:none!important;
    box-shadow:none!important;
    filter:none!important;
  }

  .enterprise-documents-archive-screen
  > .enterprise-documents-toolbar
  > button.secondary-button::before{
    content:"×"!important;
    font-size:22px!important;
    font-weight:900!important;
    line-height:1!important;
  }

  /* ---------------------------------------------------------
     ROW 2 — 8 equal archive filter cells
     --------------------------------------------------------- */

  .enterprise-documents-archive-screen
  > .enterprise-documents-filterbar{
    direction:rtl!important;

    display:grid!important;
    grid-template-columns:repeat(8,minmax(0,1fr))!important;
    align-items:stretch!important;
    gap:6px!important;

    width:100%!important;
    min-width:0!important;
    max-width:100%!important;

    min-height:58px!important;
    margin:0 0 6px!important;
    padding:6px!important;

    border:1px solid #b9c4c9!important;
    border-radius:0!important;
    background:#f7f9fa!important;
    box-shadow:none!important;

    position:relative!important;
    top:auto!important;

    overflow:visible!important;
    box-sizing:border-box!important;

    transform:none!important;
    translate:none!important;
    scale:none!important;
  }

  .enterprise-documents-archive-screen
  > .enterprise-documents-filterbar > label{
    width:100%!important;
    min-width:0!important;
    max-width:none!important;

    height:46px!important;
    min-height:46px!important;
    max-height:46px!important;

    margin:0!important;
    padding:3px 5px!important;

    display:grid!important;
    grid-template-rows:14px 28px!important;
    align-items:center!important;
    gap:0!important;

    border:1px solid #c4cdd1!important;
    border-radius:0!important;
    background:#fff!important;

    overflow:hidden!important;
    box-sizing:border-box!important;
  }

  .enterprise-documents-archive-screen
  > .enterprise-documents-filterbar > label > span{
    min-width:0!important;
    margin:0!important;
    padding:0!important;

    font-size:calc(7.8px * var(--font-scale,1))!important;
    font-weight:800!important;
    line-height:14px!important;

    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }

  .enterprise-documents-archive-screen
  > .enterprise-documents-filterbar > label > select,

  .enterprise-documents-archive-screen
  > .enterprise-documents-filterbar > label > input{
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;

    height:28px!important;
    min-height:28px!important;
    max-height:28px!important;

    margin:0!important;
    padding:3px 5px!important;

    border-radius:0!important;
    box-sizing:border-box!important;
    font-size:calc(8px * var(--font-scale,1))!important;
  }

  .enterprise-documents-archive-screen
  > .enterprise-documents-filterbar > button{
    width:100%!important;
    min-width:0!important;
    max-width:none!important;

    height:46px!important;
    min-height:46px!important;
    max-height:46px!important;

    margin:0!important;
    padding:5px 8px!important;

    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;

    border-radius:0!important;
    white-space:nowrap!important;
    box-sizing:border-box!important;

    transform:none!important;
    translate:none!important;
    scale:none!important;
    box-shadow:none!important;
    filter:none!important;
  }

  /* ---------------------------------------------------------
     FIXED SCREEN — TABLE ONLY SCROLLS
     --------------------------------------------------------- */

  .enterprise-documents-archive-screen
  > .enterprise-documents-register{
    flex:1 1 auto!important;
    min-height:0!important;
    height:0!important;
    max-height:none!important;

    width:100%!important;
    margin:0!important;
    padding:0!important;

    display:flex!important;
    flex-direction:column!important;

    overflow:hidden!important;
    box-sizing:border-box!important;
  }

  .enterprise-documents-archive-screen
  > .enterprise-documents-register
  > .table-panel{
    flex:1 1 auto!important;
    min-height:0!important;
    height:100%!important;
    max-height:100%!important;

    margin:0!important;

    display:flex!important;
    flex-direction:column!important;

    overflow:hidden!important;
    border-radius:0!important;
    box-sizing:border-box!important;
  }

  /* Search controls and pagination stay fixed. */
  .enterprise-documents-archive-screen
  > .enterprise-documents-register
  > .table-panel > .table-controls,

  .enterprise-documents-archive-screen
  > .enterprise-documents-register
  > .table-panel > .table-footer{
    flex:0 0 auto!important;
  }

  /* Table body is the only scrollable area. */
  .enterprise-documents-archive-screen
  > .enterprise-documents-register
  > .table-panel > .table-scroll{
    flex:1 1 auto!important;
    min-height:0!important;
    height:auto!important;
    max-height:none!important;

    margin:0!important;

    overflow-y:auto!important;
    overflow-x:auto!important;
    overscroll-behavior:contain!important;
    scrollbar-gutter:stable!important;
  }

  /* Table column headings remain fixed while rows scroll. */
  .enterprise-documents-archive-screen
  > .enterprise-documents-register
  .data-table thead th{
    position:sticky!important;
    top:0!important;
    z-index:4!important;
  }

  /* ---------------------------------------------------------
     NO JITTER
     --------------------------------------------------------- */

  .enterprise-documents-archive-screen button:hover:not(:disabled),
  .enterprise-documents-archive-screen button:focus-visible,
  .enterprise-documents-archive-screen button:active{
    transform:none!important;
    translate:none!important;
    scale:none!important;
    box-shadow:none!important;
    filter:none!important;
  }
}

/* Preserve the two horizontal rows on narrower windows.
   Scroll horizontally instead of wrapping into side columns. */
@media screen and (max-width:1050px){

  .enterprise-documents-archive-screen
  > .enterprise-documents-toolbar{
    min-width:900px!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
  }

  .enterprise-documents-archive-screen
  > .enterprise-documents-filterbar{
    min-width:1040px!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
  }
}
