/* Khung lịch điểm danh */
.attendance-widget {
  min-width: 0;
  padding-top: 10px;

  --att-ink: #344a48;
  --att-muted: #858a7b;
  --att-green: #419579;
  --att-red: #d77c76;
  --att-gold: #c69c5d;
}

.attendance-widget * {
  box-sizing: border-box;
}

.attendance-widget .attendance-paper {
  position: relative;
  isolation: isolate;
  overflow: visible;

  padding: 31px 16px 15px;

  border: 1px solid #ede9db;
  border-radius: 18px;

  background: #fffdf6;
  color: var(--att-ink);
  box-shadow: 0 6px 20px #474b3210;
}

.attendance-widget .attendance-paper::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;

  border-radius: inherit;

  background: radial-gradient(
    ellipse at 100% 0,
    #edf1e340,
    transparent 65%
  );

  pointer-events: none;
}

/* Lò xo */
.attendance-widget .attendance-rings {
  position: absolute;
  top: -10px;
  right: 17px;
  left: 17px;

  display: flex;
  justify-content: space-between;

  pointer-events: none;
}

.attendance-widget .attendance-rings i {
  width: 12px;
  height: 24px;

  border: 3px solid var(--att-gold);
  border-bottom-color: #957440;
  border-radius: 7px;

  background: transparent;
  box-shadow: 1px 1px 1px #79562517;

  transform: rotate(-5deg);
}

.attendance-widget .attendance-leaves {
  position: absolute;
  top: 41px;
  right: -1px;
  z-index: -1;

  width: 54px;

  color: #829783;
  opacity: 0.22;
  pointer-events: none;
}

.attendance-widget .attendance-leaves svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Tiêu đề lịch */
.attendance-widget .attendance-heading {
  display: flex;
  align-items: center;
  gap: 7px;

  min-width: 0;
  margin-bottom: 17px;
}

.attendance-widget .attendance-heading-icon {
  display: flex;
  align-items: center;
  color: #6c7f68;
}

.attendance-widget .attendance-heading-icon svg {
  width: 18px;
  height: 18px;
}

.attendance-widget .attendance-heading h2 {
  margin: 0;

  color: var(--att-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.6;
  letter-spacing: -0.3px;
}

.attendance-widget button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.attendance-widget button:disabled {
  cursor: default;
}

.attendance-widget button:focus-visible {
  outline: 2px solid #8470c9;
  outline-offset: 2px;
}

.attendance-widget .attendance-today-button {
  margin-left: auto;
  padding: 4px 6px;

  border: 0;
  border-radius: 5px;

  background: #efeee3;
  color: #7d8067;

  font-size: 9px;
  line-height: 1.6;
  white-space: nowrap;
}

.attendance-widget .attendance-today-button:hover:not(:disabled) {
  background: #e5e9db;
  color: #3b725c;
}

.attendance-widget .attendance-today-button:disabled {
  opacity: 0.5;
}

/* Chuyển tháng */
.attendance-widget .attendance-navigation {
  display: grid;
  grid-template-columns: 25px 1fr 25px;
  align-items: center;
  gap: 4px;

  margin-bottom: 12px;
}

.attendance-widget .attendance-month-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.7;
  letter-spacing: -0.2px;
  text-align: center;
}

.attendance-widget .attendance-month-arrow {
  display: grid;
  place-items: center;

  width: 25px;
  height: 25px;
  padding: 0;

  border: 0;
  border-radius: 8px;

  background: transparent;
  color: #66786b;

  font-size: 24px;
  line-height: 1;
}

.attendance-widget .attendance-month-arrow:hover:not(:disabled) {
  background: #ecefe4;
  color: #345c4b;
}

.attendance-widget .attendance-month-arrow:disabled {
  opacity: 0.3;
}

/* Các ô ngày */
.attendance-widget .attendance-weekdays,
.attendance-widget .attendance-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.attendance-widget .attendance-weekdays {
  margin-bottom: 6px;
  padding-top: 11px;

  border-top: 1px solid #eeebdf;

  color: #929582;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.7;
  text-align: center;
}

.attendance-widget .attendance-grid {
  row-gap: 4px;
}

.attendance-widget .attendance-day {
  position: relative;

  display: grid;
  place-items: center;

  min-width: 0;
  aspect-ratio: 1;
  padding: 0;

  border: 0;
  border-radius: 50%;

  background: transparent;
  color: #556056;

  font-size: 11px;
  line-height: 1;

  transition:
    background 0.16s,
    color 0.16s;
}

.attendance-widget .attendance-day-number {
  display: grid;
  place-items: center;

  width: 27px;
  height: 27px;
  max-width: 100%;
  max-height: 100%;

  border: 1px solid transparent;
  border-radius: 50%;
}

.attendance-widget .attendance-day:not(:disabled):hover {
  background: #f0ecdf;
}

