/* ========================================================
   HỆ THỐNG TRA CỨU THÔNG TIN CTXH-STU
   Modern, Ultra-Responsive & Print-Optimized Stylesheet
   ======================================================== */

:root {
  --primary: #0f3b82;
  /* STU University Blue */
  --primary-hover: #0a2960;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;

  --accent: #059669;
  /* Success Emerald */
  --accent-hover: #047857;
  --accent-light: #ecfdf5;
  --accent-border: #a7f3d0;

  --text-main: #0f172a;
  /* Slate 900 */
  --text-body: #334155;
  /* Slate 700 */
  --text-muted: #64748b;
  /* Slate 500 */

  --bg-page: #f1f5f9;
  /* Soft Slate Gray */
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;

  --danger: #b91c1c;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 8px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.03);

  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
}

/* Base reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-page);
  color: var(--text-body);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 32px 16px 24px;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

/* ========================================================
   Header
   ======================================================== */
.app-header {
  text-align: center;
  margin-bottom: 28px;
  position: relative;
}

.header-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.admin-nav-pill {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  padding: 6px 14px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.admin-nav-pill:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}

.app-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  box-shadow: 0 2px 6px rgba(15, 59, 130, 0.25);
  margin-bottom: 10px;
}

.app-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  line-height: 1.25;
}

.app-subtitle {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 650px;
  margin: 0 auto;
}

/* ========================================================
   Cards
   ======================================================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 28px;
  margin-bottom: 24px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  border-color: var(--border-hover);
}

/* ========================================================
   Search Form
   ======================================================== */
.search-form {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.year-select {
  flex: 0 0 200px;
}

.form-group.mssv-input {
  flex: 1 1 260px;
}

.form-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-control {
  height: 48px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  font-size: 15px;
  background-color: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 59, 130, 0.15);
}

.btn-search {
  height: 48px;
  padding: 0 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #1e40af);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(15, 59, 130, 0.2);
}

.btn-search:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-search:active {
  transform: translateY(0);
}

.btn-search:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* Quick samples */
.quick-samples {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sample-chip {
  color: var(--primary);
  text-decoration: none;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.sample-chip:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}

.sample-chip.chip-muted {
  color: var(--text-muted);
  background: #f1f5f9;
  border-color: #e2e8f0;
}

/* ========================================================
   Student Profile Header Card
   ======================================================== */
.student-profile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  padding-bottom: 24px;
  border-bottom: 1.5px dashed var(--border-color);
  margin-bottom: 22px;
}

.profile-main {
  display: flex;
  align-items: center;
  gap: 18px;
}

.avatar-badge {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: #ffffff;
  font-size: 24px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(15, 59, 130, 0.25);
  flex-shrink: 0;
}

.profile-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.meta-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  display: inline-flex;
  align-items: center;
}

.tag-primary {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-border);
}

.summary-box {
  background: var(--accent-light);
  border: 1.5px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 14px 24px;
  text-align: center;
  min-width: 160px;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.08);
}

.summary-title {
  font-size: 12px;
  font-weight: 700;
  color: #065f46;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-value {
  font-size: 32px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1.1;
  margin: 2px 0;
}

.summary-unit {
  font-size: 13px;
  font-weight: 600;
  color: #047857;
}

/* ========================================================
   Activity Table
   ======================================================== */
.table-header-bar {
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.table-heading {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.btn-print {
  background: #ffffff;
  border: 1.5px solid var(--primary-border);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-print:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: #ffffff;
  -webkit-overflow-scrolling: touch;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.activity-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 14px 16px;
  border-bottom: 1.5px solid var(--border-color);
  white-space: nowrap;
}

.activity-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: top;
}

.activity-table tr:hover td {
  background: #f8fafc;
}

.col-stt {
  width: 48px;
  text-align: center;
  font-weight: 600;
  color: var(--text-muted);
}

.col-time {
  width: 160px;
  font-size: 13px;
  color: var(--text-body);
}

.col-days {
  width: 130px;
  text-align: right;
  white-space: nowrap;
}

.badge-days {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  font-weight: 800;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 8px;
}

.table-total-row {
  background: #f8fafc;
  font-weight: 800;
}

.table-total-row td {
  padding: 16px;
  border-top: 2px solid var(--border-color);
  border-bottom: none;
}

.total-label {
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-main);
  font-size: 14px;
}

.total-value {
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
}

/* ========================================================
   Alert / Not Found Box
   ======================================================== */
.alert-box {
  padding: 22px;
  border-radius: var(--radius);
  margin-top: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  border: 1.5px solid var(--danger-border);
  background: var(--danger-light);
  color: var(--danger);
}

.alert-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.alert-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 6px;
  color: #991b1b;
}

.alert-desc {
  font-size: 14px;
  color: #7f1d1d;
  line-height: 1.6;
}

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-bottom-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: rotation 0.8s linear infinite;
}

@keyframes rotation {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* ========================================================
   Footer
   ======================================================== */
.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: auto;
  padding-top: 36px;
  line-height: 1.7;
}

.footer-source {
  margin-top: 6px;
  font-size: 12px;
  color: #64748b;
}

.footer-source a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.footer-source a:hover {
  text-decoration: underline;
}

/* Print Header & Footer (Hidden on screen) */
.print-only {
  display: none;
}

/* ========================================================
   RESPONSIVE DESIGN (Desktop, Tablet, Mobile)
   ======================================================== */

