/* ============================================================
   SPACING AND VISUAL HIERARCHY FIXES v2
   Professional spacing with proper breathing room
   ============================================================ */

/* == CARD SPACING IMPROVEMENTS == */
.student-card {
  padding: 1.8rem 1.6rem !important;
  min-height: 240px;
  display: flex;
  flex-direction: column;
}

.student-card-head {
  margin-bottom: 1.3rem !important;
  gap: 1.2rem !important;
}

.student-card-name {
  font-size: 0.98rem !important;
  margin-bottom: 0.35rem !important;
  line-height: 1.3;
}

.student-card-pos {
  font-size: 0.78rem !important;
  line-height: 1.4;
}

.student-overall {
  font-size: 2.3rem !important;
  margin-bottom: 0.8rem !important;
  line-height: 1;
}

.student-card-footer {
  margin-top: auto !important;
  gap: 0.65rem !important;
  display: flex;
  flex-wrap: wrap;
}

.student-card-footer .btn {
  flex: 1;
  min-width: 35px;
}

.students-grid {
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)) !important;
  gap: 2rem !important;
  padding: 0.5rem 0;
}

/* == STAT CARDS IMPROVEMENTS == */
.stats-grid {
  gap: 1.8rem !important;
  margin-bottom: 2.5rem !important;
}

.stat-card {
  padding: 1.8rem 1.6rem !important;
  min-height: 200px;
}

.stat-card-icon {
  margin-bottom: 1rem !important;
  font-size: 1.4rem !important;
}

.stat-card-label {
  margin-bottom: 0.6rem !important;
  font-size: 0.75rem !important;
  letter-spacing: 0.7px !important;
}

.stat-card-value {
  font-size: clamp(1.8rem, 5vw, 2.3rem) !important;
  margin-bottom: 0.5rem !important;
  line-height: 1.2;
}

.stat-card-sub {
  font-size: 0.75rem !important;
  line-height: 1.5;
}

/* == TABLE IMPROVEMENTS == */
.table-wrapper {
  overflow: hidden;
}

.table-toolbar {
  padding: 1.3rem 1.8rem !important;
  gap: 1rem !important;
}

.table-toolbar-search {
  min-width: 200px;
}

.table-toolbar-search input {
  min-height: 40px !important;
  font-size: 0.9rem !important;
  padding: 0.65rem 1.1rem 0.65rem 2.6rem !important;
}

