/*
 * COUNSIVA v3.7.9 — operational list density standard.
 * Scope: Students, Leads, Visitors, Follow-ups, Counselling, Classes,
 * Applications and Visa & Success. Dashboard/Reports keep their own layout.
 */

/* Shared compact rhythm for operational views. */
#view-students .panel-body,
#view-leads .panel-body,
#view-visitors .panel-body,
#view-followups .panel-body,
#view-counselling .panel-body,
#view-classes .panel-body,
#view-applications .panel-body,
#view-visa .panel-body {
  padding: 14px 16px;
}

#view-students .filters,
#view-leads .filters,
#view-visitors .filters,
#view-followups .filters,
#view-counselling .filters,
#view-classes .filters,
#view-applications .filters,
#view-visa .filters {
  margin-bottom: 12px;
}

#view-students .field label,
#view-leads .field label,
#view-visitors .field label,
#view-followups .field label,
#view-counselling .field label,
#view-classes .field label,
#view-applications .field label,
#view-visa .field label {
  margin-bottom: 5px;
}

#view-students .field input,
#view-students .field select,
#view-leads .field input,
#view-leads .field select,
#view-visitors .field input,
#view-visitors .field select,
#view-followups .field input,
#view-followups .field select,
#view-counselling .field input,
#view-counselling .field select,
#view-classes .field input,
#view-classes .field select,
#view-applications .field input,
#view-applications .field select,
#view-visa .field input,
#view-visa .field select {
  min-height: 38px;
  padding: 8px 10px;
}

/* Students: one dense row, including Open + Ask AI in one action rail. */
#studentList .student-row {
  grid-template-columns:
    38px
    minmax(250px, 1.65fr)
    minmax(72px, .55fr)
    minmax(155px, .95fr)
    minmax(120px, .75fr)
    minmax(150px, .9fr);
  gap: 10px;
  min-height: 76px;
  padding: 9px 12px;
  align-items: center;
}

#studentList .student-row h4 {
  margin: 0 0 2px;
  font-size: 14px;
  line-height: 1.2;
}

#studentList .student-row small {
  line-height: 1.25;
}

#studentList .list-date {
  margin-top: 2px;
}

#studentList .student-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(64px, 1fr));
  gap: 5px;
  align-items: center;
  min-width: 145px;
}

#studentList .student-actions .btn {
  width: 100%;
  min-height: 30px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.1;
  white-space: nowrap;
}

#studentList .cai-context-action {
  margin: 0 !important;
  width: 100% !important;
}

/* Leads / Visitors / Follow-ups / Counselling: consistent compact workflow cards. */
#leadList .workflow-row,
#visitorList .workflow-row,
#followupList .workflow-row,
#counsellingList .workflow-row {
  grid-template-columns:
    38px
    minmax(250px, 1.2fr)
    minmax(220px, .9fr)
    minmax(300px, 1.25fr);
  gap: 10px;
  min-height: 72px;
  padding: 9px 12px;
  align-items: center;
}

#leadList .workflow-row h4,
#visitorList .workflow-row h4,
#followupList .workflow-row h4,
#counsellingList .workflow-row h4 {
  margin: 0 0 2px;
  font-size: 14px;
  line-height: 1.2;
}

#leadList .workflow-row > .actions,
#visitorList .workflow-row > .actions,
#followupList .workflow-row > .actions,
#counsellingList .workflow-row > .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  justify-content: flex-start;
}

#leadList .workflow-row .btn,
#visitorList .workflow-row .btn,
#followupList .workflow-row .btn,
#counsellingList .workflow-row .btn {
  min-height: 30px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.1;
}

/* Shared dense table treatment for Classes / Applications / Visa. */
#view-classes .data-table th,
#view-applications .data-table th,
#view-visa .data-table th {
  padding: 8px 9px;
  font-size: 10px;
  line-height: 1.2;
}

#view-classes .data-table td,
#view-applications .data-table td,
#view-visa .data-table td {
  padding: 8px 9px;
  font-size: 12px;
  line-height: 1.28;
  vertical-align: top;
}

#view-classes .data-table td small,
#view-applications .data-table td small,
#view-visa .data-table td small {
  line-height: 1.25;
}

