/* ============================================
   TIMECARD APP — iOS Style
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg:            #1C1C1E;
  --bg2:           #2C2C2E;
  --bg3:           #3A3A3C;
  --surface:       #2C2C2E;
  --surface2:      #3A3A3C;
  --label:         #FFFFFF;
  --label2:        rgba(255,255,255,0.60);
  --label3:        rgba(255,255,255,0.35);
  --separator:     rgba(255,255,255,0.10);
  --accent-blue:   #0A84FF;
  --accent-green:  #30D158;
  --accent-orange: #FF9F0A;
  --accent-red:    #FF453A;
  --accent-teal:   #5AC8FA;
  --radius-lg:     18px;
  --radius-md:     12px;
  --radius-sm:     8px;
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --safe-top:      env(safe-area-inset-top, 44px);
  --safe-bottom:   env(safe-area-inset-bottom, 20px);
  --nav-h:         56px;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ── Screens ────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transform: translateX(30px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateX(0);
}
.screen.slide-out {
  opacity: 0;
  transform: translateX(-30px);
}

/* ── iOS Navigation Bar ─────────────────────── */
.ios-nav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(var(--nav-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 8px;
  padding-right: 8px;
  background: rgba(28, 28, 30, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--separator);
  flex-shrink: 0;
  z-index: 10;
}
.nav-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--label);
  letter-spacing: -0.2px;
}
.nav-btn {
  position: absolute;
  bottom: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  color: var(--accent-blue);
  background: none;
  border: none;
  font-size: 17px;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}
.nav-btn:active { opacity: 0.5; }
.nav-btn-left  { left: 0; }
.nav-btn-right { right: 0; }
.nav-btn span  { font-size: 17px; }

/* ── Main Content ───────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px calc(var(--safe-bottom) + 20px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Date Card ──────────────────────────────── */
.date-card {
  text-align: center;
  padding: 8px 0 4px;
}
.date-label {
  font-size: 42px;
  font-weight: 300;
  color: var(--label);
  letter-spacing: -1px;
  line-height: 1;
}
.date-weekday {
  font-size: 14px;
  font-weight: 400;
  color: var(--label2);
  margin-top: 4px;
  letter-spacing: 0.2px;
}

/* ── Status Bar ─────────────────────────────── */
.status-bar {
  background: var(--surface);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  overflow: hidden;
}
.status-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 0;
}
.status-divider {
  width: 0.5px;
  height: 20px;
  background: var(--separator);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-work  { background: var(--label3); }
.dot-break { background: var(--label3); }
.dot-work.active  { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.dot-break.active { background: var(--accent-orange); box-shadow: 0 0 8px var(--accent-orange); }
.status-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--label2);
}
.status-text.active { color: var(--label); }

/* ── Time Summary ───────────────────────────── */
.time-summary {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 0.5px solid var(--separator);
}
.time-row:last-child { border-bottom: none; }
.time-row-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--label2);
}
.time-row-value {
  font-size: 17px;
  font-weight: 400;
  color: var(--label);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}
.time-row-value.recorded {
  color: var(--label);
}

/* ── Buttons ────────────────────────────────── */
.btn-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}
.ios-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 20px 24px;
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font);
  font-size: 19px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
  position: relative;
  overflow: hidden;
  letter-spacing: -0.3px;
}
.ios-btn:active {
  transform: scale(0.97);
  opacity: 0.85;
}
.ios-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.ios-btn:disabled:active { transform: none; }

