/*
 * 딜레이다 - 공통 베이스 스타일
 * 모던 반응형 디자인
 */

/* ========================================
   1. 전역 설정
   ======================================== */
:root {
    font-size: 16px;

    /* ========================================
       색상 시스템 - 기본
       ======================================== */
    --primary-color: #008f8c;
    --primary-hover: #007370;
    --primary-light: #e0f7f6;

    /* 텍스트 색상 */
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --text-light: #999;
    --text-white: #ffffff;

    /* 테두리 및 배경 */
    --border-color: #e5e5e5;
    --border-dark: #d0d0d0;
    --bg-white: #ffffff;
    --bg-gray: #f8f9fa;
    --bg-light: #fafbfc;

    /* 섀도우 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);

    /* 보더 레이디우스 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* 트랜지션 */
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;
    --transition-slow: all 0.5s ease;

    /* ========================================
       카테고리 색상 (nosearch.com 스타일)
       ======================================== */
    --category-home: #8FBEC1;
    --category-kitchen: #A7AEC6;
    --category-digital: #F4A79D;
    --category-furniture: #C9B8A3;
    --category-living: #B8D4C6;
    --category-baby: #F5C7D3;
    --category-hobby: #D4C5E2;

    /* ========================================
       상태 색상
       ======================================== */
    --success-color: #52c41a;
    --warning-color: #faad14;
    --error-color: #ff4757;
    --info-color: #1890ff;
}

/* ========================================
   2. 리셋 & 기본 스타일
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', sans-serif;
    background-color: var(--bg-gray);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

a:hover {
    opacity: 0.8;
}

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

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

/* ========================================
   3. 레이아웃
   ======================================== */
#wrap {
    position: relative;
    width: 100%;
    max-width: 768px;
    margin: 0 auto;
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
}

@media (min-width: 768px) {
    #wrap {
        max-width: 768px;
    }
}

/* ========================================
   4. 헤더
   ======================================== */
#header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
    padding: 0 1rem;
    background-color: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

#header.header--hidden {
    transform: translateY(-100%);
}

@media (min-width: 768px) {
    #header {
        height: 60px;
        padding: 0 2rem;
    }
}

#header .logo {
    display: flex;
    align-items: center;
}

#header .logo img {
    height: clamp(24px, 5vw, 30px);
    transition: var(--transition);
}

#header .logo:hover img {
    transform: scale(1.05);
}

#header .header_btns {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#header .header_btns button {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

#header .header_btns button:hover {
    background: var(--bg-gray);
}

#header .header_btns button img {
    width: clamp(22px, 5vw, 28px);
    height: clamp(22px, 5vw, 28px);
    transition: var(--transition);
    opacity: 0.7;
}

#header .header_btns button:hover img {
    opacity: 1;
    transform: scale(1.1);
}

/* ========================================
   4-1. 서브 헤더 (뒤로가기 + 제목 + 검색)
   ======================================== */
.gdetail-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 1rem;
    background-color: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

@media (min-width: 768px) {
    .gdetail-header {
        height: 70px;
        padding: 0 2rem;
    }
}

.gdetail-header .back_btn {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.gdetail-header .back_btn button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition);
}

.gdetail-header .back_btn button:hover {
    background: var(--bg-gray);
}

.gdetail-header .back_btn img {
    width: 24px;
    height: 24px;
}

.gdetail-header .header_title {
    flex: 1;
    font-size: clamp(1rem, 3vw, 1.125rem);
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 1rem;
}

