/* ============================================================
   COMPONENTS — TimeTracker UI 컴포넌트
   ============================================================ */

/* ── AppHeader ───────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-4);
  background: var(--color-bg-dark);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header--light {
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
}

.app-header__left,
.app-header__right {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 44px;
}

.app-header__right { justify-content: flex-end; }

.app-header__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.app-header__logo-img {
  height: 40px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  display: block;
}

.app-header__logo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.02em;
}
.app-header__logo-fallback svg {
  flex-shrink: 0;
  color: var(--color-primary);
}

.app-header--brand {
  background: linear-gradient(180deg, rgba(232,228,245,0.98) 0%, rgba(245,242,232,0.98) 100%);
  border-bottom: 1px solid var(--color-border);
}

.app-header--brand .icon-btn {
  color: var(--color-text);
  width: 44px;
  height: 44px;
}

.app-header--brand .icon-btn svg {
  width: 24px;
  height: 24px;
}

.app-header--brand .icon-btn:hover {
  background: var(--color-bg-subtle);
}

.app-header__brand-name {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-black);
  color: var(--color-text-inverse);
  letter-spacing: 0.05em;
  line-height: 1;
}

.app-header__brand-sub {
  font-size: 9px;
  color: rgba(245, 240, 232, 0.5);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 1px;
}

.app-header__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  flex: 1;
  text-align: center;
}

.app-header__title--inverse {
  color: var(--color-text-inverse);
}

/* ── Icon Button ─────────────────────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: var(--radius-lg);
  transition: background var(--transition-fast);
  flex-shrink: 0;
  color: var(--color-text-inverse);
}

.icon-btn:hover  { background: rgba(255,255,255,0.1); }
.icon-btn:active { background: rgba(255,255,255,0.15); }

.icon-btn--dark {
  color: var(--color-text);
}
.icon-btn--dark:hover  { background: var(--color-bg-subtle); }
.icon-btn--dark:active { background: var(--color-border); }

.icon-btn svg { width: 20px; height: 20px; stroke-width: 1.75; }

.icon-btn--sm {
  width: 32px;
  height: 32px;
  color: var(--color-text);
}
.icon-btn--sm svg { width: 16px; height: 16px; }

/* ── Bottom Navigation ───────────────────────────────────── */
.bottom-nav {
  display: flex;
  align-items: stretch;
  height: var(--bottom-nav-height);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--color-bg-dark);
  flex-shrink: 0;
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: rgba(245,240,232,0.4);
  font-size: 9px;
  font-weight: var(--font-weight-bold);
  font-family: var(--font-family);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color var(--transition-fast);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: var(--space-2) 0;
}

.bottom-nav__item:hover { color: rgba(245,240,232,0.7); }
.bottom-nav__item.active { color: var(--color-accent-yellow); }
.bottom-nav__item.active svg { stroke: var(--color-accent-yellow); }

.bottom-nav__item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.75;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-5);
  height: 46px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  font-family: var(--font-family);
  letter-spacing: 0.02em;
  border-radius: var(--radius-lg);
  border: none;
  transition: all var(--transition-fast);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn svg { width: 16px; height: 16px; stroke-width: 2; flex-shrink: 0; }

/* Primary — 딥 레드 */
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-stamp);
}
.btn-primary:hover  { background: var(--color-primary-hover); }

/* Dark */
.btn-dark {
  background: var(--color-bg-dark);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-stamp);
}
.btn-dark:hover { background: var(--color-bg-dark-2); }

/* Secondary */
.btn-secondary {
  background: var(--color-bg-card);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg-subtle); }

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}
.btn-ghost:hover { background: var(--color-primary-light); }

/* Sizes */
.btn-sm   { height: 36px; padding: 0 var(--space-3); font-size: var(--font-size-xs); }
.btn-lg   { height: 52px; font-size: var(--font-size-base); border-radius: var(--radius-xl); }
.btn-full { width: 100%; }

/* ── Bottom CTA ──────────────────────────────────────────── */
.bottom-cta {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
}

.card-dark {
  background: var(--color-bg-dark);
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}