/* Tablet & Mobile (<= 860px) */
@media screen and (max-width: 860px) {
  body {
    padding: 20px 12px;
  }

  .card {
    padding: 20px;
  }

  .app-title {
    font-size: 24px;
  }

  .student-profile {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-box {
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .summary-value {
    font-size: 28px;
  }
}

/* Mobile (<= 640px) */
@media screen and (max-width: 640px) {
  body {
    padding: 14px 8px;
  }

  .card {
    padding: 16px;
    border-radius: var(--radius);
  }

  .app-header {
    margin-bottom: 20px;
  }

  .app-title {
    font-size: 21px;
  }

  .app-subtitle {
    font-size: 13px;
  }

  .search-form {
    flex-direction: column;
    gap: 12px;
  }

  .form-group.year-select,
  .form-group.mssv-input {
    flex: 1 1 100%;
    width: 100%;
  }

  .btn-search {
    width: 100%;
  }

  .profile-main {
    gap: 12px;
  }

  .avatar-badge {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .profile-name {
    font-size: 18px;
  }

  .activity-table th,
  .activity-table td {
    padding: 10px 12px;
    font-size: 13px;
  }

  .col-time {
    width: 120px;
  }

  .col-days {
    width: 90px;
  }

  .table-total-row td {
    padding: 12px;
    font-size: 13px;
  }

  .total-value {
    font-size: 16px;
  }
}

/* ========================================================
   PRINT VIEW OPTIMIZATION (@media print)
   Chỉ in bảng kết quả sinh viên và danh sách CTXH
   ======================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 1.5cm 1.2cm;
  }

  body {
    background: #ffffff;
    color: #000000;
    padding: 0;
    font-size: 12pt;
    line-height: 1.4;
  }

  /* Ẩn toàn bộ phần không liên quan */
  .app-header,
  .search-card,
  .quick-samples,
  .app-footer,
  .btn-print,
  .admin-nav-pill,
  .no-print {
    display: none;
  }

  .container {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .card {
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
  }

  /* Hiện tiêu đề in chính thức */
  .print-only {
    display: block;
  }

  .print-official-header {
    text-align: center;
    border-bottom: 2px solid #000;
    padding-bottom: 12px;
    margin-bottom: 20px;
  }

  .print-school {
    font-size: 13pt;
    font-weight: 700;
    text-transform: uppercase;
  }

  .print-dept {
    font-size: 11pt;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
  }

  .print-title {
    font-size: 16pt;
    font-weight: 800;
    text-transform: uppercase;
    margin-top: 10px;
    color: #000;
  }

  .print-meta {
    font-size: 9.5pt;
    font-style: italic;
    color: #555;
    margin-top: 4px;
  }

  /* Hồ sơ sinh viên khi in */
  .student-profile {
    border: 1px solid #333;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 18px;
    background: #fafafa;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .avatar-badge {
    display: none;
  }

  .profile-name {
    font-size: 14pt;
    color: #000;
  }

  .tag {
    border: 1px solid #666;
    color: #000;
    background: #fff;
    font-size: 10pt;
  }

  .summary-box {
    border: 2px solid #000;
    background: #ffffff;
    padding: 8px 16px;
  }

  .summary-title {
    color: #000;
  }

  .summary-value {
    color: #000;
    font-size: 22pt;
  }

  .summary-unit {
    color: #333;
  }

  /* Bảng in */
  .table-responsive {
    border: none;
    overflow: visible;
  }

  .activity-table {
    border: 1px solid #000;
    width: 100%;
    page-break-inside: auto;
  }

  .activity-table th,
  .activity-table td {
    border: 1px solid #444;
    padding: 7px 10px;
    color: #000;
    font-size: 10pt;
  }

  .activity-table th {
    background: #eeeeee;
    font-weight: 700;
  }

  .activity-table tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .badge-days {
    background: transparent;
    border: none;
    color: #000;
    font-weight: 700;
    padding: 0;
  }

  .table-total-row {
    background: #f0f0f0;
  }

  .table-total-row td {
    border-top: 2px solid #000;
  }

  .total-value {
    color: #000;
    font-size: 13pt;
  }

  /* Chữ ký xác nhận khi in */
  .print-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 36px;
    padding-top: 10px;
    font-size: 10pt;
    text-align: center;
    page-break-inside: avoid;
  }

  .sign-col {
    width: 45%;
  }

  .sign-title {
    font-weight: 700;
    margin-bottom: 60px;
  }
}

/* Thông báo tham khảo */
.disclaimer-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 14px auto 0;
  padding: 8px 13px;
  border: 1px solid #f1d39a;
  border-radius: 999px;
  background: #fff8e8;
  color: #78551b;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
}

.disclaimer-footer {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  padding: 15px 16px;
  border: 1px solid #d9e2ec;
  border-radius: 10px;
  background: #f7f9fc;
  color: #344256;
  font-size: 13px;
  line-height: 1.7;
  text-align: left;
}

.disclaimer-footer p {
  margin: 0;
}

.disclaimer-footer strong {
  display: block;
  margin-bottom: 4px;
  color: #243247;
}

.print-disclaimer {
  display: none;
}

@media (max-width: 600px) {
  .disclaimer-badge {
    max-width: 100%;
    border-radius: 10px;
  }

  .disclaimer-footer {
    padding: 12px;
  }
}

/* Khi in, chỉ hiển thị kết quả tra cứu và lưu ý đi kèm */
@media print {
  body * {
    visibility: hidden;
  }

  #resultContainer,
  #resultContainer *,
  .print-disclaimer,
  .print-disclaimer * {
    visibility: visible;
  }

  #resultContainer {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }

  .print-disclaimer {
    display: block;
    position: relative;
    visibility: visible;
    margin-top: 14px;
    padding-top: 8px;
    border-top: 1px solid #999;
    color: #444;
    font-size: 10pt;
    font-style: italic;
    line-height: 1.5;
  }

  .print-disclaimer * {
    visibility: visible;
  }
}