/* ============================================================
   RMS – Result Management System  v3
   Google-inspired: heavy white, minimal colour, beautiful.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&family=Roboto:wght@300;400;500&display=swap');

/* ── Variables ── */
:root {
  --blue:         #1a73e8;
  --blue-dark:    #1557b0;
  --blue-light:   #e8f0fe;
  --blue-50:      #f0f4ff;
  --red:          #ea4335;
  --red-light:    #fce8e6;
  --green:        #34a853;
  --green-light:  #e6f4ea;
  --yellow:       #fbbc04;
  --yellow-light: #fef7e0;
  --grey-50:      #f8f9fa;
  --grey-100:     #f1f3f4;
  --grey-200:     #e8eaed;
  --grey-300:     #dadce0;
  --grey-500:     #9aa0a6;
  --grey-700:     #5f6368;
  --grey-900:     #202124;
  --white:        #ffffff;
  --shadow-card:  0 1px 3px rgba(60,64,67,.12), 0 2px 8px rgba(60,64,67,.06);
  --shadow-2:     0 2px 6px rgba(60,64,67,.3),  0 1px 4px rgba(60,64,67,.15);
  --radius-sm:    6px;
  --radius-md:    8px;
  --radius-lg:    12px;
  --radius-xl:    16px;
  --transition:   all .2s cubic-bezier(.4,0,.2,1);
  --navbar-h:     60px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Roboto', 'Google Sans', sans-serif;
  background: var(--grey-50);
  color: var(--grey-900);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
h1,h2,h3,h4,h5,h6 { font-family: 'Google Sans', sans-serif; font-weight: 500; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Loading overlay ── */
#rmsLoadingOverlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.92);
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  backdrop-filter: blur(2px);
}
#rmsLoadingOverlay.active { display: flex; }
.rms-spinner-large {
  width: 52px; height: 52px;
  border: 4px solid var(--grey-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
#rmsLoadingMsg {
  font-family: 'Google Sans', sans-serif;
  font-size: 15px; color: var(--grey-700);
  text-align: center;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Navbar ── */
.rms-navbar {
  background: var(--white);
  border-bottom: 1px solid var(--grey-200);
  height: var(--navbar-h);
  padding: 0 16px;
  display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 200;
  box-shadow: 0 1px 4px rgba(60,64,67,.08);
}
.rms-navbar .brand {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Google Sans', sans-serif;
  font-size: 20px; font-weight: 700;
  color: var(--grey-900); text-decoration: none;
  white-space: nowrap; flex-shrink: 0;
}
.logo-dots { display: flex; gap: 3px; flex-wrap: wrap; width: 20px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-b { background: var(--blue); }
.dot-r { background: var(--red); }
.dot-y { background: var(--yellow); }
.dot-g { background: var(--green); }
.nav-school, .nav-term {
  font-size: 12px; color: var(--grey-700);
  background: var(--grey-100); padding: 5px 12px;
  border-radius: 20px; white-space: nowrap;
}
.nav-school { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.nav-spacer { flex: 1; }
.nav-user {
  font-family: 'Google Sans', sans-serif; font-size: 13px;
  font-weight: 500; color: var(--grey-700); white-space: nowrap;
}
.btn-logout {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--grey-700);
  padding: 7px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--grey-300); background: var(--white);
  cursor: pointer; transition: var(--transition);
  font-family: 'Google Sans', sans-serif; font-weight: 500;
  text-decoration: none; white-space: nowrap; flex-shrink: 0;
}
.btn-logout:hover { background: var(--grey-100); color: var(--grey-900); text-decoration: none; }

/* ── Responsive navbar ── */
@media (max-width: 640px) {
  .nav-school, .nav-term, .nav-user { display: none; }
  .logout-label { display: none; }
  .btn-logout { padding: 8px 10px; }
  .rms-navbar { padding: 0 10px; gap: 6px; }
  .rms-navbar .brand { font-size: 17px; }
}

/* ── Page Layout ── */
.rms-container { max-width: 1320px; margin: 0 auto; padding: 18px 14px; }
.page-header { margin-bottom: 18px; }
.page-header h1 { font-size: 22px; font-weight: 500; }
.page-header .subtitle { font-size: 13px; color: var(--grey-700); margin-top: 4px; }

/* ── Cards ── */
.rms-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--grey-200);
  overflow: hidden;
}
.rms-card .card-header {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--grey-200);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.rms-card .card-header h5 { font-size: 14px; font-weight: 500; margin: 0; }
.rms-card .card-body { padding: 18px; }

/* ── Tabs ── */
.rms-tabs {
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--grey-200); border-bottom: none;
}
.rms-tabs .nav-tabs {
  border-bottom: 2px solid var(--grey-200);
  padding: 0 12px;
  display: flex; gap: 2px;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.rms-tabs .nav-tabs::-webkit-scrollbar { display: none; }
.rms-tabs .nav-tabs .nav-link {
  font-family: 'Google Sans', sans-serif; font-size: 13px; font-weight: 500;
  color: var(--grey-700); border: none;
  padding: 13px 13px 11px; border-bottom: 3px solid transparent;
  border-radius: 0; background: none; transition: var(--transition);
  position: relative; top: 2px; white-space: nowrap; cursor: pointer;
  user-select: none;
}
.rms-tabs .nav-tabs .nav-link:hover { color: var(--blue); background: var(--blue-50); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.rms-tabs .nav-tabs .nav-link.active { color: var(--blue); border-bottom-color: var(--blue); background: none; }
.rms-tab-content {
  background: var(--white);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--grey-200); border-top: none;
  padding: 18px 14px;
}

/* ── Buttons ── */
.btn {
  font-family: 'Google Sans', sans-serif; font-weight: 500; font-size: 14px;
  border-radius: var(--radius-sm); padding: 9px 18px; border: none;
  cursor: pointer; transition: var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; line-height: 1.4; white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary    { background: var(--blue);     color: #fff; }
.btn-primary:hover    { background: var(--blue-dark); color: #fff; text-decoration: none; box-shadow: var(--shadow-2); }
.btn-outline-primary  { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-outline-primary:hover { background: var(--blue-light); text-decoration: none; }
.btn-sm  { font-size: 12px; padding: 6px 12px; }
.btn-danger   { background: var(--red);   color: #fff; }
.btn-danger:hover   { background: #c62828; color: #fff; text-decoration: none; }
.btn-success  { background: var(--green); color: #fff; }
.btn-success:hover  { background: #2e7d32; color: #fff; text-decoration: none; }
.btn-secondary { background: var(--grey-100); color: var(--grey-700); border: 1px solid var(--grey-300); }
.btn-secondary:hover { background: var(--grey-200); color: var(--grey-900); text-decoration: none; }
.btn-warning  { background: var(--yellow); color: var(--grey-900); }
.btn-warning:hover  { background: #f9a825; color: var(--grey-900); text-decoration: none; }

/* ── Forms ── */
.form-label {
  font-family: 'Google Sans', sans-serif; font-size: 13px; font-weight: 500;
  color: var(--grey-700); margin-bottom: 6px; display: block;
}
.form-control, .form-select {
  border: 1.5px solid var(--grey-300); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 15px; font-family: 'Roboto', sans-serif;
  color: var(--grey-900); background: #fff; width: 100%;
  transition: var(--transition); outline: none;
  -webkit-appearance: none; appearance: none;
}
.form-control:focus, .form-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,115,232,.15); }
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235f6368' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
textarea.form-control { resize: vertical; min-height: 90px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); flex: 1; }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Tables — horizontal scroll on mobile ── */
.table-wrapper {
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-md);
  overflow: hidden; background: #fff;
}
.table-scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll-x table { min-width: 520px; }
.table-scroll { max-height: 520px; overflow-y: auto; }

table.rms-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rms-table thead { background: var(--grey-50); }
table.rms-table thead th {
  padding: 10px 13px;
  font-family: 'Google Sans', sans-serif; font-weight: 500;
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--grey-700); border-bottom: 1px solid var(--grey-200);
  white-space: nowrap; text-align: left;
}
table.rms-table tbody tr { transition: background .1s; }
table.rms-table tbody tr:hover { background: var(--grey-50); }
table.rms-table tbody td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--grey-100);
  color: var(--grey-900); vertical-align: middle; font-size: 14px;
}
table.rms-table tbody tr:last-child td { border-bottom: none; }

/* Score inputs */
.score-input {
  width: 68px; padding: 7px 5px; font-size: 14px;
  text-align: center; border: 1.5px solid var(--grey-300); border-radius: 4px;
  transition: var(--transition); background: #fff;
  -webkit-appearance: none;
}
.score-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(26,115,232,.15); outline: none; }
.score-input.saved { border-color: var(--green); background: var(--green-light); }
.score-input.error { border-color: var(--red);   background: var(--red-light); }
@media (max-width: 600px) {
  .score-input { width: 58px; font-size: 16px; }
}

/* ── Badges ── */
.badge-rms {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 12px;
  font-size: 11px; font-weight: 500;
  font-family: 'Google Sans', sans-serif; white-space: nowrap;
}
.badge-junior    { background: var(--blue-light);   color: var(--blue); }
.badge-senior    { background: var(--yellow-light); color: #7c5e00; }
.badge-general   { background: var(--green-light);  color: var(--green); }
.badge-science   { background: #e3f2fd; color: #0277bd; }
.badge-business  { background: #e8f5e9; color: #2e7d32; }
.badge-humanities{ background: #fce4ec; color: #880e4f; }
.badge-active    { background: var(--green-light);  color: var(--green); }
.badge-inactive  { background: var(--grey-100);     color: var(--grey-500); }

/* ── Alerts ── */
.rms-alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 15px; border-radius: var(--radius-md);
  margin-bottom: 16px; font-size: 14px; line-height: 1.5;
}
.rms-alert .alert-icon { font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.rms-alert-success { background: var(--green-light); color: #1e6b35; border: 1px solid #a8d5b5; }
.rms-alert-danger  { background: var(--red-light);   color: #8b1f1f; border: 1px solid #f4c7c3; }
.rms-alert-info    { background: var(--blue-light);  color: #174ea6; border: 1px solid #aecbfa; }
.rms-alert-warning { background: var(--yellow-light);color: #7c5e00; border: 1px solid #fdd663; }

/* ── Login ── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--grey-50); padding: 20px;
}
.login-card {
  background: #fff; border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card); border: 1px solid var(--grey-200);
  padding: 38px 32px; width: 100%; max-width: 420px;
}
.login-logo { text-align: center; margin-bottom: 26px; }
.dots-grid { display: grid; grid-template-columns: repeat(2,13px); gap: 4px; margin: 0 auto 12px; width: fit-content; }
.dot-lg { width: 13px; height: 13px; border-radius: 50%; }

/* ── Stats ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat-card {
  background: #fff; border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg); padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.stat-card .stat-number { font-family: 'Google Sans',sans-serif; font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-card .stat-label  { font-size: 11px; color: var(--grey-700); text-transform: uppercase; letter-spacing: .4px; font-weight: 500; }
.stat-card.blue   .stat-number { color: var(--blue); }
.stat-card.red    .stat-number { color: var(--red); }
.stat-card.green  .stat-number { color: var(--green); }
.stat-card.yellow .stat-number { color: #f9a825; }

/* ── Subject assign grid ── */
.subject-assign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: 7px; }
.subject-check-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: var(--transition); background: #fff; font-size: 13px;
}
.subject-check-item:hover { border-color: var(--blue); background: var(--blue-50); }
.subject-check-item input[type=checkbox] { accent-color: var(--blue); width: 15px; height: 15px; flex-shrink: 0; }
.subject-check-item.general { border-color: var(--green); background: var(--green-light); }
.subject-check-item.core    { border-color: var(--yellow); background: var(--yellow-light); }

/* ── Spinner (inline) ── */
.spinner-rms {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--grey-200); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle;
}

/* ── Modals ── */
.modal-content { border: none; border-radius: var(--radius-lg); box-shadow: 0 8px 32px rgba(60,64,67,.25); }
.modal-header  { border-bottom: 1px solid var(--grey-200); padding: 16px 18px 12px; }
.modal-title   { font-family: 'Google Sans',sans-serif; font-size: 16px; font-weight: 500; }
.modal-body    { padding: 18px; }
.modal-footer  { border-top: 1px solid var(--grey-200); padding: 12px 18px; }

/* ── Chips & dividers ── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 16px; font-size: 12px;
  font-family: 'Google Sans',sans-serif; font-weight: 500;
  background: var(--grey-100); color: var(--grey-700); border: 1px solid var(--grey-200);
}
.section-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; }
.section-divider span { font-family: 'Google Sans',sans-serif; font-size: 11px; font-weight: 500; color: var(--grey-500); text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.section-divider::before,.section-divider::after { content:''; flex:1; height:1px; background: var(--grey-200); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 44px 18px; color: var(--grey-500); }
.empty-state .empty-icon { font-size: 42px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; line-height: 1.6; }

/* ── AI Prompt Box ── */
.ai-prompt-box {
  background: #f0f4ff;
  border: 1.5px dashed var(--blue);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  position: relative;
}
.ai-prompt-box pre {
  font-family: 'Roboto Mono','Courier New',monospace;
  font-size: 12px; color: var(--grey-700);
  white-space: pre-wrap; word-break: break-word;
  margin: 0; line-height: 1.6; max-height: 190px; overflow-y: auto;
}
.ai-prompt-box .copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: var(--blue); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 5px 12px;
  font-size: 12px; font-family: 'Google Sans',sans-serif; font-weight: 500;
  cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.ai-prompt-box .copy-btn:hover { background: var(--blue-dark); }
.ai-prompt-box .copy-btn.copied { background: var(--green); }

/* ── Toast notification ── */
.rms-toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 10000; min-width: 280px; max-width: 92vw;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  animation: slideUpToast .3s ease;
  border-radius: var(--radius-md);
}
@keyframes slideUpToast {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .rms-container   { padding: 12px 10px; }
  .rms-tab-content { padding: 14px 10px; }
  .login-card      { padding: 28px 18px; }
  .stats-grid      { grid-template-columns: repeat(2,1fr); }
  .rms-card .card-body { padding: 13px; }
  .hide-mobile     { display: none !important; }
  .modal-dialog    { margin: 8px; }
}
@media (max-width: 480px) {
  .stats-grid      { grid-template-columns: repeat(2,1fr); gap: 8px; }
  .page-header h1  { font-size: 19px; }
  .rms-tabs .nav-tabs .nav-link { font-size: 12px; padding: 11px 9px 9px; }
  table.rms-table tbody td,
  table.rms-table thead th { padding: 9px 9px; font-size: 13px; }
  .subject-assign-grid { grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); }
}

/* ── Print helpers ── */
@media print {
  .rms-navbar, .ctrl-bar, .print-hide { display: none !important; }
}
