/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
    font-size: 14px;
    color: #333;
    background: #f5f6fa;
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ========== Layout ========== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ========== Header ========== */
.site-header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,.06);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
}

.logo { font-size: 20px; font-weight: 700; color: #2563eb; white-space: nowrap; }

.search-form { display: flex; flex: 1; gap: 8px; }

.search-input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
}
.search-input:focus { border-color: #2563eb; }

.search-btn {
    padding: 8px 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}
.search-btn:hover { background: #1d4ed8; }

/* ========== Main ========== */
.main-content { padding: 24px 0 48px; }

/* ========== Category Nav ========== */
.category-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.cat-btn {
    padding: 6px 14px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
    transition: all .2s;
}
.cat-btn:hover, .cat-btn.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* ========== Result Summary ========== */
.result-summary { margin-bottom: 16px; color: #555; font-size: 14px; }

/* ========== Product Grid ========== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.product-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    transition: box-shadow .2s, transform .2s;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.product-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    transform: translateY(-2px);
}

.product-type {
    display: inline-block;
    background: #eff6ff;
    color: #2563eb;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.product-name {
    font-size: 15px;
    font-weight: 600;
    color: #111;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-maker { font-size: 13px; color: #666; }
.product-date { font-size: 12px; color: #aaa; margin-top: auto; }

/* ========== Pagination ========== */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 32px; flex-wrap: wrap; }

.page-btn {
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all .2s;
}
.page-btn:hover, .page-btn.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 64px 16px;
    color: #888;
    font-size: 16px;
}

/* ========== Product Detail ========== */
.breadcrumb { font-size: 13px; color: #888; margin-bottom: 16px; }
.breadcrumb a:hover { color: #2563eb; }

.detail-title { font-size: 24px; font-weight: 700; margin-bottom: 24px; }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .detail-grid { grid-template-columns: 1fr; }
}

.detail-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
}

.detail-card h2 { font-size: 16px; font-weight: 700; margin-bottom: 16px; color: #444; }

.info-table { width: 100%; border-collapse: collapse; }
.info-table th, .info-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}
.info-table th { width: 40%; color: #666; font-weight: 600; }

.ingredient-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ingredient-item {
    padding: 8px 12px;
    background: #f9fafb;
    border-left: 3px solid #2563eb;
    border-radius: 4px;
    font-size: 14px;
}

.ingredient-raw { margin-top: 12px; color: #aaa; }
.no-data { color: #aaa; font-style: italic; }

.detail-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all .2s;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #fff; color: #555; border: 1px solid #d1d5db; }
.btn-secondary:hover { background: #f9fafb; }

/* ========== Footer ========== */
.site-footer {
    background: #1e293b;
    color: #94a3b8;
    padding: 24px 0;
    text-align: center;
    font-size: 13px;
    margin-top: 40px;
}

/* ========== Top Nav ========== */
.top-nav { display: flex; gap: 12px; }
.top-nav-link {
    padding: 6px 12px; border-radius: 6px; font-size: 13px; color: #555;
    transition: background .15s;
}
.top-nav-link:hover { background: #f1f5f9; color: #2563eb; }

/* ========== Page title ========== */
.page-title { font-size: 24px; margin: 16px 0 4px; color: #111827; }
.page-title small { font-size: 14px; color: #6b7280; font-weight: 400; }
.page-subtitle { color: #6b7280; margin-bottom: 20px; }

/* 페이지 상단 제목 + 우측 액션 버튼 (쇼핑몰 메인 / 제품 등록 등에서 공유) */
.shop-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.shop-hero > div { flex: 1 1 auto; min-width: 0; }
.shop-hero .btn { flex: 0 0 auto; }

/* ========== Dataset grid ========== */
.dataset-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    margin-top: 16px;
}
.dataset-card {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 20px; transition: box-shadow .15s, transform .15s;
    display: block;
}
.dataset-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); transform: translateY(-2px); }
.dataset-sid { font-family: monospace; font-size: 12px; color: #2563eb; }
.dataset-label { font-size: 18px; margin: 4px 0 8px; color: #111827; }
.dataset-desc { font-size: 13px; color: #6b7280; min-height: 36px; }
.dataset-stats { margin-top: 12px; display: flex; justify-content: space-between; align-items: end; }
.dataset-stats strong { font-size: 20px; color: #2563eb; }
.dataset-last { font-size: 11px; color: #9ca3af; }

/* ========== Tables ========== */
.data-table {
    width: 100%; background: #fff; border-collapse: collapse;
    border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.05);
    margin-top: 12px;
}
.data-table th, .data-table td {
    padding: 10px 14px; text-align: left; border-bottom: 1px solid #f1f5f9; font-size: 13px;
}
.data-table th { background: #f9fafb; font-weight: 600; color: #374151; }
.data-table tr:hover { background: #f9fafb; }
.mono { font-family: monospace; color: #6b7280; }

/* ========== Filter form ========== */
.filter-form { display: flex; gap: 8px; margin: 16px 0; }
.filter-form .search-input { max-width: 300px; }

/* ========== Sync admin ========== */
.sync-status { margin-top: 24px; background: #fff; padding: 16px; border-radius: 8px; border: 1px solid #e5e7eb; }
.sync-status h3 { font-size: 14px; margin-bottom: 8px; color: #374151; }
.sync-status pre {
    background: #0f172a; color: #94f5cd; padding: 12px; border-radius: 6px;
    font-size: 12px; max-height: 300px; overflow: auto;
}
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ========== Raw JSON details ========== */
.raw-json-details { margin-top: 16px; }
.raw-json-details summary { cursor: pointer; padding: 8px; color: #2563eb; font-weight: 500; }
.raw-json {
    background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 6px;
    font-size: 12px; overflow: auto; max-height: 400px;
}

/* ========== Responsive ========== */
@media (max-width: 480px) {
    .header-inner { flex-wrap: wrap; }
    .product-grid { grid-template-columns: 1fr 1fr; }
    .top-nav { flex-wrap: wrap; }
}
