/* Employee Attendance - simple, professional, responsive */

:root {
  --blue: #1a4f8b;
  --blue-dark: #143c6b;
  --green: #1e8e3e;
  --red: #c5221f;
  --orange: #e8710a;
  --purple: #6b3fa0;
  --teal: #0e7490;
  --grey-bg: #f4f6f8;
  --grey-line: #e1e5ea;
  --text: #21262c;
  --muted: #6b7480;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #ffffff;
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

/* ------------------------------ header ------------------------------ */

.topbar {
  background: var(--blue);
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.topbar-action { margin: 0; }

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.container.narrow { max-width: 380px; }

.today {
  margin: 0 0 16px;
  color: var(--muted);
}

.today strong {
  color: var(--text);
  font-size: 18px;
}

.page-title {
  font-size: 18px;
  margin: 4px 0 14px;
}

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

.card {
  background: var(--grey-bg);
  border: 1px solid var(--grey-line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.card-title { margin: 0 0 12px; font-size: 17px; }

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 14px;
  padding: 12px 16px;
}

.s-present { color: var(--green); }
.s-absent { color: var(--red); }
.s-leave { color: var(--orange); }
.s-late { color: var(--purple); }
.s-short_leave { color: var(--teal); }
.s-none { color: var(--muted); }

/* ------------------------------- list ------------------------------- */

.list-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--grey-line);
  margin-bottom: 4px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--grey-line);
}

.row:last-child { border-bottom: none; }

.name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon:empty { display: none; }

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status {
  font-weight: 600;
  white-space: nowrap;
}

.status-present { color: var(--green); }
.status-absent { color: var(--red); }
.status-leave { color: var(--orange); }
.status-late { color: var(--purple); }
.status-short_leave { color: var(--teal); }
.status-none { color: var(--muted); font-weight: 500; }

.locked {
  font-size: 12px;
  color: var(--muted);
}

.empty, .readonly-note {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.readonly-note { text-align: center; }

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

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  color: #ffffff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn:disabled { opacity: 0.6; cursor: default; }

.btn-present { background: var(--green); }
.btn-absent { background: var(--red); }
.btn-leave { background: var(--orange); }
.btn-late { background: var(--purple); }
.btn-short_leave { background: var(--teal); }
.btn-primary { background: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); }

.btn-ghost {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
}

.topbar .btn-ghost { color: #ffffff; }

.btn-block { width: 100%; margin-top: 16px; }

.btn-history {
  color: var(--blue);
  margin-bottom: 16px;
}

/* ------------------------------- forms ------------------------------ */

label {
  display: block;
  font-size: 14px;
  margin: 10px 0 4px;
  color: var(--muted);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--grey-line);
  border-radius: 6px;
  background: #ffffff;
}

.alert {
  background: #fdecea;
  border: 1px solid #f5c2c0;
  color: var(--red);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  margin: 0 0 12px;
}

/* ------------------------------ history ----------------------------- */

.history-row { padding: 0; }

.history-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  padding: 12px 0;
  color: inherit;
  text-decoration: none;
}

.history-link:hover .name { text-decoration: underline; }

.counts {
  display: flex;
  gap: 14px;
  font-size: 14px;
  flex-wrap: wrap;
}

/* ------------------------- modal and toast -------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  background: #ffffff;
  border-radius: 8px;
  padding: 20px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.modal p { margin: 0 0 6px; font-size: 16px; font-weight: 600; }

.modal-note {
  font-size: 13px !important;
  font-weight: 400 !important;
  color: var(--muted);
  margin-bottom: 16px !important;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-buttons .btn-ghost { color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: #21262c;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  max-width: 90%;
  text-align: center;
}

.toast[hidden] { display: none; }
.toast.error { background: var(--red); }

/* ------------------------------ mobile ------------------------------ */

@media (max-width: 600px) {
  .topbar h1 { font-size: 17px; }

  .list-head { display: none; }

  .row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .actions {
    justify-content: flex-start;
    width: 100%;
  }

  .actions .btn { flex: 1 1 auto; text-align: center; }

  .locked { width: 100%; }

  .history-link { flex-direction: column; align-items: flex-start; }
}

/* ---------------------- out time and manage page --------------------- */

.out-time {
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.out-time-field {
  text-align: left;
  margin-bottom: 12px;
}

.out-time-field[hidden] { display: none; }

.out-time-field input[type="time"] {
  width: 100%;
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--grey-line);
  border-radius: 6px;
  background: #ffffff;
}