.attendance-widget .attendance-day.other-month {
  color: #c7c8bc;
}

.attendance-widget
  .attendance-day.pending:not(.other-month):not(.is-future)
  .attendance-day-number {
  background: #eeeee540;
}

.attendance-widget .attendance-day.is-future:not(.other-month) {
  color: #a5a895;
}

.attendance-widget .attendance-day.present .attendance-day-number {
  background: #e1f1e6;
  color: #397e60;
}

.attendance-widget .attendance-day.absent .attendance-day-number {
  background: #f8e6df;
  color: #c0746c;
}

.attendance-widget .attendance-day.present:not(.is-today)::after,
.attendance-widget .attendance-day.absent:not(.is-today)::after {
  content: "";

  position: absolute;
  bottom: 1px;

  width: 3px;
  height: 3px;
  border-radius: 50%;

  background: var(--att-green);
}

.attendance-widget .attendance-day.absent:not(.is-today)::after {
  background: var(--att-red);
}

.attendance-widget .attendance-day.is-today .attendance-day-number {
  background: #536e59;
  color: #ffffff;
  box-shadow: 0 3px 7px #405e3c22;
  font-weight: 700;
}

.attendance-widget .attendance-day.is-today.present .attendance-day-number {
  background: #328a6b;
}

.attendance-widget .attendance-day.is-today.absent .attendance-day-number {
  background: #bc756b;
}

/* Chú thích */
.attendance-widget .attendance-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 9px;

  margin-top: 12px;

  color: #8b8d7d;
  font-size: 9px;
  line-height: 1.7;
}

.attendance-widget .attendance-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.attendance-widget .attendance-dot {
  width: 5px;
  height: 5px;
  flex: none;

  border-radius: 50%;
  background: #c6c9bb;
}

.attendance-widget .attendance-dot.present {
  background: var(--att-green);
}

.attendance-widget .attendance-dot.absent {
  background: var(--att-red);
}

/* Thống kê điểm danh */
.attendance-widget .attendance-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));

  margin-top: 12px;
  padding: 13px 0 11px;

  border-top: 1px dashed #e8e4d6;
  text-align: center;
}

.attendance-widget .attendance-stats > div + div {
  border-left: 1px solid #ede9de;
}

.attendance-widget .attendance-stats strong,
.attendance-widget .attendance-stats span {
  display: block;
}

.attendance-widget .attendance-stats strong {
  color: #4c6756;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.5;
}

.attendance-widget .attendance-stats span {
  margin-top: 2px;
  color: #939281;
  font-size: 9px;
  line-height: 1.6;
}

.attendance-widget .attendance-checkin {
  display: block;

  width: 100%;
  min-height: 34px;
  padding: 8px;

  border: 1px solid #d8e5d7;
  border-radius: 8px;

  background: #eaf2e8;
  color: #507653;

  font-size: 10px;
  font-weight: 600;
  line-height: 1.5;

  transition: background 0.16s;
}

.attendance-widget .attendance-checkin:hover:not(:disabled) {
  background: #dcebd9;
}

.attendance-widget .attendance-checkin:disabled {
  border-color: #e4e9dd;
  background: #eff2e9;
  color: #8d9d85;
}

.attendance-widget .attendance-note {
  margin: 7px 0 0;
  color: #a09b85;
  font-size: 9px;
  line-height: 1.8;
  text-align: center;
}

.attendance-widget .attendance-feedback {
  margin: 9px 0 0;
  padding: 7px 8px;
  border-radius: 6px;

  background: #eaf2e8;
  color: #477451;

  font-size: 10px;
  line-height: 1.7;
}

.attendance-widget .attendance-feedback.is-error {
  background: #fff0e9;
  color: #aa6558;
}

.attendance-widget [hidden] {
  display: none !important;
}

