/* ── App Theme Overrides ────────────────────────────────────── */

:root {
  --app-primary: #1a1a2e;
  --app-accent: #0f3460;
  --app-punch-in: #16a34a;
  --app-punch-out: #dc2626;
  --app-topnav-height: 56px;
  --app-bottomnav-height: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --app-primary: #e2e8f0;
  --app-accent: #60a5fa;
}


/* ── Global ────────────────────────────────────────────────── */

html, body {
  height: 100%;
  overflow: hidden;
}

.screen {
  height: 100%;
}


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

#screen-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--space-4);
  background: var(--background);
}

.login-container {
  width: 100%;
  max-width: 380px;
}

.login-header {
  margin-bottom: var(--space-8);
}

.login-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-large);
}

.login-header h2 {
  margin: 0 0 var(--space-1) 0;
}

.login-header p {
  margin: 0;
}


/* ── App Shell Layout ──────────────────────────────────────── */

#app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.app-topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: var(--space-3) var(--space-4);
  padding-top: calc(var(--safe-top) + var(--space-3));
  background: var(--card);
  border-bottom: 1px solid var(--border);
  min-height: var(--app-topnav-height);
}

.topnav-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: var(--radius-small);
}

#topnav-user-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--foreground);
  font-weight: var(--font-semibold);
  font-size: var(--text-7);
}

.app-main {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  padding-bottom: calc(var(--app-bottomnav-height) + var(--safe-bottom) + var(--space-4));
}

.app-main h3 {
  margin: 0 0 var(--space-4) 0;
}

.app-bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  justify-content: space-around;
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
}

.bottomnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-2) var(--space-4);
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-size: 0.7rem;
  cursor: pointer;
  transition: color var(--transition-fast);
  border-radius: 0;
}

.bottomnav-item:hover,
.bottomnav-item:active {
  background: none;
  transform: none;
}

.bottomnav-item.active {
  color: var(--primary);
}


/* ── Punch Card ────────────────────────────────────────────── */

.home-content {
  max-width: 420px;
  margin: 0 auto;
}

.punch-card {
  padding: var(--space-8) var(--space-6);
}

.punch-status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.punch-status-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--muted-foreground);
  transition: background var(--transition);
}

.punch-status-dot.checked-in {
  background: var(--app-punch-in);
  box-shadow: 0 0 8px rgba(22, 163, 74, 0.5);
}

.punch-status-dot.checked-out {
  background: var(--muted-foreground);
}

.punch-hours {
  font-size: var(--text-1);
  font-weight: var(--font-bold);
  line-height: 1.2;
}

.punch-btn-wrap {
  display: flex;
  justify-content: center;
}

.punch-btn {
  width: 130px;
  height: 130px;
  border-radius: var(--radius-full);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--text-5);
  font-weight: var(--font-semibold);
  color: #fff;
  border: 4px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background-color 0.2s;
  background: var(--app-punch-in);
  box-shadow: 0 4px 20px rgba(22, 163, 74, 0.35);
}

.punch-btn:hover:not(:disabled) {
  background: var(--app-punch-in);
  transform: scale(1.05);
}

.punch-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.punch-btn.checked-in {
  background: var(--app-punch-out);
  box-shadow: 0 4px 20px rgba(220, 38, 38, 0.35);
}

.punch-btn.checked-in:hover:not(:disabled) {
  background: var(--app-punch-out);
}

.punch-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.punch-btn-icon {
  font-size: 2rem;
  line-height: 1;
}

.punch-btn-label {
  font-size: var(--text-7);
}


/* ── Stats Row ─────────────────────────────────────────────── */

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.stat-card {
  padding: var(--space-4);
  text-align: center;
}

.stat-card strong {
  font-size: var(--text-4);
  display: block;
  margin-top: var(--space-1);
}


/* ── History ───────────────────────────────────────────────── */

.history-list {
  min-height: 100px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child {
  border-bottom: none;
}

.history-item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item-date {
  font-weight: var(--font-medium);
  font-size: var(--text-7);
}

.history-item-time {
  font-size: var(--text-8);
  color: var(--muted-foreground);
}

.history-item-hours {
  font-weight: var(--font-semibold);
  font-size: var(--text-7);
}

.history-empty {
  text-align: center;
  padding: var(--space-8) 0;
  color: var(--muted-foreground);
}


/* ── Profile ───────────────────────────────────────────────── */

.profile-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
}

.profile-header h4 {
  margin: 0;
}

.profile-header p {
  margin: 0;
  font-size: var(--text-7);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2);
  font-weight: var(--font-bold);
  color: var(--muted-foreground);
  overflow: hidden;
  flex-shrink: 0;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}


/* ── Install Banner ─────────────────────────────────────────── */

.install-banner {
  margin-top: var(--space-4);
}

.install-banner .card {
  padding: var(--space-3) var(--space-4);
  background: color-mix(in srgb, var(--primary) 8%, var(--background));
}


/* ── Loading States ────────────────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgb(from var(--background) r g b / 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