.gdetail-header .header_right {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.gdetail-header .header_right img {
    width: 24px;
    height: 24px;
    cursor: pointer;
    opacity: 0.7;
    transition: var(--transition);
    box-sizing: content-box;
}

.gdetail-header .header_right img:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* ========================================
   5. 탭 네비게이션
   ======================================== */
.tab_nav.common {
    display: flex;
    justify-content: space-between;
    position: sticky;
    top: 50px;
    left: 0;
    padding: 0 1.5rem;
    background: var(--bg-white);
    overflow-x: auto;
    white-space: nowrap;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -ms-overflow-style: none;
    scrollbar-width: none;
    transition: top 0.3s ease-out;
    -webkit-transition: top 0.3s ease-out;
    z-index: 99;
}

.tab_nav.common.nav--top {
    top: 0;
}

.tab_nav.common::-webkit-scrollbar {
    display: none;
}

.tab_nav.common .tab_item {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
    line-height: 1.5;
    color: var(--text-primary);
    text-decoration: none;
    box-sizing: border-box;
    padding: 0.8rem 0.5rem;
}

.tab_nav.common .tab_item.is--active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

/* 탭 네비게이션 모바일 대응 */
@media (max-width: 768px) {
    .tab_nav.common {
        padding: 0 1rem;
    }

    .tab_nav.common .tab_item {
        font-size: 1rem;
        padding: 0.8rem 0.3rem;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .tab_nav.common {
        padding: 0 0.5rem;
    }

    .tab_nav.common .tab_item {
        font-size: 1rem;
        padding: 0.7rem 0.2rem;
    }
}

/* ========================================
   6. 메인 컨텐츠
   ======================================== */
#contents {
    padding-bottom: 80px;
    min-height: calc(100vh - 60px - 52px - 60px);
    background: var(--bg-gray);
}

@media (min-width: 768px) {
    #contents {
        min-height: calc(100vh - 70px - 52px - 60px);
    }
}

/* ========================================
   7. 하단 네비게이션 바
   ======================================== */
.foot_bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 768px;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.quick_menu.hasFootbar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 60px;
    padding: 0 0.5rem;
}

.quick_menu .menu_item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    padding: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-light);
    transition: var(--transition);
    border-radius: var(--radius-sm);
}

.quick_menu .menu_item:hover {
    background: var(--bg-gray);
}

.quick_menu .menu_item img {
    width: 24px;
    height: 24px;
    transition: var(--transition);
}

.quick_menu .menu_item:hover img {
    transform: scale(1.1);
}

.quick_menu .menu_item span {
    transition: var(--transition);
}

/* ========================================
   8. 푸터
   ======================================== */
.footer {
    padding: 2.5rem 1rem;
    background: var(--bg-gray);
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.6;
}

@media (min-width: 768px) {
    .footer {
        padding: 3rem 2rem;
    }
}

.footer > div:first-child {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.footer > div {
    margin-bottom: 0.75rem;
}

.footer span {
    position: relative;
    padding: 0 0.5rem;
}

.footer span:not(:last-child)::after {
    content: '|';
    position: absolute;
    right: 0;
    color: var(--border-color);
}

.footer span:first-child {
    padding-left: 0;
}

.footer p {
    margin: 0.5rem 0;
    color: var(--text-light);
}

/* ========================================
   9. 유틸리티 클래스
   ======================================== */
.container {
    width: 100%;
    max-width: 768px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 768px) {
    .container {
        padding: 0 2rem;
    }
}

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

.text-secondary {
    color: var(--text-secondary);
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

/* ========================================
   10. 스크롤바 커스터마이징 (PC)
   ======================================== */
@media (min-width: 768px) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    ::-webkit-scrollbar-track {
        background: var(--bg-gray);
    }

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

    ::-webkit-scrollbar-thumb:hover {
        background: var(--border-dark);
    }
}

/* ========================================
   11. 반응형 헬퍼
   ======================================== */
.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

@media (min-width: 1024px) {
    .mobile-only {
        display: none;
    }

    .desktop-only {
        display: block;
    }
}

/* ========================================
   12. 포커스 스타일
   ======================================== */
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ========================================
   13. 로딩 & 애니메이션
   ======================================== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    animation: spin 1s linear infinite;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

/* ========================================
   13. 모바일 헤더 숨김 (1023px 이하)
   ======================================== */
@media (max-width: 1023px) {
    .pc-header,
    #header-pc {
        display: none !important;
    }
}

/* ========================================
   14. PC 레이아웃 (1024px+)
   ======================================== */
