/**
 * components.css — UI 컴포넌트 디자인 스타일링
 * Gemini 3.5 Flash 담당: 아름다운 미학과 생동감 있는 인터랙션 구현
 */

/* ─────────────────────────────────────────────
   페이지 레이아웃 공통
   ───────────────────────────────────────────── */
.page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.3s ease-out;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-bottom: 4px;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.8px;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: -0.3px;
}

.chevron {
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 300;
  transition: var(--transition-bounce);
}

/* ─────────────────────────────────────────────
   아바타 (Avatar)
   ───────────────────────────────────────────── */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), #C4C1FF);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.avatar--lg {
  width: 76px;
  height: 76px;
  font-size: 28px;
  background: linear-gradient(135deg, var(--primary-color), #8F88FF);
  color: white;
  box-shadow: 0 8px 20px rgba(108, 99, 255, 0.2);
}

/* ─────────────────────────────────────────────
   버튼 컴포넌트 (Buttons)
   ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  outline: none;
  cursor: pointer;
  font-weight: 700;
  border-radius: var(--radius-md);
  transition: var(--transition-bounce);
  gap: 6px;
  text-decoration: none;
}

/* 기본 크기 */
.btn:not(.btn--icon):not(.btn--sm) {
  padding: 16px 24px;
  font-size: 15px;
}

/* 호버 & 활성화 시 효과 */
.btn:hover {
  transform: translateY(-2px);
}
.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary-color), #8F88FF);
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(108, 99, 255, 0.2);
}
.btn--primary:hover {
  box-shadow: 0 12px 20px rgba(108, 99, 255, 0.3);
}

.btn--ghost {
  background-color: var(--primary-light);
  color: var(--primary-dark);
}
.btn--ghost:hover {
  background-color: #E2E0FF;
}

.btn--danger {
  background: linear-gradient(135deg, var(--danger-color), #FF7A95);
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(255, 79, 112, 0.2);
}

.btn--sm {
  padding: 8px 14px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn--full {
  width: 100%;
}

.btn--icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: white;
  color: var(--text-primary);
  font-size: 18px;
  box-shadow: var(--shadow-sm);
}
.btn--icon:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.btn--back {
  font-size: 24px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─────────────────────────────────────────────
   입력창 & 폼 (Inputs & Forms)
   ───────────────────────────────────────────── */
.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.required {
  color: var(--danger-color);
  font-weight: bold;
}

.input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border-color);
  background-color: white;
  border-radius: var(--radius-md);
  outline: none;
  font-size: 16px;
  color: var(--text-primary);
  transition: var(--transition-smooth);
}

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

.input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.08);
}

.input--textarea {
  resize: none;
  min-height: 100px;
  line-height: 1.5;
}

.input--select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234B5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  padding-right: 40px;
}

.input-with-suffix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-suffix .input {
  padding-right: 36px;
}

.input-suffix {
  position: absolute;
  right: 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
  pointer-events: none;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.form-hint {
  font-size: 12px;
  color: var(--primary-color);
  text-decoration: none;
  align-self: flex-end;
  font-weight: 600;
  transition: var(--transition-smooth);
}
.form-hint:hover {
  text-decoration: underline;
}

/* ─────────────────────────────────────────────
   칩 & 라디오 버튼 (Chips & Chip Radios)
   ───────────────────────────────────────────── */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  background-color: white;
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-bounce);
  box-shadow: var(--shadow-sm);
  outline: none;
}

.chip:hover {
  border-color: var(--border-focus);
}

.chip--active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white !important;
  font-weight: 700;
  box-shadow: var(--shadow-active);
}

.chip--sm {
  padding: 6px 12px;
  font-size: 11px;
  border-radius: var(--radius-sm);
}

.chip-radio {
  cursor: pointer;
}

.chip-radio input[type="radio"] {
  display: none;
}

.chip-radio input[type="radio"]:checked + .chip {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
  box-shadow: var(--shadow-active);
}

/* ─────────────────────────────────────────────
   요약 카드 (Summary Card — 대시보드)
   ───────────────────────────────────────────── */
