/* ===== 디자인 토큰 ===== */
@import url('theme.css');

/* ===== 리셋 ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--surface-white);
  line-height: 1.6;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-content {
  flex: 1;
}

a {
  text-decoration: none;
  color: inherit;
  outline: none;
  cursor: pointer;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  outline: none;
}

input,
textarea,
select {
  -webkit-user-select: text;
  user-select: text;
  outline: none;
  font-family: inherit;
}

button:focus,
button:focus-visible,
a:focus,
a:focus-visible,
[role="button"]:focus,
[role="button"]:focus-visible,
[tabindex]:focus,
[tabindex]:focus-visible,
label:focus,
summary:focus {
  outline: none;
}

ul, ol {
  list-style: none;
}

img {
  max-width: 100%;
  display: block;
}

/* ===== 프로모션 바 ===== */
.promo-bar {
  position: relative;
  z-index: calc(var(--z-header) + 1);
  background: var(--brand-primary);
  color: var(--text-inverse);
  text-align: center;
  padding: 10px 20px;
  height: var(--promo-height);
  display: flex;
  align-items: center;
  justify-content: center;
}

.promo-bar__text {
  font-size: var(--text-sm);
  letter-spacing: 1.5px;
  font-weight: var(--weight-light);
}

.promo-bar__text strong {
  color: var(--brand-accent);
  font-weight: var(--weight-semibold);
}

/* ===== 헤더 ===== */
.header {
  position: absolute;
  top: var(--promo-height);
  left: 0;
  right: 0;
  z-index: var(--z-header);
  background: transparent;
  height: var(--header-height);
  transition: background var(--ease-base), box-shadow var(--ease-base);
}

.header--scrolled,
.header--solid {
  position: fixed;
  top: 0;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}

.header--solid .header__logo,
.header--solid .header__nav-link,
.header--solid .header__icon,
.header--solid .header__search-btn,
.header--solid .header__hamburger span {
  color: var(--text-primary);
}

.header--solid .header__hamburger span {
  background: var(--text-primary);
}

.header--solid .header__search {
  background: var(--surface-light);
  border-color: transparent;
}

.header--solid .header__search-input {
  color: var(--text-primary);
}

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

.header--scrolled .header__logo,
.header--scrolled .header__nav-link,
.header--scrolled .header__icon,
.header--scrolled .header__hamburger span {
  color: var(--text-primary);
}

.header--scrolled .header__hamburger span {
  background: var(--text-primary);
}

.header__inner {
  padding: 0 40px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

.header__logo {
  display: flex;
  align-items: center;
  height: 50px;
  width: 180px;
  flex-shrink: 0;
}

.header__logo-img {
  height: 50px;
  width: auto;
  object-fit: cover;
  transition: opacity 1s ease;
}

.header__logo-img--text {
  animation: logoSwap 10s ease-in-out infinite;
}

.header__logo-img--mark {
  position: absolute;
  height: 70px;
  opacity: 0;
  animation: logoSwapAlt 10s ease-in-out infinite;
}

@keyframes logoSwap {
  0%, 40% { opacity: 1; }
  50%, 90% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes logoSwapAlt {
  0%, 40% { opacity: 0; }
  50%, 90% { opacity: 1; }
  100% { opacity: 0; }
}

.header__logo:hover .header__logo-img {
  filter: brightness(0.8);
}

/* 내비게이션 */
.header__nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header__nav-item {
  position: relative;
}

.header__nav-link {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text-inverse);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  position: relative;
  transition: all var(--ease-fast);
  white-space: nowrap;
  letter-spacing: 0;
  display: block;
}

.header--scrolled .header__nav-link {
  color: var(--text-primary);
}

.header__nav-link::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--brand-accent);
  transition: width var(--ease-base);
}

.header__nav-item:hover .header__nav-link {
  color: var(--brand-secondary);
}