@media (min-width: 1024px) {
    /* #wrap PC 확장 */
    #wrap {
        max-width: 1400px;
        box-shadow: none; /* PC에서는 그림자 제거 */
    }

    /* ========================================
       14-1. 모바일 헤더 및 네비게이션 숨김
       ======================================== */
    /* 모바일 헤더 숨김 */
    #header {
        display: none;
    }

    /* 탭 네비게이션 숨김 */
    .tab_nav.common {
        display: none;
    }

    /* ========================================
       14-2. PC 헤더 표시 및 기본 스타일
       ======================================== */
    .pc-header {
        display: flex !important;
        position: sticky;
        top: 0;
        z-index: 100;
        align-items: center;
        justify-content: space-between;
        height: 70px;
        padding: 0 3rem;
        background-color: rgba(255, 255, 255, 0.95);
        border-bottom: 1px solid var(--border-color);
        backdrop-filter: blur(10px);
        max-width: 1400px;
        margin: 0 auto;
        width: 100%;
        transition: var(--transition);
    }

    /* ========================================
       14-3. PC 헤더 좌측 (로고 + 메인 네비게이션)
       ======================================== */
    .header-left {
        display: flex;
        align-items: center;
        gap: 3rem;
        flex: 1;
    }

    .header-left .logo img {
        height: 32px;
        transition: var(--transition);
    }

    .header-left .logo:hover img {
        transform: scale(1.05);
    }

    .header-left .main-nav {
        display: flex;
        align-items: center;
        gap: 2rem;
    }

    .header-left .main-nav .nav-item {
        position: relative;
        font-size: 1rem;
        font-weight: 500;
        color: var(--text-primary);
        text-decoration: none;
        cursor: pointer;
        padding: 0.5rem 0;
        transition: var(--transition);
        border-bottom: 2px solid transparent;
    }

    .header-left .main-nav .nav-item:hover {
        color: var(--primary-color);
    }

    .header-left .main-nav .nav-item.active {
        color: var(--primary-color);
        border-bottom-color: var(--primary-color);
    }

    /* ========================================
       14-4. PC 헤더 우측 (검색 + 유틸리티 메뉴)
       ======================================== */
    .header-right {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 1.5rem;
    }

    /* 검색 아이콘 버튼 */
    .header-right .search-icon-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: transparent;
        border: none;
        cursor: pointer;
        transition: var(--transition);
        padding: 0;
    }

    .header-right .search-icon-btn:hover {
        background: var(--bg-gray);
    }

    .header-right .search-icon-btn img {
        width: 24px;
        height: 24px;
        opacity: 0.7;
        transition: var(--transition);
    }

    .header-right .search-icon-btn:hover img {
        opacity: 1;
        transform: scale(1.1);
    }

    /* 유틸리티 네비게이션 */
    .header-right .utility-nav {
        display: flex;
        align-items: center;
        gap: 1.5rem;
    }

    .header-right .utility-nav .utility-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        cursor: pointer;
        text-align: center;
        transition: var(--transition);
        text-decoration: none;
        color: var(--text-primary);
    }

    .header-right .utility-nav .utility-item:hover {
        color: var(--primary-color);
    }

    .header-right .utility-nav .utility-item.active {
        color: var(--primary-color);
    }

    .header-right .utility-nav .utility-item img {
        width: 24px;
        height: 24px;
        opacity: 0.7;
        transition: var(--transition);
    }

    .header-right .utility-nav .utility-item:hover img {
        opacity: 1;
        transform: scale(1.1);
    }

    .header-right .utility-nav .utility-item.active img {
        opacity: 1;
    }

    .header-right .utility-nav .utility-item span {
        font-size: 0.75rem;
        font-weight: 500;
        transition: var(--transition);
    }

    /* ========================================
       14-5. 검색 모달 스타일
       ======================================== */
    .search-modal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1001;
        align-items: center;
        justify-content: center;
        animation: modalSlideDown 0.3s ease-out;
    }

    .search-modal.active {
        display: flex;
    }

    .search-modal .search-modal-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: -1;
    }

    .search-modal .search-modal-content {
        position: relative;
        width: 90%;
        max-width: 600px;
        background: var(--bg-white);
        border-radius: var(--radius-lg);
        padding: 2rem;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
        animation: slideInDown 0.3s ease-out;
    }

    .search-modal .search-modal-header {
        display: flex;
        align-items: center;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .search-modal .search-modal-header input {
        flex: 1;
        padding: 0.75rem 1rem;
        font-size: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        transition: var(--transition);
        font-family: inherit;
    }

    .search-modal .search-modal-header input:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(0, 143, 140, 0.1);
        transition: var(--transition);
    }

    .search-modal .search-modal-header .close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: transparent;
        border: none;
        cursor: pointer;
        transition: var(--transition);
        padding: 0;
        flex-shrink: 0;
    }

    .search-modal .search-modal-header .close-btn:hover {
        background: var(--bg-gray);
    }

    .search-modal .search-modal-header .close-btn img {
        width: 24px;
        height: 24px;
        opacity: 0.7;
        transition: var(--transition);
    }

    .search-modal .search-modal-header .close-btn:hover img {
        opacity: 1;
    }

    /* ========================================
       14-6. 서브 헤더 PC 스타일 - 숨김
       ======================================== */
    .gdetail-header {
        display: none;
    }

    /* ========================================
       14-7. 메인 컨텐츠 및 하단 네비게이션
       ======================================== */
    /* 메인 컨텐츠 */
    #contents {
        padding-bottom: 2rem; /* 바텀바 없으므로 패딩 감소 */
        max-width: 768px;
        margin: 0 auto;
    }

    /* 바텀 네비게이션 숨김 */
    .foot_bar {
        display: none;
    }

    /* 모바일 헤더 숨김 */
    .mobile-header {
        display: none;
    }

    /* ========================================
       14-8. 푸터 PC 스타일
       ======================================== */
    .footer {
        padding: 4rem 3rem;
        max-width: 1400px;
        margin: 0 auto;
    }

    /* ========================================
       14-9. 컨테이너 PC 스타일
       ======================================== */
    .container {
        max-width: 1400px;
        padding: 0 3rem;
    }
}

