/* BNKAcademicHub - shared stylesheet */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1f2733;
  --text-muted: #6b7685;
  --border: #e3e7ef;
  --primary: #3457d5;
  --primary-dark: #2540a8;
  --primary-light: #eaefff;
  --accent: #10b283;
  --danger: #e0483e;
  --danger-light: #fdecea;
  --warn: #d99a1b;
  --warn-light: #fdf3de;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.04), 0 8px 24px rgba(20, 30, 60, 0.06);
  font-family: "Sarabun", "Noto Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.container-narrow {
  max-width: 460px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand .logo-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--text-muted);
}
.topbar .user-info strong { color: var(--text); }

/* Login screen */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
}
.login-card .logo-dot { background: var(--accent); }
.login-title {
  text-align: center;
  margin-bottom: 4px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-dark);
}
.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* Cards / sections */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2, .card h3 {
  margin-top: 0;
}
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-header {
  padding: 28px 0 8px;
}
.page-header h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
}
.page-header p {
  color: var(--text-muted);
  margin: 0;
}

/* Forms */
label { font-size: 0.88rem; font-weight: 600; color: var(--text); display: block; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }
textarea { resize: vertical; min-height: 70px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-full { width: 100%; }
.btn-secondary { background: var(--primary-light); color: var(--primary-dark); }
.btn-secondary:hover { background: #dbe3ff; }
.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: #fadcd9; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: #eef1f6; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; border-radius: 8px; }

.error-box {
  background: var(--danger-light);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 14px;
}
.hint { color: var(--text-muted); font-size: 0.82rem; margin-top: 6px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}
.badge-active { background: #e5f8f1; color: var(--accent); }
.badge-archived { background: var(--warn-light); color: var(--warn); }
.badge-admin { background: var(--primary-light); color: var(--primary-dark); }
.badge-teacher { background: #eef1f6; color: var(--text-muted); }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: .02em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab-btn {
  background: none; border: none; padding: 10px 16px; font-family: inherit;
  font-size: 0.92rem; font-weight: 600; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Submission list */
.year-group { margin-bottom: 22px; }
.year-group-title {
  font-weight: 700; font-size: 0.95rem; color: var(--primary-dark);
  margin-bottom: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--primary-light);
}
.sub-item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--border);
}
.sub-item:last-child { border-bottom: none; }
.sub-item-title { font-weight: 600; }
.sub-item-desc { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }
.sub-item-meta { color: var(--text-muted); font-size: 0.78rem; margin-top: 4px; }
.sub-item-actions { display: flex; gap: 8px; flex-shrink: 0; }

.empty-state {
  text-align: center; color: var(--text-muted); padding: 32px 12px; font-size: 0.9rem;
}

/* Calendar */
.calendar-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.calendar-header .month-label { font-weight: 700; }
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.calendar-grid .dow {
  text-align: center; font-size: 0.72rem; color: var(--text-muted); font-weight: 700; padding-bottom: 4px;
}
.calendar-cell {
  aspect-ratio: 1 / 1; min-height: 40px;
  border-radius: 8px; padding: 4px 6px; font-size: 0.78rem;
  background: #f8f9fc; position: relative; color: var(--text);
}
.calendar-cell.empty { background: transparent; }
.calendar-cell.today { box-shadow: inset 0 0 0 2px var(--primary); }
.calendar-cell.has-event { background: var(--primary-light); cursor: pointer; }
.calendar-cell .day-num { font-weight: 600; }
.calendar-cell .event-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
  position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
}
.event-list-item {
  display: flex; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border); align-items: flex-start;
}
.event-list-item:last-child { border-bottom: none; }
.event-date-chip {
  flex-shrink: 0; background: var(--primary-light); color: var(--primary-dark);
  border-radius: 8px; padding: 6px 10px; font-size: 0.76rem; font-weight: 700; text-align: center; min-width: 58px;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 26, 40, 0.5);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-backdrop[hidden] { display: none; }
.modal-box {
  background: var(--surface); border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow); text-align: center;
}
.modal-box h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: center; }
#qrcode-box { display: flex; justify-content: center; margin: 16px 0; }
.qr-link {
  font-size: 0.8rem; word-break: break-all; color: var(--text-muted);
  background: #f8f9fc; padding: 8px 10px; border-radius: 8px; margin-top: 6px;
}

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f2733; color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 0.88rem; opacity: 0; pointer-events: none; transition: all 0.2s ease; z-index: 200;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: var(--danger); }

/* Public view page */
.public-header {
  text-align: center; padding: 40px 20px 20px;
}
.public-header .avatar {
  width: 64px; height: 64px; border-radius: 50%; background: var(--primary-light);
  color: var(--primary-dark); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.4rem; margin: 0 auto 12px;
}
.public-header h1 { margin: 0 0 4px; font-size: 1.3rem; }
.public-header .status-note { color: var(--text-muted); font-size: 0.82rem; }

.loading { text-align: center; color: var(--text-muted); padding: 40px 0; }

@media (max-width: 560px) {
  .field-row { flex-direction: column; gap: 0; }
  .topbar { padding: 12px 14px; }
  .card { padding: 18px 16px; }
  .sub-item { flex-direction: column; }
}