.header__nav-item:hover .header__nav-link::after {
  width: 60%;
}

/* 드롭다운 */
.header__dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  min-width: 180px;
  background: var(--surface-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px 0;
  opacity: 0;
  visibility: hidden;
  transition: all var(--ease-base);
  z-index: var(--z-dropdown);
}

.header__nav-item:hover .header__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.header__dropdown-link {
  display: block;
  padding: 10px 20px;
  font-size: var(--text-base);
  color: var(--text-secondary);
  transition: all var(--ease-fast);
  white-space: nowrap;
}

.header__dropdown-link:hover {
  background: var(--surface-light);
  color: var(--text-primary);
  padding-left: 24px;
}

/* 헤더 액션 */
.header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.header__search {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-full);
  padding: 0 16px;
  height: 38px;
  transition: all var(--ease-base);
  width: 200px;
}

.header--scrolled .header__search {
  background: var(--surface-light);
  border-color: transparent;
}

.header__search:focus-within {
  background: var(--surface-white);
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 2px var(--brand-accent);
  width: 240px;
}

.header__search:focus-within .header__search-input {
  color: var(--text-primary);
}

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

.header__search:focus-within .header__search-btn {
  color: var(--text-muted);
}

.header__search-input {
  flex: 1;
  font-size: var(--text-base);
  background: transparent;
  color: var(--text-inverse);
  width: 100%;
  border: none;
}

.header--scrolled .header__search-input {
  color: var(--text-primary);
}

.header__search-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

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

.header__search-btn {
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  padding: 4px;
  transition: color var(--ease-fast);
}

.header--scrolled .header__search-btn {
  color: var(--text-muted);
}

.header__search-btn:hover {
  color: var(--text-inverse);
}

.header--scrolled .header__search-btn:hover {
  color: var(--text-primary);
}

.header__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  color: var(--text-inverse);
  transition: all var(--ease-fast);
}

.header--scrolled .header__icon {
  color: var(--text-primary);
}

.header__icon:hover {
  background: var(--surface-light);
  color: var(--brand-secondary);
}

.header__cart {
  position: relative;
}

.header__cart-badge {
  position: absolute;
  top: 4px;
  right: 2px;
  background: var(--brand-accent);
  color: var(--text-inverse);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
}

.header__hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 10px 8px;
  border-radius: var(--radius-full);
  transition: background var(--ease-fast);
}

.header__hamburger:hover {
  background: var(--surface-light);
}

.header__hamburger span {
  display: block;
  height: 1.5px;
  background: var(--text-inverse);
  border-radius: 1px;
  transition: all var(--ease-base);
}

.header--scrolled .header__hamburger span {
  background: var(--text-primary);
}

.header__hamburger span:nth-child(2) {
  width: 70%;
}

/* ===== 섹션 공통 ===== */
.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px var(--page-padding) 100px;
}

.section__header {
  text-align: center;
  margin-bottom: 50px;
}

.section__title {
  font-family: var(--font-body);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.5px;
  color: var(--text-primary);
  margin-bottom: 0;
}

.section__subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: var(--weight-light);
  margin-top: 0;
  letter-spacing: 0.5px;
}

/* ===== 관리자 FAB ===== */
.admin-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-primary);
  color: var(--text-inverse);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-header);
  transition: background var(--ease-fast), transform var(--ease-fast);
}

.admin-fab:hover {
  background: var(--brand-accent);
  transform: scale(1.1);
}

@media (max-width: 768px) {
  .admin-fab {
    bottom: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
  }

  .admin-fab svg {
    width: 18px;
    height: 18px;
  }
}

