/* ==============================
   components.css — 재사용 컴포넌트
   ============================== */

/* ══════════════════════════════
   버튼
══════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-5);
  height: 48px;
  border-radius: var(--border-radius);
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  white-space: nowrap;
}

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

/* 사이즈 */
.btn--sm  { height: 36px; padding: 0 var(--space-4); font-size: var(--text-sm); border-radius: var(--border-radius-sm); }
.btn--lg  { height: 56px; padding: 0 var(--space-6); font-size: var(--text-lg); }
.btn--full { width: 100%; }

/* 타입 */
.btn--primary {
  background: var(--sage);
  color: #fff;
  box-shadow: 0 2px 8px rgba(123, 158, 135, 0.35);
}
.btn--primary:not(:disabled):hover  { background: #6A8E76; }
.btn--primary:not(:disabled):active { background: #5D7E69; }

.btn--secondary {
  background: var(--sage-light);
  color: var(--sage-dark);
}
.btn--secondary:not(:disabled):hover  { background: #B5CEC5; }

.btn--point {
  background: var(--point);
  color: #fff;
  box-shadow: 0 2px 8px rgba(232, 168, 124, 0.35);
}
.btn--point:not(:disabled):hover { background: var(--point-dark); }

.btn--outline {
  background: transparent;
  color: var(--sage);
  border: 1.5px solid var(--sage);
}
.btn--outline:not(:disabled):hover { background: var(--sage-bg); }

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn--ghost:not(:disabled):hover { background: var(--gray-100); color: var(--text-primary); }

.btn--danger {
  background: var(--color-error);
  color: #fff;
}

/* 아이콘 버튼 */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:active { transform: scale(0.93); background: var(--gray-100); }

/* ══════════════════════════════
   폼 인풋
══════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}

.form-label .required {
  color: var(--color-error);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--border-radius);
  font-size: var(--text-base);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.form-textarea {
  height: auto;
  min-height: 100px;
  padding: var(--space-3) var(--space-4);
  resize: vertical;
  line-height: var(--lh-relaxed);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23728F84' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: var(--space-8);
  cursor: pointer;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(123, 158, 135, 0.15);
}

.form-input::placeholder { color: var(--text-tertiary); }

.form-input--error,
.form-select--error {
  border-color: var(--color-error);
}
.form-input--error:focus { box-shadow: 0 0 0 3px rgba(229, 115, 115, 0.15); }

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-error);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 인풋 + 버튼 그룹 */
.input-group {
  display: flex;
  gap: var(--space-2);
}
.input-group .form-input { flex: 1; }

/* ══════════════════════════════
   카드
══════════════════════════════ */
.card {
  background: var(--bg-surface);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card--border {
  border: 1px solid var(--border-light);
  box-shadow: none;
}

.card--hover {
  cursor: pointer;
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}
.card--hover:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-xs);
}

.card-body     { padding: var(--space-4); }
.card-body--sm { padding: var(--space-3); }
.card-body--lg { padding: var(--space-6); }

.card-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-light);
  background: var(--gray-50);
}

/* ══════════════════════════════
   리스트 아이템
══════════════════════════════ */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-fast);
}

.list-item:last-child { border-bottom: none; }
.list-item--clickable { cursor: pointer; }
.list-item--clickable:active { background: var(--gray-50); }

.list-item__avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-full);
  background: var(--sage-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-bold);
  font-size: var(--text-sm);
  color: var(--sage-dark);
  flex-shrink: 0;
}

.list-item__body {
  flex: 1;
  min-width: 0;
}

.list-item__title {
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item__sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 1px;
}

.list-item__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

/* ══════════════════════════════
   랭킹 아이템
══════════════════════════════ */
.rank-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border-radius: var(--border-radius);
  margin-bottom: var(--space-2);
}