/* ========================================
   15. 검색 모달 애니메이션
   ======================================== */
@keyframes modalSlideDown {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   16. 카테고리 태그 (필터용)
   ======================================== */
.category-tag {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-white);
    display: inline-block;
    transition: var(--transition-fast);
    cursor: pointer;
    border: none;
    text-decoration: none;
}

.category-tag:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-sm);
}

.category-tag:active {
    transform: scale(0.98);
}

/* 카테고리별 배경 색상 */
.category-tag.home { background: var(--category-home); }
.category-tag.kitchen { background: var(--category-kitchen); }
.category-tag.digital { background: var(--category-digital); }
.category-tag.furniture { background: var(--category-furniture); }
.category-tag.living { background: var(--category-living); }
.category-tag.baby { background: var(--category-baby); }
.category-tag.hobby { background: var(--category-hobby); }

/* ========================================
   Sidebar Banner Layout (공통 스타일)
   ======================================== */

.content-wrapper {
    display: flex;
    width: 100%;
    justify-content: center;
}

.main-content {
    width: 100%;
    max-width: 768px;
}

.sidebar-banner {
    display: none;
}

/* PC Layout with Sidebar (1024px+) */
@media (min-width: 1024px) {
    #contents {
        max-width: 1024px;
        margin: 0 auto;
        padding: 0 1rem;
    }

    .content-wrapper {
        display: flex;
        gap: 1rem;
        width: 100%;
        justify-content: flex-start;
    }

    /* Main content area */
    .main-content {
        width: 768px;
        flex-shrink: 0;
    }

    /* Sidebar banner (when present) */
    .sidebar-banner {
        display: block;
        flex-shrink: 0;
        width: 240px;
        margin-top: 1.5rem;
    }

    /* When no sidebar, content stays centered at 768px */
    .content-wrapper:not(:has(.sidebar-banner)) {
        justify-content: center;
    }

    .sidebar-banner-wrapper {
        position: sticky;
        top: 1.5rem;
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .sidebar-banner-item {
        display: block;
        border-radius: var(--radius-md);
        overflow: hidden;
        box-shadow: var(--shadow-sm);
        transition: var(--transition);
    }

    .sidebar-banner-item:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }

    .sidebar-banner-item img {
        width: 100%;
        height: auto;
        display: block;
    }
}

/* ========================================
   17. header-back 스타일 (모바일 뒤로가기 헤더)
   ======================================== */
.header-back {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-white);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

.header-back .btn-back {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-back .btn-back img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.header-back .header-title {
    flex: 1;
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    margin: 0;
}

.header-back .header-spacer {
    width: 2.4rem;
}

/* PC에서 header-back 숨김 */
@media (min-width: 1024px) {
    .header-back {
        display: none !important;
    }
}