/* ===== 상품 그리드 ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 28px 20px;
}

.product-card {
  cursor: pointer;
}

.product-card__image {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 0;
  background: var(--surface-light);
}

.product-card__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--surface-light);
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover .product-card__img {
  transform: scale(1.05);
}

.product-card__placeholder {
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover .product-card__placeholder {
  transform: scale(1.05);
}

.product-card__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--brand-primary);
  color: var(--text-inverse);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 2px;
  font-family: var(--font-ui);
  z-index: 2;
}

.product-card__badge--hot {
  background: var(--brand-danger);
}

.product-card__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--ease-base);
  border-radius: var(--radius-md);
}

.product-card:hover .product-card__overlay {
  opacity: 1;
}

.product-card__quick {
  background: var(--surface-white);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: 2px;
  padding: 12px 28px;
  transform: translateY(10px);
  transition: all var(--ease-base);
}

.product-card:hover .product-card__quick {
  transform: translateY(0);
}

.product-card__quick:hover {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.product-card__info {
  padding: 12px 0 8px;
}

.product-card__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--text-primary);
  line-height: 1.5;
  height: calc(var(--text-sm) * 1.5 * 2);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card:hover .product-card__name {
  color: var(--text-primary);
}

.product-card__price {
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.product-card__price-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.product-card__original {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-decoration: line-through;
  display: block;
}

.product-card__discount {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--brand-danger);
}

.product-card__sale {
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

/* ===== 푸터 ===== */
.footer {
  background: var(--brand-primary);
  color: rgba(255, 255, 255, 0.7);
  padding: 60px 0 0;
}

.footer__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--page-padding);
}

.footer__brand {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border-inverse);
}

.footer__logo {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: 2px;
  color: var(--text-inverse);
  margin-bottom: 8px;
}

.footer__tagline {
  font-size: var(--text-base);
  font-weight: var(--weight-light);
  color: var(--text-inverse-muted);
}

.footer__links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
  margin-bottom: 48px;
}

.footer__col-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-inverse);
  letter-spacing: 1px;
  margin-bottom: 16px;
  text-transform: uppercase;
}

.footer__link {
  display: block;
  font-size: var(--text-base);
  font-weight: var(--weight-light);
  color: var(--text-inverse-muted);
  padding: 4px 0;
  transition: color var(--ease-fast);
}

.footer__link:hover {
  color: var(--brand-accent);
}

.footer__text {
  font-size: var(--text-base);
  font-weight: var(--weight-light);
  color: var(--text-inverse-muted);
  padding: 2px 0;
}

.footer__bottom {
  border-top: 1px solid var(--border-inverse);
  padding: 24px 0;
  text-align: center;
}

.footer__bottom p {
  font-size: var(--text-sm);
  font-weight: var(--weight-light);
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.5px;
}

/* ===== 모바일 메뉴 ===== */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  z-index: var(--z-overlay);
  opacity: 0;
  transition: opacity var(--ease-base);
}

.mobile-overlay--active {
  display: block;
  opacity: 1;
}

.mobile-menu {
  position: fixed;
  top: 0;
  right: -320px;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  background: var(--surface-white);
  z-index: var(--z-modal);
  transition: right var(--ease-slide);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.mobile-menu--active {
  right: 0;
}

.mobile-menu__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-menu__logo {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: var(--weight-semibold);
  letter-spacing: 1px;
}

.mobile-menu__close {
  color: var(--text-primary);
  padding: 4px;
}

.mobile-menu__search {
  display: flex;
  align-items: center;
  margin: 16px 24px;
  background: var(--surface-light);
  border-radius: var(--radius-full);
  padding: 0 16px;
  height: 42px;
}

.mobile-menu__search input {
  flex: 1;
  font-size: var(--text-md);
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
}

.mobile-menu__search svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.mobile-menu__nav {
  flex: 1;
  padding: 8px 0;
}

.mobile-menu__item {
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-menu__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 24px;
  font-size: 15px;
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.mobile-menu__link svg {
  transition: transform var(--ease-base);
  color: var(--text-muted);
}

.mobile-menu__item--open .mobile-menu__link svg {
  transform: rotate(180deg);
}

.mobile-menu__sub {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--ease-base);
  background: var(--surface-off-white);
}

.mobile-menu__item--open .mobile-menu__sub {
  max-height: 200px;
}

.mobile-menu__sub a {
  display: block;
  padding: 12px 24px 12px 40px;
  font-size: var(--text-md);
  color: var(--text-secondary);
  transition: all var(--ease-fast);
}

.mobile-menu__sub a:hover {
  color: var(--brand-accent);
  background: var(--surface-light);
}

.mobile-menu__footer {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--border-subtle);
}