@media (min-width: 1800px) {
  .attendance-widget .attendance-day {
    font-size: 12px;
  }

  .attendance-widget .attendance-day-number {
    width: 30px;
    height: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .attendance-widget .attendance-day,
  .attendance-widget .attendance-checkin {
    transition: none;
  }
}

/* Hiệu ứng xé lịch */
.attendance-widget {
  position: relative;
  isolation: isolate;
  perspective: 1200px;
}

.attendance-widget > .attendance-rings {
  top: 0;
  z-index: 8;
}

.attendance-widget.is-tearing {
  z-index: 2;
}

.attendance-widget .attendance-turn-sheet {
  position: absolute;
  z-index: 4;

  margin: 0;

  pointer-events: none;
  user-select: none;

  transform-origin: 50% 8px;
  backface-visibility: hidden;

  will-change: transform, opacity;
  contain: layout style;
}

.attendance-widget .attendance-turn-sheet::before {
  content: "";
  position: absolute;
  top: 9px;
  right: 12px;
  left: 12px;

  border-top: 1px dashed #cfc5a980;
  pointer-events: none;
}

.attendance-widget .attendance-turn-sheet.tear-next {
  animation:
    qurio-calendar-tear-next 650ms
    cubic-bezier(0.25, 0.65, 0.25, 1) both;
}

.attendance-widget .attendance-turn-sheet.tear-prev {
  animation:
    qurio-calendar-tear-prev 650ms
    cubic-bezier(0.25, 0.65, 0.25, 1) both;
}

.attendance-widget .attendance-new-sheet {
  animation:
    qurio-calendar-sheet-reveal
    650ms ease-out both;
}

@keyframes qurio-calendar-tear-next {
  0% {
    transform:
      translate3d(0, 0, 0)
      rotateX(0)
      rotateZ(0);

    opacity: 1;
    box-shadow: 0 6px 20px #474b3210;
    clip-path: inset(0 round 18px);
  }

  22% {
    transform:
      translate3d(1px, 10px, 24px)
      rotateX(9deg)
      rotateZ(1deg);

    opacity: 1;
    box-shadow: -5px 16px 24px #474b3228;

    clip-path: polygon(
      0 1%, 4% 0, 8% 1.5%, 12% 0.2%,
      17% 1%, 22% 0, 27% 1.5%, 32% 0,
      37% 1%, 42% 0.2%, 47% 1.5%, 52% 0,
      57% 1%, 62% 0.3%, 67% 1.5%, 72% 0,
      77% 1%, 82% 0.2%, 87% 1.5%, 92% 0,
      96% 1%, 100% 0, 100% 100%, 0 100%
    );
  }

  65% {
    transform:
      translate3d(12px, 66px, 50px)
      rotateX(23deg)
      rotateZ(6deg);

    opacity: 0.88;
    box-shadow: -12px 22px 32px #474b3230;
  }

  100% {
    transform:
      translate3d(28px, 170px, 30px)
      rotateX(38deg)
      rotateZ(12deg);

    opacity: 0;
    box-shadow: -14px 24px 36px #474b3200;

    clip-path: polygon(
      0 1%, 4% 0, 8% 1.5%, 12% 0.2%,
      17% 1%, 22% 0, 27% 1.5%, 32% 0,
      37% 1%, 42% 0.2%, 47% 1.5%, 52% 0,
      57% 1%, 62% 0.3%, 67% 1.5%, 72% 0,
      77% 1%, 82% 0.2%, 87% 1.5%, 92% 0,
      96% 1%, 100% 0, 100% 100%, 0 100%
    );
  }
}

@keyframes qurio-calendar-tear-prev {
  0% {
    transform:
      translate3d(0, 0, 0)
      rotateX(0)
      rotateZ(0);

    opacity: 1;
    box-shadow: 0 6px 20px #474b3210;
    clip-path: inset(0 round 18px);
  }

  22% {
    transform:
      translate3d(-1px, 10px, 24px)
      rotateX(9deg)
      rotateZ(-1deg);

    opacity: 1;
    box-shadow: 5px 16px 24px #474b3228;

    clip-path: polygon(
      0 0, 4% 1%, 8% 0, 12% 1.5%,
      17% 0.2%, 22% 1%, 27% 0, 32% 1.5%,
      37% 0.3%, 42% 1%, 47% 0, 52% 1.5%,
      57% 0.2%, 62% 1%, 67% 0, 72% 1.5%,
      77% 0, 82% 1%, 87% 0.2%, 92% 1.5%,
      96% 0, 100% 1%, 100% 100%, 0 100%
    );
  }

  65% {
    transform:
      translate3d(-12px, 66px, 50px)
      rotateX(23deg)
      rotateZ(-6deg);

    opacity: 0.88;
    box-shadow: 12px 22px 32px #474b3230;
  }

  100% {
    transform:
      translate3d(-28px, 170px, 30px)
      rotateX(38deg)
      rotateZ(-12deg);

    opacity: 0;
    box-shadow: 14px 24px 36px #474b3200;

    clip-path: polygon(
      0 0, 4% 1%, 8% 0, 12% 1.5%,
      17% 0.2%, 22% 1%, 27% 0, 32% 1.5%,
      37% 0.3%, 42% 1%, 47% 0, 52% 1.5%,
      57% 0.2%, 62% 1%, 67% 0, 72% 1.5%,
      77% 0, 82% 1%, 87% 0.2%, 92% 1.5%,
      96% 0, 100% 1%, 100% 100%, 0 100%
    );
  }
}

@keyframes qurio-calendar-sheet-reveal {
  0% {
    opacity: 0.6;
    transform: translateY(-3px);
  }

  55%,
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .attendance-widget .attendance-turn-sheet,
  .attendance-widget .attendance-new-sheet {
    animation: none !important;
  }
}