/* =========================================================
   국산모든것 - 공용 스타일시트
   모바일 퍼스트 반응형 / 최신 트렌드(카드형 UI, 넉넉한 여백, 라운드 처리)
   ========================================================= */

:root {
    --color-primary: #0f7a5c;
    --color-primary-dark: #0b5c45;
    --color-accent: #ff7a30;
    --color-bg: #f6f7f5;
    --color-surface: #ffffff;
    --color-text: #222831;
    --color-text-light: #6b7280;
    --color-border: #e5e7eb;
    --radius: 12px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 20, 0.08);
    --shadow-md: 0 6px 20px rgba(15, 23, 20, 0.10);
    --header-h: 64px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4 { margin: 0 0 12px; line-height: 1.3; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------------- Header / Nav ---------------- */

.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 200;
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--header-h);
}

.logo {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--color-primary-dark);
    white-space: nowrap;
}
.logo span { color: var(--color-accent); }

.search-form {
    flex: 1;
    max-width: 420px;
    margin-left: auto;
    display: flex;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    overflow: hidden;
    background: #fafafa;
}
.search-form input {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 9px 14px;
    font-size: 0.9rem;
    outline: none;
    min-width: 0;
}
.search-form button {
    border: 0;
    background: transparent;
    padding: 0 14px;
    cursor: pointer;
    font-size: 1rem;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    cursor: pointer;
    order: 3;
}
.nav-toggle span {
    display: block;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
}

.main-nav {
    background: var(--color-primary);
}
.nav-inner { padding: 0; }
.cat-nav {
    display: flex;
    flex-wrap: wrap;
}
.cat-nav > li {
    position: relative;
}
.cat-nav > li > a {
    display: block;
    padding: 10px 16px;
    color: #fff;
    font-weight: 500;
    font-size: 0.92rem;
    white-space: nowrap;
}
.cat-nav > li:hover > a,
.cat-nav > li > a:focus {
    background: var(--color-primary-dark);
}
.sub-nav {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
    border-radius: 0 0 8px 8px;
    min-width: 180px;
    padding: 6px 0;
    z-index: 300;
}
.has-sub:hover .sub-nav { display: block; }
.sub-nav li a {
    display: block;
    padding: 9px 16px;
    color: var(--color-text);
    font-size: 0.88rem;
}
.sub-nav li a:hover { background: var(--color-bg); color: var(--color-primary-dark); }

/* ---------------- Layout helpers ---------------- */

.main-content { padding: 24px 0 60px; min-height: 50vh; }

.section { margin-bottom: 44px; }
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-head h2 {
    font-size: 1.25rem;
    font-weight: 800;
}
.section-head .more-link {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.breadcrumb {
    font-size: 0.82rem;
    color: var(--color-text-light);
    margin-bottom: 16px;
}
.breadcrumb a { color: var(--color-text-light); }
.breadcrumb a:hover { color: var(--color-primary); }

/* ---------------- Hero ---------------- */

.hero {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: clamp(28px, 6vw, 56px);
    margin-bottom: 32px;
    text-align: center;
}
.hero h1 {
    font-size: clamp(1.4rem, 4vw, 2.1rem);
    font-weight: 900;
    margin-bottom: 8px;
}
.hero p {
    color: rgba(255,255,255,0.9);
    font-size: clamp(0.85rem, 2vw, 1rem);
    margin: 0;
}

/* ---------------- Quick category tiles ---------------- */

.cat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
}
.cat-tile {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 8px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    transition: transform .15s, box-shadow .15s;
}
.cat-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); border-color: var(--color-primary); }
.cat-tile.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ---------------- Product grid / card ---------------- */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(234px, 1fr));
    gap: 18px;
}

.product-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .18s, box-shadow .18s;
    position: relative;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.product-thumb-wrap { position: relative; aspect-ratio: 1 / 1; background: #f1f2f0; overflow: hidden; }
.product-thumb { width: 100%; height: 100%; object-fit: cover; }

.badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    z-index: 2;
}
.badge-new { background: var(--color-accent); }
.badge-best { background: var(--color-primary-dark); }

.product-body { padding: 12px 14px 14px; display: flex; flex-direction: column; flex-grow: 1; gap: 6px; }
.product-cat { font-size: 0.72rem; color: var(--color-text-light); }
.product-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #111;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.5em;
}
.product-desc {
    font-size: 0.82rem;
    color: var(--color-text-light);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-actions { margin-top: auto; display: flex; gap: 6px; padding-top: 6px; }

.btn {
    display: inline-block;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    border: 0;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary { background: var(--color-primary); color: #fff; flex: 1; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-outline { background: #fff; color: var(--color-text); border: 1px solid var(--color-border); flex: 1; }
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-accent { background: var(--color-accent); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 0.78rem; }
.btn-danger { background: #dc3545; color: #fff; }

.ad-notice {
    font-size: 0.7rem;
    color: #888;
    background: #f1f3f5;
    padding: 6px 8px;
    border-radius: 6px;
    line-height: 1.35;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-light);
}

/* ---------------- Product detail page ---------------- */

.detail-wrap {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: clamp(16px, 4vw, 32px);
}
.detail-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 4px; }
.detail-wrap > .product-cat { margin-bottom: 18px; }

.detail-media { display: flex; gap: 16px; margin-bottom: 22px; align-items: flex-start; }
.detail-media-main { flex: 0 0 35%; max-width: 35%; }
.detail-media-ingredient { flex: 0 0 65%; max-width: 65%; }
.detail-media.no-ingredient .detail-media-main { flex: 0 0 100%; max-width: 420px; }
.detail-media-main img,
.detail-media-ingredient img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius);
    background: #f1f2f0;
}
.detail-media-main img { aspect-ratio: 1/1; object-fit: cover; }