.mobile-menu__btn {
  display: block;
  text-align: center;
  padding: 14px;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  transition: all var(--ease-fast);
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.mobile-menu__btn:hover {
  opacity: 0.9;
}

.mobile-menu__btn--outline {
  background: var(--surface-white);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.mobile-menu__btn--outline:hover {
  border-color: var(--brand-primary);
}


/* ===== 공통 유틸리티 ===== */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: var(--text-md);
}

.empty-state--grid {
  grid-column: 1 / -1;
}

.empty-state--table {
  padding: var(--grid-gap);
}

/* ===== 구매 기능 ===== */

/* ===== 공통 반응형 ===== */
@media (max-width: 1400px) {
  .header__inner { padding: 0 20px; gap: 16px; }
  .header__nav { gap: 0; }
  .header__nav-link { padding: 8px 10px; font-size: var(--text-base); }
  .header__search { width: 160px; }
}

@media (max-width: 1200px) {
  .header__search { display: none; }
  .header__nav-link { padding: 8px 8px; font-size: var(--text-sm); }
}

@media (max-width: 1024px) {
  .header__inner {
    padding: 0 20px;
  }

  .header__logo { flex: 1; }
  .header__nav { display: none; }
  .header__search { display: none; }

  .section { padding: 60px 20px 80px; }

  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }

  .footer__links { gap: 24px; }
  .footer__inner { padding: 0 20px; }
}

@media (max-width: 768px) {
  :root { --header-height: 60px; }

  .promo-bar__text {
    font-size: var(--text-xs);
    letter-spacing: 0.5px;
  }

  .header__logo { font-size: 18px; }
  .header__search { display: none; }
  .header__icon { width: 36px; height: 36px; }

  .section { padding: 48px 16px 60px; }
  .section__title { font-size: var(--text-2xl); }
  .section__header { margin-bottom: 32px; }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .product-card__name { font-size: var(--text-sm); -webkit-line-clamp: 2; }
  .product-card__price { font-size: var(--text-md); }
  .product-card__info { padding: 8px 0 4px; }
  .product-card__badge { font-size: 10px; padding: 3px 8px; top: 8px; left: 8px; }
  .product-card__discount { font-size: var(--text-sm); }
  .product-card__sale { font-size: var(--text-md); }

  .footer { padding: 40px 0 0; }
  .footer__inner { padding: 0 16px; }
  .footer__links { grid-template-columns: 1fr; gap: 24px; }
  .footer__brand { margin-bottom: 24px; padding-bottom: 24px; }
}

@media (max-width: 480px) {
  .header__actions { gap: 4px; }
  .product-grid { gap: 12px; }
  .product-card__overlay { display: none; }
}

/* ===== 토스트 알림 ===== */
.toast-stack {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100% - 32px);
}

.toast {
  min-width: 280px;
  max-width: 420px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--surface-white);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--text-secondary);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity var(--ease-base), transform var(--ease-base);
  pointer-events: auto;
  word-break: keep-all;
}

.toast--show {
  opacity: 1;
  transform: translateY(0);
}

.toast--success {
  border-left-color: var(--status-complete);
}

.toast--error {
  border-left-color: var(--brand-danger);
}

.toast--info {
  border-left-color: var(--brand-primary);
}

@media (max-width: 480px) {
  .toast {
    min-width: 0;
    width: 100%;
  }
}