/* APU Student Portal — shared styles for index.html and dashboard.html */

:root {
  --navy:        #0d2b53;
  --navy-dark:   #082040;
  --navy-soft:   #1b4784;
  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --text:        #1c2430;
  --muted:       #667284;
  --border:      #dfe4ec;
  --border-soft: #eaeef4;

  --good:    #16713f;
  --good-bg: #e7f4ec;
  --warn:    #8a5a06;
  --warn-bg: #fdf3e0;
  --bad:     #b3241c;
  --bad-bg:  #fdecea;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(13, 43, 83, 0.06), 0 6px 20px rgba(13, 43, 83, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2 { letter-spacing: -0.01em; }
.muted { color: var(--muted); font-size: 13px; }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

/* ---------- brand ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 8px;
  display: block;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }

.brand-name {
  font-size: 15px;
  font-weight: 700;
}

.brand-sub {
  font-size: 12px;
  opacity: 0.75;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-stacked {
  flex-direction: column;
  text-align: center;
  gap: 10px;
  color: var(--navy);
}

.brand-stacked .brand-mark { width: 56px; height: 56px; }
.brand-stacked .brand-text { align-items: center; }

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--navy-soft);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
}

.btn-primary:hover { background: var(--navy-dark); }

.btn-block { width: 100%; padding: 12px 16px; }

.btn-ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
  padding: 7px 14px;
  font-size: 14px;
}

.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- login page ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px 16px;
  background:
    linear-gradient(180deg, rgba(13, 43, 83, 0.06), rgba(13, 43, 83, 0)) ,
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px 24px;
}

.login-title {
  margin: 22px 0 4px;
  font-size: 19px;
  text-align: center;
}

.login-hint {
  margin: 0 0 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #3a4453;
}

.field input {
  width: 100%;
  font: inherit;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fcfdfe;
  color: var(--text);
}

.field input:focus {
  outline: none;
  border-color: var(--navy-soft);
  box-shadow: 0 0 0 3px rgba(27, 71, 132, 0.14);
}

.field input.input-error {
  border-color: var(--bad);
  background: var(--bad-bg);
}

.form-error {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--bad-bg);
  border: 1px solid #f3c4c0;
  color: var(--bad);
  font-size: 13px;
  font-weight: 600;
}

.login-foot {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* ---------- dashboard shell ---------- */

.topbar {
  background: var(--navy);
  color: #fff;
}

.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user {
  font-size: 13px;
  opacity: 0.9;
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 22px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- cards ---------- */

.card {
  min-width: 0; /* let the flex item shrink so .table-scroll can scroll */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-title {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--navy);
}

.card-head .card-title { margin: 0; }

/* ---------- welcome ---------- */

.welcome {
  display: flex;
  align-items: center;
  gap: 18px;
}

.avatar {
  width: 78px;
  height: 78px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border-soft);
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}

.welcome-text {
  min-width: 0;
}

.welcome-text h1 {
  margin: 0 0 4px;
  font-size: 20px;
  overflow-wrap: break-word;
}

.welcome-text p { margin: 0; }

/* ---------- student info ---------- */

.info-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 24px;
}

.info-item dt {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 3px;
}

.info-item dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: break-word;
}

/* ---------- tables ---------- */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

.table th {
  background: #f7f9fc;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.table tbody tr:hover { background: #fafbfd; }
.table tbody tr:last-child td { border-bottom: none; }

/* Year heading inside the grades table */
.group-row th {
  background: #eef2f8;
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.group-row:hover { background: none; }

.table .num { text-align: right; }

.badge {
  display: inline-block;
  min-width: 34px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.badge-good { background: var(--good-bg); color: var(--good); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad  { background: var(--bad-bg);  color: var(--bad); }

.tone-good { color: var(--good); font-weight: 600; }
.tone-warn { color: var(--warn); font-weight: 600; }
.tone-bad  { color: var(--bad);  font-weight: 600; }

/* ---------- summary stats ---------- */

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.stat {
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: #f7f9fc;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  overflow-wrap: break-word;
}

/* ---------- attendance ---------- */

.attendance-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px 28px;
}

/* Keep the bars aligned across the grid when a module name wraps. */
.attendance-item {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.attendance-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.attendance-name { font-size: 14px; }
.attendance-value { font-size: 14px; }

.bar {
  height: 9px;
  border-radius: 999px;
  background: #eceff4;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
}

.bar-good { background: #1f9d58; }
.bar-warn { background: #e0a32a; }
.bar-bad  { background: #cf3a30; }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .topbar-inner {
    justify-content: center;
    text-align: center;
  }

  .welcome {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }

  .welcome-text h1 { font-size: 18px; }

  .card { padding: 16px; }

  .attendance-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
