@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700;900&family=Outfit:wght@400;600;800&display=swap');

:root {
  --primary-color: #0284c7; /* 감자 블루 (스카이 700) */
  --secondary-color: #f59e0b; /* 감자 골드 (앰버 500) */
  --dark-color: #0f172a; /* 감자 다크 (슬레이트 900) */
  --light-color: #f8fafc; /* 밝은 회백색 (슬레이트 50) */
  --kraft-color: #e2e8f0; /* 모던 슬레이트 그레이 (슬레이트 200) */
  --stamp-color: #e11d48; /* 감자 로즈 도장 (로즈 600) */
  --shadow-color: rgba(15, 23, 42, 0.08);
}

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

body {
  font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
  background-color: #0f172a;
  color: var(--dark-color);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 10px;
}

/* 스크롤바 디자인 */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
}
::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

/* 공통 컨테이너 */
.app-container {
  width: 100%;
  max-width: 480px;
  background: var(--light-color);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  position: relative;
  border: 4px solid var(--secondary-color);
}

/* 헤더 영역 */
.app-header {
  background: linear-gradient(-45deg, var(--dark-color), #1e293b, #111827, var(--dark-color));
  background-size: 400% 400%;
  animation: gradient-flow 12s ease infinite;
  padding: 28px 20px;
  text-align: center;
  color: white;
  border-bottom: 3px solid var(--secondary-color);
  position: relative;
  overflow: hidden;
}

@keyframes gradient-flow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--secondary-color), var(--primary-color), var(--secondary-color));
}

