/* ═══════════════════════════════════════════
   Anwesenheit — Office Presence Tracker
   ═══════════════════════════════════════════ */

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/nunito-latin-400.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/nunito-latinext-400.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: inherit;
}

:root {
  --bg: #0c0c14;
  --surface: #16162a;
  --surface-hover: #1e1e3a;
  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.35);
  --accent-light: #a29bfe;
  --teal: #00cec9;
  --teal-glow: rgba(0, 206, 201, 0.25);
  --pink: #fd79a8;
  --orange: #e17055;
  --danger: #ff6b6b;
  --success: #51cf66;
  --text: #eef0ff;
  --text-dim: #7a7a9e;
  --border: rgba(255, 255, 255, 0.07);
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(108, 92, 231, 0.2) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(0, 206, 201, 0.12) 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  min-height: 100dvh;
}

/* ── Login ────────────────────────────────── */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}

.login-container {
  background: var(--surface);
  padding: 40px 40px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
  width: 100%;
  max-width: 420px;
  height: 420px;
  display: flex;
  flex-direction: column;
  margin: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 60px rgba(108, 92, 231, 0.08);
}

.login-container h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 32px;
  background: linear-gradient(135deg, var(--teal), var(--accent-light), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-field input {
  width: 100%;
  padding: 15px;
  font-size: 17px;
  height: 52px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
  border-color: var(--teal);
  box-shadow: none;
  outline: none;
}


.login-button {
  display: block;
  width: 100%;
  padding: 15px;
  height: 52px;
  margin: 16px 0 0;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: filter 0.2s, transform 0.1s;
}

.login-button:hover { filter: brightness(1.15); }
.login-button:active { transform: scale(0.98); }

/* ── Card layout (shared) ─────────────────── */

.card-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-flash {
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-flash .alert {
  color: var(--danger);
  font-weight: 600;
  font-size: 14px;
  margin: 0;
}

.card-flash .flash-success {
  color: var(--success);
  font-weight: 600;
  font-size: 14px;
  margin: 0;
}

.alert {
  color: var(--danger);
  margin-bottom: 16px;
  font-weight: 500;
  font-size: 14px;
}

.lock-hint {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-button-lock {
  background: none;
  background-color: var(--danger);
}

.cancel-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  margin-top: 10px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  text-decoration: none;
  text-align: center;
  transition: background 0.2s, color 0.2s;
}

.cancel-link:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }

/* ── Dashboard ────────────────────────────── */

.dashboard {
  max-width: 100vw;
  height: 100dvh;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.header-left h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dashboard-date {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 2px;
}

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

.total-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.total-count {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--teal), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-link {
  padding: 4px 12px;
  font-size: 14px;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: color 0.2s, border-color 0.2s;
}

.header-link:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

.logout-button {
  padding: 4px 12px;
  font-size: 14px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}

.logout-button:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ── Button Grid ──────────────────────────── */

.bu-grid {
  display: grid;
  gap: 10px;
  flex: 1;
  margin-top: 12px;
  /* Default: 5 columns x 4 rows (landscape) */
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(4, 1fr);
}

.bu-item {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

/* Portrait / narrower: 4 columns x 5 rows */
@media (max-aspect-ratio: 4/3) and (min-width: 500px) {
  .bu-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(5, 1fr);
  }
}

/* Narrow / phone: 2 columns x 10 rows */
@media (max-width: 499px) {
  .bu-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(10, 1fr);
  }
}

/* ── Shared card layout ───────────────────── */

.bu-button,
.bu-card-edit {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 2px;
  padding: 12px 14px;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  text-align: left;
  min-height: 0;
}

/* ── BU Button (normal mode) ──────────────── */

.bu-button {
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.3s, transform 0.12s;
}

/* Subtle gradient shimmer on each card */
.bu-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.06) 0%, rgba(0, 206, 201, 0.04) 50%, rgba(253, 121, 168, 0.04) 100%);
  pointer-events: none;
}

.bu-button:hover {
  background: var(--surface-hover);
  border-color: rgba(108, 92, 231, 0.3);
  box-shadow: 0 4px 24px rgba(108, 92, 231, 0.15), 0 0 12px rgba(0, 206, 201, 0.08);
}

.bu-button:active {
  transform: scale(0.97);
}

.bu-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-dim);
  align-self: start;
  word-break: break-word;
  hyphens: auto;
}

.bu-button .bu-count {
  font-size: 40px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  align-self: end;
  justify-self: start;
  display: inline-block;
  background: linear-gradient(135deg, #fff, var(--teal), var(--accent-light));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Cooldown ─────────────────────────────── */

.bu-button .bu-cooldown-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--teal), var(--pink));
  border-radius: 0 3px 0 0;
}

.bu-button.cooling-down {
  pointer-events: none;
  border-color: rgba(108, 92, 231, 0.25);
  box-shadow:
    0 0 30px var(--accent-glow),
    0 0 15px var(--teal-glow),
    inset 0 0 30px rgba(108, 92, 231, 0.04);
}

.bu-button.cooling-down .bu-cooldown-bar {
  animation: cooldown-bar 3s linear forwards;
}

@keyframes cooldown-bar {
  from { width: 100%; }
  to { width: 0%; }
}

.bu-button.cooling-down .bu-count {
  animation: count-pop 0.35s ease-out;
  transform-origin: center center;
}

@keyframes count-pop {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: scale(1.35); opacity: 0.8; }
  60% { transform: scale(0.95); opacity: 1; }
  100% { transform: scale(1); }
}

/* ── Undo state (button becomes the undo button) ── */