.field-error {
  display: block;
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  margin-top: 5px;
}

.field-error[hidden] { display: none; }

.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.page-links .btn-history { margin-bottom: 0; }

.notice {
  background: #e7f4ea;
  border: 1px solid #b7dfc2;
  color: var(--green);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  margin: 0 0 12px;
}

.add-form label {
  margin-top: 0;
}

.add-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.add-row input[type="text"] { flex: 1 1 auto; }
.add-row .btn { flex: 0 0 auto; }

.actions form { margin: 0; }

.muted-name { color: var(--muted); }

@media (max-width: 600px) {
  .add-row { flex-direction: column; }
  .page-links .btn-history { flex: 1 1 auto; text-align: center; }
}

/* ------------------------------ logins ------------------------------- */

.hint {
  color: var(--muted);
  font-size: .9rem;
  margin: -6px 0 6px;
}

.you {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--blue);
  background: #e6eef8;
  border-radius: 3px;
  padding: 2px 6px;
  margin-left: 6px;
}

/* ------------------------------- roles ------------------------------- */

.role-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  border-radius: 3px;
  padding: 2px 7px;
  white-space: nowrap;
}

.role-super_admin { color: #6b3fa0; background: #efe8f8; }
.role-manager     { color: #0e7490; background: #e2f1f5; }

.role-key p {
  margin: 0 0 6px;
  font-size: .9rem;
  color: var(--muted);
}
.role-key p:last-child { margin-bottom: 0; }

.who {
  font-size: 13px;
  opacity: .85;
  margin-right: 4px;
}

.topbar-action {
  display: flex;
  align-items: center;
  gap: 8px;
}

select {
  width: 100%;
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--grey-line);
  border-radius: 6px;
  background: #ffffff;
}

.btn-small { font-size: 13px; padding: 6px 10px; }

.user-row { flex-wrap: wrap; }

.reset-row {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}
.reset-row input { flex: 1 1 auto; min-width: 0; }
.reset-row .btn { flex: 0 0 auto; }

@media (max-width: 600px) {
  .reset-row { flex-direction: column; }
}

.backfill-note { margin-bottom: 16px; }

/* ------------------------------ calendar ----------------------------- */

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.cal-title { font-size: 1.05rem; }

.is-disabled { opacity: .3; cursor: default; }

.cal-jump {
  margin: -4px 0 12px;
  font-size: .88rem;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.cal-weekday {
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding-bottom: 4px;
}

.cal-cell {
  min-height: 54px;
  border: 1px solid var(--grey-line);
  border-radius: 6px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text);
  padding: 4px 2px;
}

a.cal-cell:hover { border-color: var(--blue); }

.cal-cell.is-blank { border: none; background: transparent; min-height: 0; }

.cal-cell.is-future {
  background: #fafbfc;
  color: #b6bec7;
  border-style: dashed;
}

.cal-day { font-weight: 600; font-size: 15px; line-height: 1.1; }

.cal-count {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.cal-none { color: #b6bec7; font-weight: 400; }

.cal-cell.is-complete { background: #e8f5ec; border-color: #b7dfc4; }
.cal-cell.is-complete .cal-count { color: var(--green); }

.cal-cell.is-partial { background: #fdf3e6; border-color: #f0d3ab; }
.cal-cell.is-partial .cal-count { color: var(--orange); }

.cal-cell.is-empty { background: #ffffff; }

.cal-cell.is-today {
  border: 2px solid var(--blue);
  box-shadow: 0 0 0 1px rgba(26, 79, 139, .15);
}

.cal-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 14px 0 0;
  padding: 0;
  font-size: 12px;
  color: var(--muted);
}

.cal-legend li { display: flex; align-items: center; gap: 6px; }

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--grey-line);
  display: inline-block;
}

.swatch-complete { background: #e8f5ec; border-color: #b7dfc4; }
.swatch-partial  { background: #fdf3e6; border-color: #f0d3ab; }
.swatch-empty    { background: #ffffff; }
.swatch-today    { background: #ffffff; border: 2px solid var(--blue); }

.jump-form { display: flex; gap: 8px; }
.jump-form input { flex: 1 1 auto; min-width: 0; }

@media (max-width: 600px) {
  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 46px; }
  .cal-day { font-size: 14px; }
  .jump-form { flex-direction: column; }
}
