/* SEGaza V3.0.11 — compact student grid + robust mobile scrolling */
@media(max-width:760px){
  /* Students are a real horizontal table on mobile, not stacked cards. */
  #view-students .table-card{
    overflow:hidden!important;
    border:1px solid #e1e8f0!important;
    border-radius:16px!important;
    background:#fff!important;
    box-shadow:0 7px 20px rgba(21,52,84,.05)!important;
  }
  #view-students .table-scroll{
    display:block!important;
    overflow:auto!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior:contain!important;
    touch-action:pan-x pan-y!important;
    max-height:calc(100dvh - 286px)!important;
    background:#fff!important;
  }
  #view-students .ux-responsive-table{
    display:table!important;
    width:100%!important;
    min-width:940px!important;
    border-collapse:separate!important;
    border-spacing:0!important;
    table-layout:fixed!important;
    direction:rtl!important;
    background:#fff!important;
  }
  #view-students .ux-responsive-table thead{display:table-header-group!important}
  #view-students .ux-responsive-table tbody{display:table-row-group!important;padding:0!important}
  #view-students .ux-responsive-table tr{
    display:table-row!important;
    padding:0!important;
    border:0!important;
    border-radius:0!important;
    background:#fff!important;
    box-shadow:none!important;
    overflow:visible!important;
  }
  #view-students .ux-responsive-table tbody tr:nth-child(even){background:#f9fbfd!important}
  #view-students .ux-responsive-table th,
  #view-students .ux-responsive-table td{
    display:table-cell!important;
    position:relative!important;
    min-height:0!important;
    height:auto!important;
    padding:9px 8px!important;
    border:0!important;
    border-bottom:1px solid #e8edf3!important;
    border-left:1px solid #edf1f5!important;
    text-align:right!important;
    vertical-align:middle!important;
    font-size:12.5px!important;
    line-height:1.4!important;
    white-space:normal!important;
    background:inherit!important;
  }
  #view-students .ux-responsive-table td:before{display:none!important;content:none!important}
  #view-students .ux-responsive-table th{
    position:sticky!important;
    top:0!important;
    z-index:18!important;
    background:#eef3f8!important;
    color:#38526b!important;
    font-size:12px!important;
    font-weight:900!important;
    white-space:nowrap!important;
  }

  /* Keep selection + student identity visible. All other columns, including grade, scroll. */
  #view-students .ux-responsive-table th:nth-child(1),
  #view-students .ux-responsive-table td:nth-child(1){
    position:sticky!important;
    right:0!important;
    left:auto!important;
    width:48px!important;
    min-width:48px!important;
    max-width:48px!important;
    text-align:center!important;
    z-index:27!important;
    background:#fff!important;
  }
  #view-students .ux-responsive-table th:nth-child(1){z-index:42!important;background:#eaf0f6!important}
  #view-students .ux-responsive-table tbody tr:nth-child(even)>td:nth-child(1){background:#f9fbfd!important}
  #view-students .ux-responsive-table td:nth-child(1) input,
  #view-students .ux-responsive-table th:nth-child(1) input{
    width:22px!important;height:22px!important;margin:0!important;accent-color:#176f91!important
  }

  #view-students .ux-responsive-table th:nth-child(2),
  #view-students .ux-responsive-table td:nth-child(2){
    position:sticky!important;
    right:48px!important;
    left:auto!important;
    width:205px!important;
    min-width:205px!important;
    max-width:205px!important;
    z-index:26!important;
    background:#fff!important;
    box-shadow:-7px 0 12px -12px rgba(20,45,70,.55)!important;
  }
  #view-students .ux-responsive-table th:nth-child(2){z-index:41!important;background:#eef3f8!important}
  #view-students .ux-responsive-table tbody tr:nth-child(even)>td:nth-child(2){background:#f9fbfd!important}

  /* Compact identity: name may use two lines, initiative sits below it. */
  #view-students .student-primary-cell{padding:7px 9px!important}
  #view-students .student-primary-cell .student-name-with-signals{
    display:flex!important;align-items:flex-start!important;gap:4px!important;min-width:0!important
  }
  #view-students .student-primary-cell .student-name-with-signals>b{
    display:-webkit-box!important;
    -webkit-box-orient:vertical!important;
    -webkit-line-clamp:2!important;
    overflow:hidden!important;
    white-space:normal!important;
    max-width:168px!important;
    font-size:13.5px!important;
    line-height:1.35!important;
    font-weight:900!important;
    color:#173653!important;
  }
  #view-students .student-row-meta{display:flex!important;align-items:center!important;gap:4px!important;margin-top:4px!important;min-height:17px!important}
  #view-students .student-primary-cell .initiative-pill{
    display:inline-flex!important;align-items:center!important;
    max-width:176px!important;overflow:hidden!important;text-overflow:ellipsis!important;white-space:nowrap!important;
    padding:2px 6px!important;border-radius:999px!important;font-size:9.5px!important;line-height:1.25!important
  }

  /* Sliding detail widths. */
  #view-students .ux-responsive-table th:nth-child(3),#view-students .ux-responsive-table td:nth-child(3){width:94px!important}
  #view-students .ux-responsive-table th:nth-child(4),#view-students .ux-responsive-table td:nth-child(4){width:122px!important}
  #view-students .ux-responsive-table th:nth-child(5),#view-students .ux-responsive-table td:nth-child(5){width:118px!important}
  #view-students .ux-responsive-table th:nth-child(6),#view-students .ux-responsive-table td:nth-child(6){width:112px!important}
  #view-students .ux-responsive-table th:nth-child(7),#view-students .ux-responsive-table td:nth-child(7){width:100px!important}
  #view-students .ux-responsive-table th:nth-child(8),#view-students .ux-responsive-table td:nth-child(8){width:88px!important;text-align:center!important}
  #view-students .ux-responsive-table th:nth-child(9),#view-students .ux-responsive-table td:nth-child(9){width:142px!important}
  #view-students .student-grade-cell b{font-size:12.5px!important;color:#24445f!important;white-space:normal!important}
  #view-students .status-note{display:block!important;margin-top:2px!important;font-size:9.5px!important;color:#718095!important}
  #view-students .row-actions{display:flex!important;flex-wrap:nowrap!important;gap:5px!important;justify-content:flex-start!important}
  #view-students .row-actions .mini{min-height:34px!important;padding:6px 9px!important;font-size:11px!important;white-space:nowrap!important}
  #view-students .wa-link{min-height:34px!important;padding:6px 8px!important;font-size:11px!important;white-space:nowrap!important}

  /* Remove old fixed-grade behavior and old hint. */
  #view-students:after{content:'اسم الطالب ثابت — اسحب يمينًا ويسارًا لبقية البيانات والإجراءات'!important}
}