.bu-undo-icon {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  font-size: 32px;
  color: #fff;
  pointer-events: none;
}

.bu-button.undo-state {
  background: #2d2450 !important;
  border-color: #4a3a7a !important;
  box-shadow: 0 0 24px rgba(74, 58, 122, 0.3);
  cursor: pointer;
  pointer-events: auto !important;
  opacity: 1 !important;
}

.bu-button.undo-state .bu-name { color: rgba(255, 255, 255, 0.4); }

.bu-button.undo-state .bu-count {
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.3);
  background-clip: unset;
}

.bu-button.undo-state .bu-undo-icon {
  display: grid;
  position: absolute;
  inset: 0;
  place-items: center;
  font-size: 36px;
  color: rgba(255, 255, 255, 0.6);
  animation: undo-pop 0.25s ease-out;
}

@keyframes undo-pop {
  from { transform: rotate(-180deg); opacity: 0; }
  to { transform: rotate(0deg); opacity: 1; }
}

/* ── Edit mode toggle ─────────────────────── */

.bu-card-edit { display: none; }

.bu-item.editing .bu-button-normal { display: none; }
.bu-item.editing .bu-card-edit {
  display: grid;
  background: var(--surface);
  border: 1px solid rgba(0, 206, 201, 0.25);
  animation: edit-in 0.2s ease-out;
}

.bu-item.editing .bu-card-edit .stepper {
  align-self: end;
  justify-self: center;
  flex-shrink: 1;
}

@keyframes edit-in {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

/* ── Stepper ──────────────────────────────── */

.stepper {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}

.stepper-btn {
  width: 44px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.stepper-minus { border-right: 1px solid var(--border); }
.stepper-plus { border-left: 1px solid var(--border); }

.stepper-btn:hover { background: var(--surface-hover); }
.stepper-btn:active {
  background: var(--teal);
  color: #fff;
  transform: scale(0.95);
}

.stepper-value {
  min-width: 44px;
  padding: 0 4px;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 36px;
}

/* ── Edit button (in grid) ────────────────── */
/* Same grid layout as all cards but visually distinct */

.bu-button-edit {
  background: transparent;
  border: 2px dashed rgba(253, 121, 168, 0.3);
  color: var(--text-dim);
  min-height: 0;
}

.bu-button-edit::before { display: none; }

.bu-button-edit .bu-name {
  color: var(--pink);
  opacity: 0.7;
}

.bu-edit-icon {
  align-self: end;
  justify-self: start;
  color: var(--pink);
  opacity: 0.4;
  transition: opacity 0.2s;
}

.bu-button-edit:hover {
  background: rgba(253, 121, 168, 0.06);
  border-color: rgba(253, 121, 168, 0.5);
  box-shadow: 0 0 20px rgba(253, 121, 168, 0.1);
}

.bu-button-edit:hover .bu-edit-icon { opacity: 0.8; }

/* Active (save mode) */
.bu-button-edit-active {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(0, 206, 201, 0.15)) !important;
  border: 2px solid var(--teal) !important;
  box-shadow: 0 0 30px var(--teal-glow), 0 0 15px var(--accent-glow);
  animation: save-pulse 2s ease-in-out infinite;
}

.bu-button-edit-active .bu-name {
  color: var(--teal) !important;
  opacity: 1;
}

.bu-button-edit-active .bu-edit-icon {
  color: var(--teal);
  opacity: 1;
}

@keyframes save-pulse {
  0%, 100% { box-shadow: 0 0 20px var(--teal-glow), 0 0 10px var(--accent-glow); }
  50% { box-shadow: 0 0 40px var(--teal-glow), 0 0 20px var(--accent-glow); }
}

/* Countdown mode */
.bu-button-edit-countdown {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(225, 112, 85, 0.1)) !important;
  border: 2px solid var(--danger) !important;
  animation: none !important;
  box-shadow: 0 0 30px rgba(255, 107, 107, 0.2);
}

.bu-button-edit-countdown .bu-name { color: var(--danger) !important; }
.bu-button-edit-countdown .bu-edit-icon { display: none; }

.bu-countdown-number {
  display: none;
  font-size: 36px;
  font-weight: 800;
  color: var(--danger);
  align-self: end;
  justify-self: start;
  font-variant-numeric: tabular-nums;
}

.bu-button-edit-countdown .bu-countdown-number { display: block; }

/* ── Export Page ──────────────────────────── */

.export-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}

.export-card {
  background: var(--surface);
  padding: 40px 40px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
  width: 100%;
  max-width: 420px;
  height: 420px;
  display: flex;
  flex-direction: column;
  margin: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.export-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.export-hint {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 28px;
}


.export-field input {
  width: 100%;
  padding: 15px;
  height: 52px;
  font-size: 17px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.export-field input:focus {
  border-color: var(--teal);
  box-shadow: none;
  outline: none;
}

.export-submit {
  display: block;
  width: 100%;
  height: 52px;
  margin: 16px 0 0;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: filter 0.2s, transform 0.1s;
}

.export-submit:hover { filter: brightness(1.15); }
.export-submit:active { transform: scale(0.98); }

.export-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  margin-top: 10px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.export-back:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }

/* ── Responsive font scaling ──────────────── */

@media (min-width: 768px) {
  .bu-name { font-size: 15px; }
  .bu-button .bu-count { font-size: clamp(28px, 4vw, 48px); }
  .stepper-btn { width: 48px; height: 40px; font-size: 22px; }
  .stepper-value { font-size: 24px; min-width: 48px; line-height: 40px; }
}