.brand-logo {
  max-height: 70px;
  height: auto;
  margin-bottom: 12px;
  filter: drop-shadow(0px 4px 8px rgba(0,0,0,0.4));
  animation: logo-float 5s ease-in-out infinite, slide-down-fade 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes logo-float {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}

.brand-title {
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--secondary-color);
  letter-spacing: 1px;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
  animation: title-glow 3s ease-in-out infinite alternate, slide-down-fade 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

@keyframes title-glow {
  0% { text-shadow: 0 0 10px rgba(245, 158, 11, 0.2); }
  100% { text-shadow: 0 0 25px rgba(245, 158, 11, 0.6), 0 0 5px rgba(255, 255, 255, 0.3); }
}

.brand-subtitle {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-top: 6px;
  font-weight: 400;
  color: #e2e8f0;
  letter-spacing: 0.5px;
  animation: slide-down-fade 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

@keyframes slide-down-fade {
  0% { opacity: 0; transform: translateY(-12px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* 콘텐츠 영역 */
.app-content {
  padding: 24px 20px;
}

/* 카드 공통 */
.card {
  background: white;
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 15px var(--shadow-color);
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition: transform 0.2s;
}

/* 로그인 화면 */
.login-section {
  text-align: center;
}

.login-section p {
  font-size: 0.95rem;
  color: #666;
  margin-bottom: 25px;
  line-height: 1.5;
}

.input-group {
  margin-bottom: 20px;
  position: relative;
}

.input-group label {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 8px;
}

.tel-input {
  width: 100%;
  padding: 16px;
  font-size: 1.3rem;
  border: 2px solid #ddd;
  border-radius: 12px;
  text-align: center;
  letter-spacing: 2px;
  font-weight: 700;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.tel-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(122, 28, 28, 0.15);
}

/* 버튼 스타일 */
.btn {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, #601414 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(122, 28, 28, 0.3);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 5px rgba(122, 28, 28, 0.3);
}

.btn-primary:disabled {
  background: #ccc;
  box-shadow: none;
  cursor: not-allowed;
}

/* 스탬프 카드 섹션 */
.stamp-card-container {
  background-color: var(--kraft-color);
  background-image: radial-gradient(rgba(0,0,0,0.03) 1px, transparent 0);
  background-size: 24px 24px;
  border: 2px dashed #B8A88E;
  border-radius: 16px;
  padding: 18px;
  position: relative;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 15px;
}

/* 개별 스탬프 슬롯 */
.stamp-slot {
  aspect-ratio: 1;
  background: #fff;
  border-radius: 50%;
  border: 2px dashed #C3B49E;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
}

.stamp-slot::before {
  content: attr(data-num);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  color: #94a3b8;
  position: absolute;
  z-index: 1;
}

/* 혜택이 걸려 있는 특별 슬롯 */
.stamp-slot.reward-slot::after {
  content: '';
  position: absolute;
  width: 110%;
  height: 110%;
  border: 1px solid var(--secondary-color);
  border-radius: 50%;
  animation: pulse 2s infinite;
  pointer-events: none;
}

.stamp-slot.reward-slot .reward-badge {
  position: absolute;
  bottom: -4px;
  background: var(--secondary-color);
  color: var(--dark-color);
  font-size: 0.6rem;
  font-weight: 900;
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  border: 1px solid #fff;
}

/* 실제 찍히는 도장 이미지 */
.stamp-ink {
  width: 90%;
  height: 90%;
  background: radial-gradient(circle, var(--stamp-color) 45%, rgba(225, 29, 72, 0.85) 100%);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-family: 'Pretendard', 'Outfit', sans-serif;
  font-weight: 900;
  font-size: 0.78rem;
  line-height: 1.15;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  box-shadow: 0 3px 6px rgba(0,0,0,0.25);
  z-index: 3;
  opacity: 0.95;
  transform: rotate(-15deg);
  position: relative;
  border: 3px double rgba(255, 255, 255, 0.4);
}

/* 잉크 빈티지 효과 */
.stamp-ink::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  background-image: 
    radial-gradient(circle, transparent 70%, rgba(239, 230, 213, 0.4) 75%),
    repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(239, 230, 213, 0.2) 4px, rgba(239, 230, 213, 0.2) 6px);
  pointer-events: none;
}

/* 도장 찍히는 애니메이션 */
.stamp-animate {
  animation: stamp-drop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes stamp-drop {
  0% {
    transform: scale(3) rotate(-45deg);
    opacity: 0;
    filter: blur(4px);
  }
  70% {
    transform: scale(0.9) rotate(5deg);
    opacity: 1;
    filter: blur(0);
  }
  100% {
    transform: scale(1) rotate(-15deg);
    opacity: 0.95;
  }
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.7);
  }
  70% {
    transform: scale(1.1);
    box-shadow: 0 0 0 6px rgba(212, 175, 55, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
  }
}

/* 상태 및 요청 바 */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
  font-size: 0.9rem;
}

.status-phone {
  font-weight: 700;
  color: var(--dark-color);
}

.status-logout {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 0.8rem;
  text-decoration: underline;
}

/* 대기 화면 오버레이 */
.waiting-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.waiting-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.waiting-card {
  background: white;
  width: 85%;
  max-width: 380px;
  padding: 30px 20px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  border: 3px solid var(--secondary-color);
}

.waiting-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(122, 28, 28, 0.1);
  border-top: 5px solid var(--primary-color);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.waiting-card h3 {
  font-family: 'Gowun Batang', serif;
  color: var(--primary-color);
  margin-bottom: 10px;
}

.waiting-card p {
  font-size: 0.9rem;
  color: #666;
  line-height: 1.5;
}

/* 쿠폰 리스트 섹션 */
.coupon-section {
  margin-top: 25px;
}

.coupon-section-title {
  font-family: 'Gowun Batang', serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.coupon-card {
  background: linear-gradient(135deg, #fff 70%, var(--kraft-color) 100%);
  border: 1px solid rgba(0,0,0,0.08);
  border-left: 6px solid var(--secondary-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.05);
  position: relative;
  overflow: hidden;
}

/* 절취선 효과 */
.coupon-card::before {
  content: '';
  position: absolute;
  right: 25%;
  top: 0;
  height: 100%;
  border-right: 2px dashed #d5c8b5;
}

.coupon-card::after {
  content: '';
  position: absolute;
  right: calc(25% - 6px);
  top: -6px;
  width: 12px;
  height: 12px;
  background: var(--light-color);
  border-radius: 50%;
}

.coupon-info h4 {
  font-family: 'Gowun Batang', serif;
  font-size: 1.05rem;
  color: var(--primary-color);
  margin-bottom: 4px;
}

.coupon-info p {
  font-size: 0.75rem;
  color: #888;
}

.btn-use-coupon {
  width: auto;
  padding: 8px 12px;
  font-size: 0.8rem;
  background: var(--dark-color);
  color: #fff;
  border-radius: 6px;
}

.btn-use-coupon:active {
  background: #000;
}

/* 관리자 페이지 레이아웃 */
.admin-container {
  max-width: 1000px;
  background: #f8f9fa;
  width: 100%;
  border: 4px solid var(--dark-color);
}

.admin-header {
  background: var(--dark-color);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 4px solid var(--secondary-color);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: 20px;
  padding: 20px;
}

@media(max-width: 768px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.admin-panel {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  border: 1.5px solid #eaeaea;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 15px;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 요청 카드 스타일 */
.request-card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 450px;
  overflow-y: auto;
  padding-right: 5px;
}

.request-item {
  background: #fff8f8;
  border: 1px solid #f2dede;
  border-radius: 10px;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.request-item.type-coupon {
  background: #fdfaf2;
  border-color: #faebd7;
}

.req-details h4 {
  font-size: 1.05rem;
  color: var(--dark-color);
  margin-bottom: 4px;
}

.req-details .badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.badge-stamp {
  background: #f2dede;
  color: var(--primary-color);
}

.badge-coupon {
  background: #faebd7;
  color: #b8860b;
}

.req-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

.btn-approve {
  background: #28a745;
  color: white;
}

.btn-reject {
  background: #dc3545;
  color: white;
}

/* 회원 목록 테이블 */
.user-table-wrapper {
  overflow-x: auto;
  max-height: 500px;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.user-table th, .user-table td {
  padding: 12px;
  border-bottom: 1px solid #eee;
}

.user-table th {
  background-color: #f1f1f1;
  font-weight: 700;
  color: #555;
}

.user-table tr:hover {
  background-color: #fafafa;
}

.stamp-adjust {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stamp-adjust input {
  width: 50px;
  padding: 4px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.empty-state {
  text-align: center;
  color: #888;
  padding: 40px 10px;
  font-size: 0.95rem;
}

/* QR코드 팝업 */
.qr-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 110;
}

.qr-modal-content {
  background: white;
  padding: 30px;
  border-radius: 20px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  border: 3px solid var(--secondary-color);
}

.qr-placeholder {
  width: 200px;
  height: 200px;
  margin: 15px auto;
  border: 1px solid #ddd;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 노티피케이션 (토스트) */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: white;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: transform 0.3s ease;
  z-index: 200;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* 관리자 화면 탭 스타일 */
.admin-tab {
  transition: all 0.2s ease;
}
.admin-tab:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: white !important;
}
.admin-tab.active {
  border-bottom-color: var(--primary-color) !important;
}

/* 고객 화면 탭 스타일 */
.app-tab {
  transition: all 0.2s ease;
}
.app-tab:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: white !important;
}
.app-tab.active {
  border-bottom-color: var(--secondary-color) !important;
}

/* 도장 3D 낙하 바운스 애니메이션 */
.stamp-bounce {
  animation: stamp-bounce 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes stamp-bounce {
  0% {
    transform: scale(3.5) rotate(-35deg);
    opacity: 0;
    filter: blur(4px);
  }
  60% {
    transform: scale(0.9) rotate(-5deg);
    opacity: 1;
    filter: blur(0);
  }
  80% {
    transform: scale(1.15) rotate(-10deg);
  }
  100% {
    transform: scale(1.0) rotate(-8deg);
  }
}

/* 잉크 튐 파티클 이펙트 */
.stamp-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  animation: particle-fly 0.5s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes particle-fly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0.9;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0.2);
    opacity: 0;
  }
}