.card-pressable {
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.card-pressable:hover  { box-shadow: var(--shadow-lifted); }
.card-pressable:active { transform: scale(0.99); }

/* ── Form Elements ───────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: var(--space-3);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  color: var(--color-text);
  background: var(--color-bg-card);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  line-height: 1.5;
}

.form-input::placeholder, .form-textarea::placeholder {
  color: var(--color-text-faint);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-helper { font-size: var(--font-size-xs); color: var(--color-text-muted); }
.form-error  { font-size: var(--font-size-xs); color: var(--color-danger); }

/* ── Tag / Badge ─────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* 카테고리별 컬러 태그 (아날로그 형광펜 느낌) */
.tag-default { background: var(--color-bg-subtle); color: var(--color-text-muted); }
.tag-work    { background: #E8F4FD; color: var(--color-accent-blue); }
.tag-study   { background: var(--color-success-light); color: var(--color-accent-green); }
.tag-side    { background: var(--color-warning-light); color: #A07820; }
.tag-health  { background: #FDE8E8; color: #A63030; }
.tag-life    { background: #EDE8F5; color: #6A4A90; }
.tag-rest    { background: var(--color-bg-subtle); color: var(--color-text-muted); }

/* 형광펜 하이라이트 */
.highlight {
  background: linear-gradient(transparent 40%, rgba(232,184,75,0.4) 40%);
  padding: 0 2px;
}

/* ── Section Header ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4) var(--space-2);
}

.section-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-black);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
}

/* ── 시간 기록 아이템 ─────────────────────────────────────── */
.time-entry {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.time-entry:hover { background: var(--color-bg-subtle); }
.time-entry:active { background: var(--color-border); }

.time-entry__color {
  width: 4px;
  height: 40px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.time-entry__body { flex: 1; min-width: 0; }

.time-entry__title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-entry__meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.time-entry__duration {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ── 카테고리 컬러 도트 ──────────────────────────────────── */
.cat-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-dark);
  color: var(--color-text-inverse);
  border-radius: var(--radius-xl);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  box-shadow: var(--shadow-lifted);
  pointer-events: auto;
  animation: toastIn 180ms ease;
  white-space: nowrap;
  border-left: 3px solid var(--color-accent-yellow);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast.toast-out {
  animation: toastOut 180ms ease forwards;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px); }
}

.toast svg { width: 16px; height: 16px; stroke-width: 2; flex-shrink: 0; }
.toast-success { border-left-color: var(--color-success); }
.toast-danger  { border-left-color: var(--color-primary); }

/* ── Modal Sheet ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28,28,28,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: overlayIn 180ms ease;
}

@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal-sheet {
  width: 100%;
  max-width: var(--app-max-width);
  background: var(--color-bg-card);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  padding: var(--space-6) var(--space-4);
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  animation: sheetUp 260ms cubic-bezier(0.34,1.2,0.64,1);
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-handle {
  width: 36px; height: 4px;
  background: var(--color-border-rule);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-5);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-black);
  margin-bottom: var(--space-5);
}

/* ── Progress Bar ────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
  background: var(--color-primary);
}

/* ── Toggle Switch ───────────────────────────────────────── */
.toggle {
  position: relative;
  width: 44px; height: 26px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--color-border-rule);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-base);
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-base);
}
.toggle input:checked ~ .toggle-track { background: var(--color-primary); }
.toggle input:checked ~ .toggle-track .toggle-thumb { transform: translateX(18px); }
.toggle input:focus-visible ~ .toggle-track { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  gap: var(--space-3);
  text-align: center;
}

.empty-state__icon {
  width: 60px; height: 60px;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-2xl);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
}

.empty-state__icon svg { width: 26px; height: 26px; stroke-width: 1.5; }
.empty-state__title { font-size: var(--font-size-base); font-weight: var(--font-weight-bold); }
.empty-state__desc  { font-size: var(--font-size-sm); color: var(--color-text-muted); max-width: 240px; }

/* ── Skeleton ────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg,
    var(--color-bg-subtle) 25%,
    var(--color-border) 50%,
    var(--color-bg-subtle) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-md);
}

/* ── Utility ─────────────────────────────────────────────── */
.flex-row     { display: flex; align-items: center; }
.flex-col     { display: flex; flex-direction: column; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.space-y-3 > * + * { margin-top: var(--space-3); }
.space-y-4 > * + * { margin-top: var(--space-4); }
.min-w-0 { min-width: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.font-bold { font-weight: var(--font-weight-bold); }
.font-black { font-weight: var(--font-weight-black); }
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.text-primary { color: var(--color-primary); }