@media(max-width:430px){
  #view-students .ux-responsive-table{min-width:900px!important}
  #view-students .ux-responsive-table th:nth-child(2),
  #view-students .ux-responsive-table td:nth-child(2){width:188px!important;min-width:188px!important;max-width:188px!important}
  #view-students .student-primary-cell .student-name-with-signals>b{max-width:152px!important;font-size:13px!important}
  #view-students .student-primary-cell .initiative-pill{max-width:158px!important}
}

@media(max-width:760px){
  /* Explicitly release the grade and every later body cell from V3.0.10's old sticky zone. */
  #view-students #studentsTable tr>td:nth-child(n+3){
    position:relative!important;
    right:auto!important;
    left:auto!important;
    margin:0!important;
    border-radius:0!important;
    padding:9px 8px!important;
    background:inherit!important;
    z-index:auto!important;
  }
  #view-students table thead th:nth-child(n+3){right:auto!important;left:auto!important}

  /* Re-assert the two intended sticky body columns after releasing the rest. */
  #view-students #studentsTable tr>td:nth-child(1){
    position:sticky!important;right:0!important;left:auto!important;z-index:27!important;
    width:48px!important;min-width:48px!important;max-width:48px!important;
    padding:9px 8px!important;margin:0!important;border-radius:0!important;background:#fff!important
  }
  #view-students #studentsTable tr>td:nth-child(2){
    position:sticky!important;right:48px!important;left:auto!important;z-index:26!important;
    width:205px!important;min-width:205px!important;max-width:205px!important;
    padding:7px 9px!important;margin:0!important;border-radius:0!important;background:#fff!important
  }
  #view-students #studentsTable tr:nth-child(even)>td:nth-child(1),
  #view-students #studentsTable tr:nth-child(even)>td:nth-child(2){background:#f9fbfd!important}
}

@media(max-width:430px){
  #view-students #studentsTable tr>td:nth-child(2){width:188px!important;min-width:188px!important;max-width:188px!important}
}