.grade-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.grade-table thead {
  background: linear-gradient(135deg, #f9fafd 0%, #f6f7fb 100%);
  border-bottom: 2px solid #e3e6f0;
}

.grade-table th {
  padding: 1.1rem 1rem !important;
  font-size: 0.76rem !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #3774a7;
  background: #f9fafd;
  height: 52px;
}

.grade-table td {
  padding: 1rem 1rem !important;
  font-size: 0.92rem !important;
  border-bottom: 1px solid #e3e6f0;
  vertical-align: middle;
  min-height: 48px;
  display: table-cell;
  height: 48px;
}

.grade-table tbody tr {
  transition: background-color 0.15s ease;
}

.grade-table tbody tr:hover td {
  background: #f6f9ff;
}

.grade-table tbody tr.selected td {
  background: #eef1fd;
}

/* Score values prominent */
.score-val,
.grade-val,
.total-val,
.position-val,
.remark-val {
  font-weight: 700;
  font-size: 0.96rem !important;
  color: #0d0f14;
  display: block;
  line-height: 1.4;
}

.score-val {
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.5px;
}

.score-input {
  width: 70px !important;
  padding: 0.5rem 0.6rem !important;
  font-size: 0.9rem !important;
  min-height: 40px;
  text-align: center;
  font-weight: 600;
  border: 2px solid #e3e6f0;
}

.score-input:focus {
  outline: none;
  border-color: #4361ee;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.student-name-cell {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-height: 48px;
  padding: 1rem 1rem !important;
}

.student-mini-avatar {
  width: 36px !important;
  height: 36px;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.student-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: #0d0f14;
  line-height: 1.3;
}

/* == PAGE HEADER SPACING == */
.page-header {
  margin-bottom: 2.5rem !important;
  gap: 1.2rem !important;
  align-items: flex-start;
}

.page-header-title {
  font-size: clamp(1.5rem, 4vw, 1.95rem) !important;
  line-height: 1.3;
  margin-bottom: 0;
}

.page-header-actions {
  gap: 0.8rem !important;
  margin-left: auto;
  margin-top: 0;
}

.page-header-actions .btn {
  min-height: 40px;
  font-size: 0.85rem;
  padding: 0.6rem 1.1rem;
}

/* == SUBJECT TABS SPACING == */
.subject-tabs {
  margin-bottom: 2rem !important;
  gap: 0.7rem !important;
}

.subject-tab {
  padding: 0.55rem 1.3rem !important;
  font-size: 0.86rem !important;
  min-height: 38px;
  display: flex;
  align-items: center;
}

/* == SECTION SPACING == */
.page-section {
  margin-bottom: 2.5rem;
}

.analytics-grid {
  gap: 2rem !important;
  margin-top: 2rem;
}

.analytics-card {
  padding: 2rem 1.8rem !important;
  min-height: 350px;
}

.analytics-card h3 {
  margin-bottom: 1.5rem !important;
  font-size: 1.1rem !important;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

/* == BATCH BAR SPACING == */
.batch-bar {
  padding: 1.2rem 1.8rem !important;
  gap: 1rem !important;
  margin-top: 1.5rem;
  background: linear-gradient(
    135deg,
    rgba(67, 97, 238, 0.1),
    rgba(114, 9, 183, 0.08)
  );
  border-radius: 0.5rem;
}

.batch-bar span {
  font-size: 0.9rem !important;
  font-weight: 700;
}

.batch-bar .btn {
  min-height: 40px;
  font-size: 0.85rem;
}

/* == FORM SECTION SPACING == */
.settings-section {
  padding: 2.2rem !important;
  margin-bottom: 2.5rem !important;
}

.settings-row {
  padding: 1.2rem 0 !important;
  gap: 1.5rem !important;
  min-height: 50px;
}

.settings-row:last-child {
  border-bottom: none;
}

/* == BADGE ENHANCEMENT == */
.badge {
  padding: 0.5rem 1rem !important;
  font-size: 0.8rem !important;
  font-weight: 700;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
}

.badge-pill {
  border-radius: 9999px;
}

/* == CARD ACTION BUTTONS == */
.student-card-footer .btn-sm,
.card-actions .btn-sm {
  padding: 0.5rem 0.8rem !important;
  font-size: 0.75rem !important;
  min-height: 34px;
}

.student-card-footer button,
.card-actions button {
  white-space: normal;
  overflow-wrap: break-word;
}

/* == MODAL SPACING == */
.modal-box {
  padding: 2rem !important;
}

.modal-header {
  margin-bottom: 1.8rem !important;
  padding-bottom: 1.2rem !important;
  border-bottom: 2px solid #e3e6f0;
}

.modal-header h2 {
  font-size: 1.4rem !important;
  line-height: 1.3;
}

.modal-body {
  font-size: 0.95rem;
  line-height: 1.6;
}

.modal-body label {
  display: block;
  margin-bottom: 0.6rem !important;
  font-weight: 600;
  font-size: 0.9rem;
}

.modal-body input,
.modal-body select,
.modal-body textarea {
  margin-bottom: 1.2rem !important;
  min-height: 42px;
  font-size: 0.95rem;
}

/* == RESPONSIVE SPACING ADJUSTMENTS == */
@media (max-width: 768px) {
  .students-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
    gap: 1.5rem !important;
  }

  .student-card {
    padding: 1.5rem 1.3rem !important;
  }

  .stat-card {
    padding: 1.5rem 1.3rem !important;
  }

  .stats-grid {
    gap: 1.3rem !important;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 2rem !important;
  }

  .page-header-actions {
    width: 100%;
    margin-left: 0;
  }

  .grade-table th {
    padding: 0.85rem 0.8rem !important;
    font-size: 0.72rem !important;
    height: 45px;
  }

  .grade-table td {
    padding: 0.8rem 0.8rem !important;
    font-size: 0.85rem !important;
    height: 45px;
  }

  .score-input {
    width: 60px !important;
    padding: 0.4rem 0.5rem !important;
  }
}

@media (max-width: 480px) {
  .students-grid {
    grid-template-columns: 1fr !important;
    gap: 1.2rem !important;
  }

  .student-card {
    padding: 1.3rem 1.1rem !important;
  }

  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    margin-bottom: 1.8rem !important;
  }

  .stat-card {
    padding: 1.2rem 1rem !important;
    min-height: 150px;
  }

  .stat-card-value {
    font-size: clamp(1.4rem, 3.5vw, 1.8rem) !important;
  }

  .grade-table th {
    padding: 0.65rem 0.5rem !important;
    font-size: 0.65rem !important;
    height: 40px;
  }

  .grade-table td {
    padding: 0.65rem 0.5rem !important;
    font-size: 0.8rem !important;
    height: 40px;
  }

  .score-input {
    width: 52px !important;
  }

  .page-header {
    margin-bottom: 1.5rem !important;
  }

  .student-card-footer {
    gap: 0.4rem !important;
  }

  .batch-bar {
    flex-direction: column;
    padding: 1rem 1.2rem !important;
  }
}

/* == DARK MODE IMPROVEMENTS == */
@media (prefers-color-scheme: dark) {
  .grade-table thead {
    background: linear-gradient(135deg, #1c2240 0%, #161b2e 100%);
    border-bottom-color: #2a2f45;
  }

  .grade-table th {
    background: #1c2240;
    color: #a8aed0;
  }

  .grade-table td {
    border-bottom-color: #2a2f45;
  }

  .grade-table tbody tr:hover td {
    background: rgba(67, 97, 238, 0.08);
  }

  .batch-bar {
    background: linear-gradient(
      135deg,
      rgba(67, 97, 238, 0.15),
      rgba(114, 9, 183, 0.12)
    );
    border: 1px solid rgba(67, 97, 238, 0.2);
  }
}

/* == PRINT OPTIMIZATION == */
@media print {
  .grade-table th,
  .grade-table td {
    padding: 0.8rem 0.7rem;
    page-break-inside: avoid;
  }

  .student-card {
    page-break-inside: avoid;
    box-shadow: none;
  }
}