.summary-card {
  background: linear-gradient(135deg, var(--primary-dark), #8F88FF);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: white;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  overflow: hidden;
}

/* 요약 카드에 매끄러운 원형 기하학 무늬 추가 */
.summary-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.summary-card__balance {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-card__label {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
  letter-spacing: 0.5px;
}

.summary-card__amount {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.summary-card__details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px 6px;
  backdrop-filter: blur(10px);
}

.summary-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.summary-detail:not(:last-child) {
  border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.summary-detail__label {
  font-size: 10px;
  opacity: 0.9;
  font-weight: 500;
}

.summary-detail__value {
  font-size: 13px;
  font-weight: 700;
}

/* 수지 흑자/적자 상태 컬러링 */
.balance--positive .summary-card__amount {
  color: #FFFFFF;
}
.balance--negative .summary-card__amount {
  color: #FFE6EB;
}

/* ─────────────────────────────────────────────
   리스트 아이템 & 카드 (List Items & Cards)
   ───────────────────────────────────────────── */
.event-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-bounce);
  cursor: pointer;
  border: 1px solid transparent;
}
.event-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.event-card__left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.event-card__name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.event-card__meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.event-card__date {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 2px;
}

.event-card__memo {
  font-size: 11px;
  color: var(--text-muted);
}

.event-card__amount {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.event-tag {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  background-color: var(--primary-light);
  color: var(--primary-dark);
}

/* 금액별 방향 스타일 */
.amount--given {
  color: var(--danger-color);
}

.amount--received {
  color: var(--success-dark);
}

/* ─────────────────────────────────────────────
   연락처 리스트 & 검색 (Contact Screen)
   ───────────────────────────────────────────── */
.search-bar {
  position: relative;
}

.input--search {
  padding-left: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 16px center;
  background-size: 18px;
}

.person-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.person-row {
  display: flex;
  align-items: center;
  background-color: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-bounce);
  border: 1px solid transparent;
}

.person-row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.person-row:hover .chevron {
  transform: translateX(3px) scale(1.1);
  color: var(--primary-color);
}

.person-row__info {
  flex: 1;
  margin-left: 14px;
}

.person-row__name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.person-row__meta {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ─────────────────────────────────────────────
   연락처 상세 카드 (Person Details)
   ───────────────────────────────────────────── */
.person-card {
  display: flex;
  align-items: center;
  background-color: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 20px;
  gap: 18px;
  box-shadow: var(--shadow-sm);
}

.person-card__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.person-card__name {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.person-card__meta {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.person-card__phone {
  font-size: 13px;
  color: var(--primary-color);
  font-weight: 600;
  margin-top: 4px;
}

.person-card__memo {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* ─────────────────────────────────────────────
   수지 카드 (Balance Card — 상세화면)
   ───────────────────────────────────────────── */
.balance-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--border-color);
}

.balance-card__message {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  line-height: 1.5;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border-color);
}

.balance-card__details {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}

.balance-card__details div strong {
  font-size: 15px;
  margin-left: 4px;
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────
   AI 금액 추천 섹션 (Recommendation Engine UI)
   ───────────────────────────────────────────── */
.recommend-section {
  background-color: #F3F1FF;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1.5px solid #E3DDFF;
}

.recommend-section .section-title {
  color: var(--primary-dark);
}

.recommend-type-selector {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

/* 스크롤바 가리기 */
.recommend-type-selector::-webkit-scrollbar {
  display: none;
}

.recommend-result {
  background-color: white;
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.recommend-amount {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary-color);
  letter-spacing: -0.5px;
}

.recommend-reason {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  text-align: center;
  word-break: keep-all;
}

.recommend-options {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  width: 100%;
}

.recommend-options .chip {
  padding: 8px 14px;
  font-size: 12px;
}

/* ─────────────────────────────────────────────
   설정 화면 스타일 (Settings)
   ───────────────────────────────────────────── */
.settings-info {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition-bounce);
  width: 100%;
  outline: none;
}

.settings-row:not(.settings-row--static):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.settings-row--label {
  display: flex;
  margin: 0;
}

.settings-row--static {
  cursor: default;
  background-color: rgba(255, 255, 255, 0.6);
  box-shadow: none;
  border-color: var(--border-color);
}

.settings-row--static span:last-child {
  color: var(--text-secondary);
  font-weight: 700;
}

/* ─────────────────────────────────────────────
   시스템 알림 UI (Toast & Confirm Modal)
   ───────────────────────────────────────────── */

/* 토스트 피드백 */
.toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, 20px);
  max-width: 480px;
  width: calc(100% - 40px);
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 700;
  color: white;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: var(--transition-bounce), opacity 0.25s ease;
  white-space: nowrap;
}

.toast--success {
  background: rgba(0, 210, 160, 0.95);
  backdrop-filter: blur(10px);
}

.toast--error {
  background: rgba(255, 79, 112, 0.95);
  backdrop-filter: blur(10px);
}

.toast--visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

/* 확인 모달 다이얼로그 */
#confirm-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
}

#confirm-modal.modal--visible {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(31, 41, 55, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: calc(100% - 40px);
  max-width: 360px;
  background-color: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transition: var(--transition-bounce);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#confirm-modal.modal--visible .modal-box {
  transform: translate(-50%, -50%) scale(1);
}

.modal-message {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.5;
  text-align: center;
  word-break: keep-all;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn {
  flex: 1;
}

/* ─────────────────────────────────────────────
   상태 & 유틸리티 클래스
   ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
  padding: 40px 20px;
  background-color: rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
}

.quick-amounts {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.error-screen {
  padding: 40px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--danger-color);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

/* ─────────────────────────────────────────────
   필터 탭 (Filter Tabs)
   ───────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 6px;
  background: white;
  border-radius: var(--radius-lg);
  padding: 4px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.filter-tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  outline: none;
}

.filter-tab--active {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 4px 10px rgba(108, 99, 255, 0.25);
}

/* ─────────────────────────────────────────────
   정렬 바 (Sort Bar)
   ───────────────────────────────────────────── */
.sort-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sort-select {
  appearance: none;
  background-color: white;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 30px 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────
   통계 화면 (Stats Screen)
   ───────────────────────────────────────────── */
.stats-total {
  background: linear-gradient(135deg, var(--primary-dark), #8F88FF);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-lg);
}

.stats-total__label {
  font-size: 12px;
  opacity: 0.85;
  font-weight: 600;
  margin-bottom: 4px;
}

.stats-total__value {
  font-size: 22px;
  font-weight: 800;
}

.stats-year-block {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.stats-year-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--primary-light);
  border-bottom: 1px solid rgba(108,99,255,0.1);
}

.stats-year-header__year {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary-dark);
}

.stats-year-header__summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.stats-month-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition-smooth);
  cursor: pointer;
}

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

.stats-month-item:hover {
  background: var(--bg-secondary);
}

.stats-month-item__label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.stats-month-item__count {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.stats-month-item__amounts {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stats-month-item__given {
  font-size: 13px;
  font-weight: 700;
  color: var(--danger-color);
}

.stats-month-item__received {
  font-size: 13px;
  font-weight: 700;
  color: var(--success-dark);
}

.stats-filter-bar {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  margin-bottom: 4px;
}

.stats-select {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  background-color: white;
}