.btn-work {
  background: linear-gradient(135deg, #1A6AFF 0%, #0A84FF 100%);
  color: #fff;
  box-shadow: 0 4px 24px rgba(10, 132, 255, 0.35);
}
.btn-work.state-out {
  background: linear-gradient(135deg, #FF3B30 0%, #FF453A 100%);
  box-shadow: 0 4px 24px rgba(255, 69, 58, 0.35);
}
.btn-work.state-done {
  background: var(--surface);
  box-shadow: none;
  color: var(--label2);
}

.btn-break {
  background: linear-gradient(135deg, #FF9500 0%, #FF9F0A 100%);
  color: #fff;
  box-shadow: 0 4px 24px rgba(255, 159, 10, 0.35);
}
.btn-break.state-end {
  background: linear-gradient(135deg, #30C840 0%, #30D158 100%);
  box-shadow: 0 4px 24px rgba(48, 209, 88, 0.35);
}

.btn-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Live Clock ─────────────────────────────── */
.live-clock {
  text-align: center;
  font-size: 13px;
  font-weight: 400;
  color: var(--label3);
  font-variant-numeric: tabular-nums;
  padding-bottom: 8px;
}

/* ── Calendar Content ───────────────────────── */
.calendar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(var(--safe-bottom) + 16px);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Month Navigation ───────────────────────── */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 16px;
}
.month-label {
  font-size: 20px;
  font-weight: 600;
  color: var(--label);
  letter-spacing: -0.3px;
}
.month-nav-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--surface);
  border-radius: 50%;
  color: var(--accent-blue);
  cursor: pointer;
  transition: opacity 0.15s;
}
.month-nav-btn:active { opacity: 0.5; }

/* ── Calendar Grid ──────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
}
.cal-header {
  margin-bottom: 4px;
}
.cal-dow {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--label2);
  padding: 4px 0 8px;
  letter-spacing: 0.3px;
}
.cal-dow.sun { color: var(--accent-red); }
.cal-dow.sat { color: var(--accent-blue); }

.cal-days {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 2px 6px;
  cursor: pointer;
  min-height: 52px;
  border-right: 0.5px solid var(--separator);
  border-bottom: 0.5px solid var(--separator);
  transition: background 0.15s;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.empty { cursor: default; background: transparent; }
.cal-cell:not(.empty):active { background: var(--surface2); }

.cal-day-num {
  font-size: 15px;
  font-weight: 500;
  color: var(--label);
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.cal-cell.today .cal-day-num {
  background: var(--accent-blue);
  color: #fff;
  font-weight: 700;
}
.cal-cell.selected .cal-day-num {
  background: var(--surface2);
  outline: 2px solid var(--accent-blue);
}
.cal-cell.today.selected .cal-day-num {
  background: var(--accent-blue);
  outline: 2px solid rgba(255,255,255,0.5);
}
.cal-cell.sun .cal-day-num { color: var(--accent-red); }
.cal-cell.sat .cal-day-num { color: var(--accent-blue); }
.cal-cell.today .cal-day-num,
.cal-cell.today.sun .cal-day-num,
.cal-cell.today.sat .cal-day-num { color: #fff; }

.cal-dot-row {
  display: flex;
  gap: 2px;
  margin-top: 3px;
}
.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.dot-in    { background: var(--accent-blue); }
.dot-out   { background: var(--accent-red); }
.dot-brk   { background: var(--accent-orange); }

/* ── Detail Panel ───────────────────────────── */
.detail-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.detail-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--label2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 14px 18px 10px;
  border-bottom: 0.5px solid var(--separator);
}
.detail-rows {
  padding: 4px 0;
}
.detail-empty {
  text-align: center;
  font-size: 15px;
  color: var(--label3);
  padding: 24px 0;
}
.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 0.5px solid var(--separator);
}
.detail-row:last-child { border-bottom: none; }
.detail-row-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--label2);
}
.detail-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.detail-row-value {
  font-size: 17px;
  font-weight: 400;
  color: var(--label);
  font-variant-numeric: tabular-nums;
}

/* ── Toast ──────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 30px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(44, 44, 46, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--label);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  border: 0.5px solid var(--separator);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Modal ──────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}
.modal-card {
  background: var(--bg2);
  border-radius: 14px;
  width: 100%;
  max-width: 320px;
  overflow: hidden;
  transform: scale(0.93);
  transition: transform 0.2s ease;
}
.modal-overlay.show .modal-card {
  transform: scale(1);
}
.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--label);
  text-align: center;
  padding: 20px 20px 8px;
}
.modal-body {
  font-size: 14px;
  color: var(--label2);
  text-align: center;
  padding: 4px 20px 20px;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  border-top: 0.5px solid var(--separator);
}
.modal-btn {
  flex: 1;
  padding: 14px 0;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 17px;
  cursor: pointer;
  transition: background 0.15s;
}
.modal-btn:active { background: var(--surface2); }
.modal-cancel {
  color: var(--label2);
  border-right: 0.5px solid var(--separator);
}
.modal-ok {
  color: var(--accent-blue);
  font-weight: 600;
}

/* ── Scrollbar (hide on mobile) ─────────────── */
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