.rank-number {
  width: 28px;
  font-size: var(--text-base);
  font-weight: var(--fw-extrabold);
  text-align: center;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.rank-number--1 { color: #D4AC0D; }
.rank-number--2 { color: #8A9BA8; }
.rank-number--3 { color: #B87333; }

.rank-trophy {
  font-size: 1.2em;
}

/* ══════════════════════════════
   경기 카드
══════════════════════════════ */
.match-card {
  background: var(--bg-surface);
  border-radius: var(--border-radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.match-card__teams {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.match-card__team {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.match-card__score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  font-size: var(--text-3xl);
  font-weight: var(--fw-extrabold);
  letter-spacing: -0.03em;
}

.match-card__score-divider {
  font-size: var(--text-lg);
  color: var(--text-tertiary);
  font-weight: var(--fw-light);
}

.score--win  { color: var(--sage-dark); }
.score--lose { color: var(--gray-400); }

.match-card__footer {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ══════════════════════════════
   ELO 변화 표시
══════════════════════════════ */
.elo-change {
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
}
.elo-change--up   { color: var(--color-success); }
.elo-change--down { color: var(--color-error); }
.elo-change--same { color: var(--text-tertiary); }

/* ══════════════════════════════
   스탯 박스
══════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.stat-box {
  background: var(--sage-bg);
  border-radius: var(--border-radius);
  padding: var(--space-3) var(--space-2);
  text-align: center;
}

.stat-box__value {
  font-size: var(--text-xl);
  font-weight: var(--fw-extrabold);
  color: var(--sage-dark);
  letter-spacing: -0.02em;
}

.stat-box__label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ══════════════════════════════
   출석 버튼 (대형)
══════════════════════════════ */
.attendance-btn {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--sage);
  color: #fff;
  font-size: var(--text-base);
  font-weight: var(--fw-bold);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  box-shadow: 0 6px 24px rgba(123, 158, 135, 0.4);
  transition: all var(--transition-fast);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.attendance-btn:active {
  transform: scale(0.94);
  box-shadow: 0 2px 12px rgba(123, 158, 135, 0.3);
}

.attendance-btn--done {
  background: var(--gray-200);
  color: var(--text-secondary);
  box-shadow: none;
  cursor: default;
}

.attendance-btn--closed {
  background: var(--gray-200);
  color: var(--text-tertiary);
  box-shadow: none;
  cursor: not-allowed;
}

/* ══════════════════════════════
   토스트 알림
══════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-4));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - var(--space-8));
  max-width: calc(var(--max-width) - var(--space-8));
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--sage-dark);
  color: #fff;
  border-radius: var(--border-radius);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s ease, toast-out 0.25s ease forwards;
  animation-delay: 0s, 2.75s;
  pointer-events: auto;
}

.toast--success { background: #2A7A50; }
.toast--error   { background: #B03030; }
.toast--warning { background: #9A7A10; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}

/* ══════════════════════════════
   모달
══════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: overlay-in 0.2s ease;
}

.modal-overlay--center {
  align-items: center;
  padding: var(--space-4);
}

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: var(--max-width);
  background: var(--bg-surface);
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  padding: var(--space-6) var(--space-4);
  padding-bottom: calc(var(--space-6) + var(--safe-bottom));
  animation: modal-up 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal--center {
  border-radius: var(--border-radius-lg);
  padding: var(--space-6);
  max-width: 340px;
  text-align: center;
}

@keyframes modal-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin: 0 auto var(--space-4);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-4);
}

/* ══════════════════════════════
   프로그레스 바
══════════════════════════════ */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--gray-100);
  border-radius: var(--border-radius-full);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--sage);
  border-radius: var(--border-radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ══════════════════════════════
   탭 (수평)
══════════════════════════════ */
.tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--border-radius);
  padding: 3px;
  gap: 3px;
}

.tab-item {
  flex: 1;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--border-radius) - 2px);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-item.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-xs);
}

/* ══════════════════════════════
   스위치 (토글)
══════════════════════════════ */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: var(--border-radius-full);
  cursor: pointer;
  transition: background var(--transition-base);
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform var(--transition-base);
}

.switch input:checked + .switch-slider { background: var(--sage); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

/* ══════════════════════════════
   칩 필터
══════════════════════════════ */
.chip-group {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 6px var(--space-3);
  border-radius: var(--border-radius-full);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.chip.active {
  background: var(--sage);
  border-color: var(--sage);
  color: #fff;
}

/* ══════════════════════════════
   알림 배너
══════════════════════════════ */
.banner {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--border-radius);
  font-size: var(--text-sm);
  line-height: var(--lh-relaxed);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.banner--info    { background: #EBF5FB; color: #1B5F80; border-left: 3px solid var(--color-info); }
.banner--success { background: #EAF7EF; color: #1A5C35; border-left: 3px solid var(--color-success); }
.banner--warning { background: #FEF9E7; color: #7B6B10; border-left: 3px solid var(--color-warning); }
.banner--error   { background: #FDEDED; color: #8B1A1A; border-left: 3px solid var(--color-error); }