#view-classes .badge,
#view-applications .badge,
#view-visa .badge {
  padding: 3px 7px;
  font-size: 10px;
}

/* Applications: fit six actions in two compact rows instead of a tall stack. */
#view-applications .data-table {
  min-width: 1280px;
}

#view-applications .data-table th:last-child,
#view-applications .data-table td:last-child {
  min-width: 238px;
  width: 238px;
}

#view-applications .application-actions,
#view-applications #appBody .actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(66px, 1fr));
  gap: 5px;
  align-items: center;
  min-width: 220px;
}

#view-applications .application-actions .btn,
#view-applications #appBody .actions .btn,
#view-applications #appBody td:last-child > .btn {
  min-height: 29px;
  padding: 6px 7px;
  font-size: 10.5px;
  line-height: 1.1;
  white-space: nowrap;
}

#view-applications .application-actions .return-processing,
#view-applications #appBody .actions .return-processing {
  grid-column: 1 / -1;
}

#view-applications #appBody .cai-context-action {
  margin: 0 !important;
  width: 100% !important;
}

#view-applications .mono-id,
#view-applications .application-cell,
#view-applications #appBody td:nth-child(5) {
  overflow-wrap: normal;
  word-break: keep-all;
}

/* Visa & Success: compact outcome/action area and remove unnecessary height. */
#view-visa .data-table {
  min-width: 1080px;
}

#view-visa #visaBody td:last-child {
  min-width: 185px;
}

#view-visa #visaBody .actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(76px, 1fr));
  gap: 5px;
  align-items: center;
}

#view-visa #visaBody .actions .btn,
#view-visa #visaBody td:last-child > .btn {
  min-height: 29px;
  padding: 6px 8px;
  font-size: 10.5px;
  line-height: 1.1;
  margin: 2px;
  white-space: nowrap;
}

#view-visa #visaBody .return-processing {
  grid-column: 1 / -1;
}

#view-visa #visaBody td:nth-child(4) {
  white-space: nowrap;
}

/* Classes: retain all operational information but make action cells dense. */
#view-classes .data-table {
  min-width: 1420px;
}

#view-classes #classBody .actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(68px, 1fr));
  gap: 4px;
  min-width: 145px;
}

#view-classes #classBody .actions .btn {
  min-height: 28px;
  padding: 5px 7px;
  font-size: 10.5px;
  line-height: 1.1;
  white-space: nowrap;
}

#view-classes #classBatchBody td {
  padding-top: 7px;
  padding-bottom: 7px;
}

/* Consistent row hover without changing record semantics. */
#studentList .student-row:hover,
#leadList .workflow-row:hover,
#visitorList .workflow-row:hover,
#followupList .workflow-row:hover,
#counsellingList .workflow-row:hover {
  background: #f9fcfd;
}

/* Tablet: keep information readable and allow horizontal table scroll. */
@media (max-width: 1180px) {
  #studentList .student-row {
    grid-template-columns: 36px minmax(230px, 1.5fr) 80px minmax(145px, 1fr) 120px 145px;
  }

  #leadList .workflow-row,
  #visitorList .workflow-row,
  #followupList .workflow-row,
  #counsellingList .workflow-row {
    grid-template-columns: 36px minmax(230px, 1fr) minmax(190px, .8fr) minmax(260px, 1fr);
  }
}

/* Mobile: cards stack intentionally; desktop density rules must not squeeze fields. */
@media (max-width: 760px) {
  #studentList .student-row,
  #leadList .workflow-row,
  #visitorList .workflow-row,
  #followupList .workflow-row,
  #counsellingList .workflow-row {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 7px 10px;
    align-items: start;
  }

  #studentList .student-row > :not(.row-number),
  #leadList .workflow-row > :not(.row-number),
  #visitorList .workflow-row > :not(.row-number),
  #followupList .workflow-row > :not(.row-number),
  #counsellingList .workflow-row > :not(.row-number) {
    grid-column: 2;
  }

  #studentList .student-actions {
    width: 100%;
    max-width: 280px;
  }

  #leadList .workflow-row > .actions,
  #visitorList .workflow-row > .actions,
  #followupList .workflow-row > .actions,
  #counsellingList .workflow-row > .actions {
    width: 100%;
  }
}
