/* ── Reset & tokens ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:   #2563eb;
  --pri-hover: #1d4ed8;
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --border-2:  #cbd5e1;
  --text:      #0f172a;
  --muted:     #64748b;
  --radius:    10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 16px rgba(0,0,0,.08);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Navbar ──────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 54px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-sm);
}
.brand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -.01em;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
}
.nav-links a:not(.btn-primary):not(.btn-sm) {
  text-decoration: none;
  color: var(--muted);
  font-size: .85rem;
  transition: color .15s;
}
.nav-links a:not(.btn-primary):not(.btn-sm):hover { color: var(--primary); }

/* ── Shared button styles ────────────────────────── */
.btn-sm, .btn-primary {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s, filter .15s;
  white-space: nowrap;
}
.btn-primary, .btn-sm { background: var(--primary); color: #fff; }
.btn-primary:hover, .btn-sm:hover { background: var(--pri-hover); }

/* ── Page-level buttons (timeline + form) ────────── */
.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-danger { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-danger:hover { background: #dc2626; }

/* ── Alerts ──────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: .85rem;
}
.alert.error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert.success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert.hidden  { display: none; }
.hidden        { display: none !important; }

/* ════════════════════════════════════════════════════
   EVENT TIMELINE PAGE
   ════════════════════════════════════════════════════ */

.page-wrap {
  max-width: 1460px;
  margin: 24px auto;
  padding: 0 20px;
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 20px;
  border-bottom: none;
}
.top-bar-left { display: flex; align-items: center; gap: 10px; }
.year-label   { font-size: 1.1rem; font-weight: 700; min-width: 48px; text-align: center; letter-spacing: -.01em; }
.nav-btn {
  background: none;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  width: 30px; height: 30px;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: var(--bg); color: var(--text); }

.dept-select {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  font-size: .8rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s;
  max-width: 160px;
}
.dept-select:focus { outline: none; border-color: var(--primary); }

.btn-new {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 7px;
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}
.btn-new:hover { background: var(--pri-hover); }

/* Table scroll wrapper */
.tbl-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}

/* Table base */
.tbl {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Column widths via colgroup */
.col-event { width: 220px; }

/* Header row */
.th {
  padding: 10px 8px;
  text-align: center;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.th:last-child { border-right: none; }
.th-event {
  text-align: left;
  padding-left: 18px;
  border-right: 2px solid var(--border);
}
.th-now {
  color: var(--primary);
  background: #eff6ff;
  border-bottom-color: var(--primary);
}

/* EVENT column cell */
.td-event {
  padding: 14px 14px 14px 16px;
  border-right: 2px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.ev-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.ev-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.ev-text { min-width: 0; }
.ev-name {
  font-weight: 600;
  font-size: .875rem;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}
.ev-dept {
  display: inline-block;
  font-size: .65rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  margin-top: 4px;
  letter-spacing: .01em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ev-meta {
  font-size: .72rem;
  color: var(--muted);
  margin-top: 3px;
}
.ev-desc {
  font-size: .72rem;
  color: var(--muted);
  margin-top: 2px;
  font-style: italic;
  line-height: 1.4;
  word-break: break-word;
}

/* Month cells (empty) */
.td-month {
  padding: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.td-month:last-child { border-right: none; }

/* Current-month column: subtle tint */
.td-now-col { background: #fafcff; }

/* Month cell WITH an event */
.td-hit {
  padding: 10px 10px 12px 10px;
  vertical-align: top;
}
.hit-name {
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-word;
}
.hit-desc {
  font-size: .68rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
  word-break: break-word;
  font-style: italic;
}

/* Row hover */
.tbl tbody tr:hover .td-event { background: #f8faff; }
.tbl tbody tr:hover .td-month:not(.td-hit) { background: #f8fafc; }

/* Empty / loading */
.cell-state {
  padding: 64px 24px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}
.cell-state a { color: var(--primary); text-decoration: none; font-weight: 500; }

/* ════════════════════════════════════════════════════
   EVENT FORM PAGE
   ════════════════════════════════════════════════════ */

.form-wrap {
  max-width: 600px;
  margin: 40px auto;
  padding: 0 20px;
}
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 36px 40px 40px;
}
.form-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}
.form-subtitle {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 28px;
}
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-size: .9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.required { color: #ef4444; }

.btn-submit {
  padding: 10px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-submit:hover:not(:disabled) { background: var(--pri-hover); }
.btn-submit:disabled { opacity: .55; cursor: not-allowed; }

.btn-cancel {
  padding: 10px 20px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: background .15s;
}
.btn-cancel:hover { background: var(--border); }

/* ════════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  z-index: 900;
  backdrop-filter: blur(2px);
}
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  z-index: 901;
  width: 92%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.modal-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.m-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.modal-hdr h3 { flex: 1; font-size: .95rem; font-weight: 600; }
.m-close {
  background: none; border: none;
  font-size: 1.35rem; line-height: 1;
  cursor: pointer; color: var(--muted);
  padding: 0 2px;
}
.m-close:hover { color: var(--text); }
.modal-bdy {
  padding: 4px 20px 20px;
  overflow-y: auto;
  flex: 1;
}
.m-sec {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding: 16px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.m-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 10px 0;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
}
.m-row:last-of-type { border-bottom: none; }
.m-row span { color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.m-row strong { text-align: right; font-weight: 500; word-break: break-word; }
.m-row strong a { color: var(--primary); text-decoration: none; }
.m-row strong a:hover { text-decoration: underline; }
.m-img-wrap { padding: 10px 0 4px; }
.m-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; }

/* ── Nav user info ───────────────────────────────── */
.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.nav-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nav-name {
  font-size: .82rem;
  color: var(--text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-logout {
  background: none;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: .75rem;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-logout:hover { background: #fef2f2; color: #dc2626; border-color: #fca5a5; }

/* ── Login page ──────────────────────────────────── */
.login-body { background: var(--bg); display: flex; flex-direction: column; }
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 48px 44px;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}
.login-brand { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -.02em;
}
.login-sub {
  font-size: .875rem;
  color: var(--muted);
  margin-bottom: 32px;
  line-height: 1.5;
}
.btn-vigo-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-size: .925rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, transform .1s;
  margin-bottom: 20px;
}
.btn-vigo-login:hover {
  background: var(--pri-hover);
  transform: translateY(-1px);
}
.login-note {
  text-align: center;
  font-size: .75rem;
  color: var(--muted);
}

/* ── Spinner (auth callback) ─────────────────────── */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════
   MULTI-SECTION FORM
   ════════════════════════════════════════════════════ */

.form-wrap { max-width: 760px; }

.form-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
}
.form-section.hidden-section { display: none; }

.form-section-hdr {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.form-section-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.form-section-info { flex: 1; min-width: 0; }
.form-section-title { font-size: .92rem; font-weight: 700; color: var(--text); }
.form-section-desc  { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.form-section-body  { padding: 20px 22px 24px; }

/* Sub-labels within form rows */
.sub-label { font-size: .72rem; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.field-hint-top { font-size: .72rem; color: var(--muted); margin-bottom: 6px; }
.field-hint { font-size: .72rem; color: var(--muted); margin-top: 5px; text-align: right; }

/* Radio & checkbox option lists */
.opt-list { display: flex; flex-direction: column; gap: 6px; }
.opt-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.opt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  user-select: none;
  line-height: 1.4;
}
.opt-item:hover { background: #f0f6ff; border-color: #93c5fd; }
.opt-item:has(input:checked) { background: #eff6ff; border-color: var(--primary); }

.opt-item input[type="radio"],
.opt-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--primary);
  margin: 0;
}
.opt-item span {
  font-size: .875rem;
  color: var(--text);
}
.item-hint {
  font-size: .72rem;
  color: var(--muted);
  font-style: normal;
}

/* Validation error state */
.form-group.is-invalid > label { color: #dc2626; }
.form-group.is-invalid input:not([type="radio"]):not([type="checkbox"]):not([type="file"]):not([type="hidden"]):not([readonly]),
.form-group.is-invalid textarea {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,.1) !important;
}
.form-group.is-invalid .opt-list .opt-item,
.form-group.is-invalid .opt-grid .opt-item { border-color: #fca5a5; background: #fff5f5; }
.field-err {
  font-size: .75rem;
  color: #dc2626;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.field-err::before { content: '⚠'; font-size: .7rem; }

/* Sub-input (e.g. department "Khác") */
.sub-input {
  margin-top: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border-2);
  border-radius: 8px;
  font-size: .875rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.sub-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* File upload drop zone */
.file-wrap {
  position: relative;
  border: 2px dashed var(--border-2);
  border-radius: 8px;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  background: #fafcff;
  transition: border-color .2s, background .2s;
}
.file-wrap:hover { border-color: var(--primary); background: #eff6ff; }
.file-wrap input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.file-icon { font-size: 1.5rem; margin-bottom: 6px; }
.file-label { font-size: .82rem; color: var(--muted); }
.file-label strong { color: var(--primary); }
.file-chosen { font-size: .8rem; color: #16a34a; margin-top: 8px; font-weight: 500; min-height: 1em; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .form-card { padding: 24px 20px; }
  .form-wrap { margin: 16px auto; padding: 0 12px; }
  .form-section-body { padding: 16px 14px 20px; }
  .opt-grid { grid-template-columns: 1fr; }
  .page-wrap { padding: 0 12px; margin: 16px auto; }
  .top-bar { padding: 10px 14px; }
  .year-label { font-size: .95rem; }
  .login-card { padding: 36px 24px; }
  .nav-name { display: none; }
}