.detail-desc { white-space: pre-line; color: #444; line-height: 1.7; margin: 16px 0; }
.detail-section { margin-top: 28px; }
.detail-section h3 { font-size: 1.05rem; font-weight: 700; border-left: 4px solid var(--color-primary); padding-left: 10px; }
.detail-img { width: 100%; border-radius: var(--radius); margin-bottom: 14px; }
.detail-meta p { color: #333; line-height: 1.7; }

@media (max-width: 640px) {
    .detail-media { flex-direction: column; }
    .detail-media-main, .detail-media-ingredient { flex: 1 1 auto; max-width: 100%; }
}

/* ---------------- Pagination ---------------- */

.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 6px;
    border-radius: 8px;
    font-size: 0.85rem;
    border: 1px solid var(--color-border);
    background: #fff;
}
.pagination .current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination a:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* ---------------- Banner ---------------- */
.banner-slot { margin-bottom: 20px; }
.banner-slider-container { position: relative; }
.banner-slide { display: none; }
.banner-slide:first-child { display: block; }

/* ---------------- Footer ---------------- */

.site-footer { background: #1f2723; color: #b7c1bc; padding: 32px 0; margin-top: 40px; }
.footer-inner { display: flex; flex-direction: column; gap: 10px; }
.footer-links a { color: #b7c1bc; margin-right: 16px; font-size: 0.85rem; }
.footer-links a:hover { color: #fff; }
.footer-copy { margin: 0; font-size: 0.8rem; }

/* ---------------- Forms (public: search etc.) ---------------- */

.search-summary { margin-bottom: 18px; color: var(--color-text-light); font-size: 0.9rem; }

/* ---------------- Responsive ---------------- */

@media (max-width: 860px) {
    .search-form { max-width: none; order: 4; flex: 0 0 100%; margin-left: 0; }
    .header-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; }
    .nav-toggle { display: flex; }
    .main-nav {
        max-height: 0;
        overflow: hidden;
        transition: max-height .25s ease;
    }
    .main-nav.open { max-height: 600px; }
    .cat-nav { flex-direction: column; }
    .sub-nav { position: static; box-shadow: none; display: none; padding-left: 12px; }
    .has-sub.open .sub-nav { display: block; }
}

@media (max-width: 480px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .product-title { font-size: 0.85rem; min-height: 2.3em; }
}

/* ---------------- Admin ---------------- */

.admin-body { background: #eef1f0; min-height: 100vh; }
.admin-wrap { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 220px;
    background: #1f2723;
    color: #cfd8d4;
    flex-shrink: 0;
    padding: 20px 0;
}
.admin-sidebar .brand { padding: 0 20px 18px; font-weight: 800; color: #fff; font-size: 1.1rem; border-bottom: 1px solid #33403a; margin-bottom: 10px; }
.admin-sidebar a {
    display: block;
    padding: 10px 20px;
    font-size: 0.88rem;
    color: #cfd8d4;
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: #0f7a5c; color: #fff; }
.admin-main { flex: 1; padding: 26px; min-width: 0; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.admin-card { background: #fff; border-radius: 10px; padding: 22px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 10px; padding: 18px; box-shadow: var(--shadow-sm); }
.stat-card .num { font-size: 1.6rem; font-weight: 800; color: var(--color-primary-dark); }
.stat-card .label { font-size: 0.82rem; color: var(--color-text-light); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.admin-table th, .admin-table td { padding: 10px; border-bottom: 1px solid #eee; text-align: left; vertical-align: middle; }
.admin-table th { background: #f5f6f5; }
.admin-table img.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.admin-table a.sort-link { color: inherit; }
.admin-table a.sort-link:hover { color: var(--color-primary); }

.form-grid { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 200px; }
.form-grid label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.form-grid input[type=text], .form-grid input[type=number], .form-grid input[type=password],
.form-grid input[type=file], .form-grid select, .form-grid textarea {
    width: 100%; padding: 9px 10px; border: 1px solid var(--color-border); border-radius: 6px; font-family: inherit; font-size: 0.9rem;
}
.alert { padding: 10px 14px; border-radius: 8px; font-size: 0.88rem; margin-bottom: 16px; }
.alert-error { background: #fdecea; color: #b3261e; }
.alert-success { background: #e7f6ec; color: #1e7a3c; }

.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-row { display: flex; align-items: center; gap: 10px; background: #fafbfa; border: 1px solid var(--color-border); border-radius: 8px; padding: 8px 12px; }
.order-row .grow { flex: 1; }
.order-row img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }

@media (max-width: 860px) {
    .admin-wrap { flex-direction: column; }
    .admin-sidebar { width: 100%; display: flex; overflow-x: auto; padding: 10px 0; }
    .admin-sidebar .brand { display: none; }
    .admin-sidebar a { white-space: nowrap; }
}
