/* ═══════════════════════════════════════════════════════
   style.css — 포공 CCC 캠모 나눔순 제작 (모던 웹 테마)
   ═══════════════════════════════════════════════════════ */

/* ── 기본 설정 & 폰트 ─────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --primary: #4361ee;
  --primary-hover: #3a56d4;
  --accent: #f72585;
  --text: #1a1a2e;
  --text-sub: #6c757d;
  --border: #e0e0e0;
  --success: #06d6a0;
  --warning: #ffd166;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.2s cubic-bezier(.4, 0, .2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  font-family: 'Inter', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── 레이아웃 ─────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--primary), #7209b7);
  color: #fff;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(67, 97, 238, 0.3);
}

.app-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.app-header .subtitle {
  font-size: 0.8rem;
  opacity: 0.8;
}

.main-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 600px;
  /* Mobile width constraint for all devices */
  margin: 24px auto;
  padding: 0 16px;
  padding-bottom: 80px;
  /* Space for the bottom fixed action bar */
}

/* ── 카드 공통 ────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 1.15rem;
}

/* ── 컨트롤 바 ────────────────────────────────────── */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.controls-bar input[type="number"] {
  width: 60px;
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  text-align: center;
  transition: border-color var(--transition);
}

.controls-bar input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── 버튼 ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

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

.btn-accent:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-sub);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ── 필터 칩 ──────────────────────────────────────── */
.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  /* Horizontal scrolling on mobile */
  overflow-x: auto;
  padding-bottom: 8px;
  /* space for scrollbar */
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* hide scrollbar for firefox */
}

.filter-chips::-webkit-scrollbar {
  display: none;
  /* hide scrollbar for chrome/safari */
}

.chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--card);
  transition: all var(--transition);
  user-select: none;
}

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

.chip:hover:not(.active) {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── 검색 입력 ────────────────────────────────────── */
.search-box {
  width: 100%;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 12px;
  transition: border-color var(--transition);
}

.search-box:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── 멤버 리스트 ──────────────────────────────────── */
.member-list {
  list-style: none;
  max-height: 55vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.member-item:hover {
  background: rgba(67, 97, 238, 0.06);
}

.member-item.checked {
  background: rgba(67, 97, 238, 0.08);
}

.member-item .checkbox {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all var(--transition);
  flex-shrink: 0;
}

.member-item.checked .checkbox {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.member-item .name {
  font-weight: 500;
  font-size: 0.9rem;
  flex: 1;
}

.member-item .role-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(67, 97, 238, 0.1);
  color: var(--primary);
}

/* ── 출석 카운터 ──────────────────────────────────── */
.attendance-counter {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-sub);
  margin: 10px 0 6px;
}

.attendance-counter strong {
  color: var(--primary);
  font-size: 1.1rem;
}

/* ── 결과 영역 ────────────────────────────────────── */
.results-area {
  min-height: 200px;
}

.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-sub);
  font-size: 0.95rem;
  gap: 12px;
}

.result-placeholder .big-icon {
  font-size: 3rem;
  opacity: 0.4;
}

.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.group-card {
  background: linear-gradient(145deg, #f8f9ff, #ffffff);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--transition);
  animation: fadeInUp 0.3s ease-out both;
}

.group-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(67, 97, 238, 0.12);
}

.group-card .group-header {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.group-card .group-header .group-number {
  background: var(--primary);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.group-card .member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.88rem;
}

.group-card .member-row .emoji {
  font-size: 0.9rem;
}

/* ── 토스트 알림 ──────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease-out, fadeOut 0.3s ease-in 2.5s forwards;
}

.toast.success {
  background: var(--success);
}

.toast.info {
  background: var(--primary);
}

.toast.error {
  background: var(--accent);
}

/* ── 하단 바 ──────────────────────────────────────── */
.bottom-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  max-width: 1200px;
  margin: 0 auto 30px;
  padding: 0 24px;
}

/* ── 드래그 & 드롭 영역 ──────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: var(--text-sub);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 14px;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(67, 97, 238, 0.04);
  color: var(--primary);
}

/* ── 모달 ─────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  animation: fadeInUp 0.25s ease-out;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1.5px solid var(--border);
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

/* ── 역할별 색상 시스템 ───────────────────────────── */
.role-color-대표 {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

.role-color-머리순장 {
  background: #fef3c7;
  color: #d97706;
  border-color: #fcd34d;
}

.role-color-순장 {
  background: #dbeafe;
  color: #2563eb;
  border-color: #93c5fd;
}

.role-color-순원 {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #86efac;
}

.role-color-기타 {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #d1d5db;
}

/* ── 멤버 관리 모달: 컴팩트 플렉스 레이아웃 ──────────── */
.mgr-member-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  align-content: flex-start;
  padding-right: 4px;
}

.mgr-member-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 0.85rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  transition: all 0.2s;
}

.mgr-member-card:hover {
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
  border-color: #b0b8c4;
}

.mgr-member-card .mgr-name {
  font-weight: 600;
  width: 50px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.mgr-member-card select {
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  min-width: 65px;
  text-align: center;
  appearance: none;
}

.mgr-delete-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-sub);
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.mgr-delete-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* ── 애니메이션 ───────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* ── 하단 고정 액션 바 (Mobile-First) ── */
.bottom-action-wrapper {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  background: var(--bg);
  /* or var(--card) based on preference */
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
  z-index: 100;
  display: flex;
  box-sizing: border-box;
}

.bottom-action-wrapper .btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  border-radius: var(--radius);
  justify-content: center;
}

/* ── 반응형 (모바일) - 이제 기본 베이스이므로 단순 화면 조정만 남김 ── */
@media (max-width: 600px) {
  .app-header {
    padding: 14px 16px;
  }

  .app-header h1 {
    font-size: 1.1rem;
  }
}

/* ── 스크롤바 ─────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-sub);
}