/* ── Ripple Animation ───────────────────────── */
@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  width: 40px;
  height: 40px;
  margin-top: -20px;
  margin-left: -20px;
  animation: ripple 0.5s linear;
  pointer-events: none;
}

/* ── Pulse animation for active states ──────── */
@keyframes pulse-green {
  0%,100% { box-shadow: 0 0 0 0 rgba(48,209,88,0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(48,209,88,0); }
}
.dot-work.active  { animation: pulse-green 2s infinite; }

@keyframes pulse-orange {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,159,10,0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(255,159,10,0); }
}
.dot-break.active { animation: pulse-orange 2s infinite; }

/* ── Nav Right Group ────────────────────────── */
.nav-right-group {
  position: absolute;
  bottom: 0;
  right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
}
.nav-right-group .nav-btn {
  position: static;
  height: var(--nav-h);
  padding: 0 10px;
}

/* ── Notify Screen ───────────────────────────── */
.notify-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(var(--safe-bottom) + 16px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Segmented Control ───────────────────────── */
.segmented-ctrl {
  display: flex;
  background: var(--surface);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}
.seg-btn {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--label2);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.seg-btn.active {
  background: var(--surface2);
  color: var(--label);
  font-weight: 600;
}

/* ── Notify Panels ───────────────────────────── */
.notify-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}
.notify-panel.active { display: flex; }

/* ── Notify Card ─────────────────────────────── */
.notify-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.notify-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 0.5px solid var(--separator);
}
.notify-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--label);
}
.notify-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.notify-card-body {
  padding: 0;
}

/* ── Notify Form Rows ────────────────────────── */
.nf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 0.5px solid var(--separator);
  gap: 12px;
}
.nf-row:last-child { border-bottom: none; }
.nf-row.nf-col {
  flex-direction: column;
  align-items: flex-start;
}
.nf-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--label2);
  flex-shrink: 0;
}

/* ── Toggle Switch (iOS style) ───────────────── */
.tog {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
  cursor: pointer;
}
.tog input { opacity: 0; width: 0; height: 0; }
.tog-track {
  position: absolute;
  inset: 0;
  background: var(--surface2);
  border-radius: 99px;
  transition: background 0.2s;
}
.tog-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 25px;
  height: 25px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.tog input:checked + .tog-track { background: var(--accent-green); }
.tog input:checked + .tog-track::after { transform: translateX(20px); }

/* ── Time Picker ─────────────────────────────── */
.time-pick {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border-radius: 10px;
  padding: 6px 10px;
}
.tnum {
  width: 42px;
  background: none;
  border: none;
  color: var(--label);
  font-family: var(--font);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}
.tnum::-webkit-inner-spin-button,
.tnum::-webkit-outer-spin-button { -webkit-appearance: none; }
.tcolon {
  font-size: 20px;
  font-weight: 600;
  color: var(--label2);
}

/* ── Day Picker ──────────────────────────────── */
.day-pick {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
  width: 100%;
}
.day-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  color: var(--label3);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.day-btn.on {
  background: var(--accent-blue);
  color: #fff;
}
.day-btn:active { opacity: 0.7; }

/* ── Notify Textarea ─────────────────────────── */
.nf-textarea {
  width: 100%;
  margin-top: 6px;
  background: var(--surface2);
  border: none;
  border-radius: 10px;
  color: var(--label);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 12px;
  resize: none;
  min-height: 60px;
  outline: none;
  line-height: 1.5;
  user-select: text;
}
.nf-textarea::placeholder { color: var(--label3); }
