/* =====================================================
   식약처 관리시스템 · Design System
   - Pretendard 타이포그래피 + 디자인 토큰 + 기본 컴포넌트
   ===================================================== */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

:root {
    /* ---- Color: Surface & Border ---- */
    --color-bg:             #f6f7f9;
    --color-surface:        #ffffff;
    --color-surface-alt:    #f9fafb;
    --color-border:         #e5e7eb;
    --color-border-strong:  #d1d5db;
    --color-divider:        #f0f2f5;

    /* ---- Color: Text ---- */
    --color-text:           #0f172a;
    --color-text-secondary: #475569;
    --color-text-tertiary:  #94a3b8;
    --color-text-inverse:   #ffffff;

    /* ---- Color: Brand ---- */
    --color-primary:        #2563eb;
    --color-primary-hover:  #1d4ed8;
    --color-primary-soft:   #eff6ff;
    --color-primary-border: #bfdbfe;

    /* ---- Color: Semantic ---- */
    --color-success:        #059669;
    --color-success-soft:   #ecfdf5;
    --color-warning:        #d97706;
    --color-warning-soft:   #fffbeb;
    --color-danger:         #dc2626;
    --color-danger-soft:    #fef2f2;
    --color-info:           #0891b2;
    --color-info-soft:      #ecfeff;

    /* ---- Sidebar ---- */
    --sidebar-bg:           #0f172a;
    --sidebar-bg-hover:     rgba(255,255,255,0.06);
    --sidebar-bg-active:    rgba(59,130,246,0.15);
    --sidebar-text:         rgba(226,232,240,0.70);
    --sidebar-text-active:  #ffffff;
    --sidebar-accent:       #60a5fa;

    /* ---- Spacing ---- */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  20px;
    --space-6:  24px;
    --space-8:  32px;
    --space-10: 40px;

    /* ---- Radius ---- */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 999px;

    /* ---- Shadow ---- */
    --shadow-xs: 0 1px 2px rgba(15,23,42,0.04);
    --shadow-sm: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-md: 0 4px 8px -2px rgba(15,23,42,0.08), 0 2px 4px -2px rgba(15,23,42,0.04);
    --shadow-lg: 0 12px 24px -6px rgba(15,23,42,0.10), 0 4px 8px -4px rgba(15,23,42,0.06);

    /* ---- Typography ---- */
    --font-sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', 'Malgun Gothic', sans-serif;
    --font-mono: 'D2Coding', 'JetBrains Mono', Consolas, 'Courier New', monospace;

    --text-xs:  12px;
    --text-sm:  13px;
    --text-md:  14px;
    --text-lg:  16px;
    --text-xl:  18px;
    --text-2xl: 20px;
    --text-3xl: 24px;
    --text-4xl: 28px;

    --leading-tight: 1.3;
    --leading-normal: 1.55;
    --leading-relaxed: 1.7;
}

/* =====================================================
   Base
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-weight: 400;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

/* =====================================================
   Typography
   ===================================================== */
h1, h2, h3, h4 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--color-text);
}
.ds-page-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0 0 var(--space-6) 0;
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.ds-page-title .title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 18px;
}

/* =====================================================
   Card / Panel
   ===================================================== */
.ds-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-6);
    box-shadow: var(--shadow-xs);
}
.ds-card + .ds-card { margin-top: var(--space-4); }

/* =====================================================
   Button
   ===================================================== */
.ds-btn, button.ds-btn, a.ds-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: var(--text-md);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}
.ds-btn:disabled, .ds-btn.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}
.ds-btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.ds-btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.ds-btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border-strong);
}
.ds-btn-secondary:hover { background: var(--color-surface-alt); border-color: var(--color-text-tertiary); }
.ds-btn-success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.ds-btn-success:hover { filter: brightness(0.94); }
.ds-btn-danger  { background: var(--color-danger);  color: #fff; border-color: var(--color-danger); }
.ds-btn-danger:hover { filter: brightness(0.94); }
.ds-btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: transparent;
}
.ds-btn-ghost:hover { background: var(--color-surface-alt); color: var(--color-text); }
.ds-btn-sm { padding: 5px 10px; font-size: var(--text-sm); border-radius: var(--radius-sm); }
.ds-btn-lg { padding: 11px 22px; font-size: var(--text-lg); }

/* =====================================================
   Form
   ===================================================== */
.ds-input, .ds-select, .ds-textarea {
    display: inline-block;
    padding: 8px 12px;
    font-family: inherit;
    font-size: var(--text-md);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    line-height: 1.4;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: var(--shadow-xs);
}
.ds-input:focus, .ds-select:focus, .ds-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.ds-input::placeholder { color: var(--color-text-tertiary); }
.ds-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-right: var(--space-2);
}

/* 검색 바 컨테이너 */
.ds-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: center;
    padding: var(--space-4) var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    margin-bottom: var(--space-5);
}
.ds-filter-group { display: inline-flex; align-items: center; gap: 8px; }

/* =====================================================
   Table
   ===================================================== */
.ds-table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.ds-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-md);
}
.ds-table thead th {
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    font-weight: 600;
    font-size: var(--text-sm);
    padding: 12px 14px;
    text-align: left;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.ds-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-divider);
    color: var(--color-text);
    vertical-align: middle;
}
.ds-table tbody tr:last-child td { border-bottom: none; }
.ds-table tbody tr { transition: background 0.12s ease; }
.ds-table tbody tr:hover { background: var(--color-surface-alt); }
.ds-table .text-center { text-align: center; }
.ds-table .text-right  { text-align: right; }

/* =====================================================
   Badge
   ===================================================== */
.ds-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: -0.01em;
    border: 1px solid transparent;
}
.ds-badge-neutral { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.ds-badge-info    { background: var(--color-info-soft); color: var(--color-info); border-color: #bae6fd; }
.ds-badge-success { background: var(--color-success-soft); color: var(--color-success); border-color: #a7f3d0; }
.ds-badge-warning { background: var(--color-warning-soft); color: var(--color-warning); border-color: #fde68a; }
.ds-badge-danger  { background: var(--color-danger-soft); color: var(--color-danger); border-color: #fecaca; }

/* =====================================================
   Pagination
   ===================================================== */
.ds-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: var(--space-6);
}
.ds-pagination a, .ds-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.15s ease;
}
.ds-pagination a:hover { background: var(--color-surface-alt); color: var(--color-text); border-color: var(--color-border-strong); }
.ds-pagination a.active, .ds-pagination span.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.ds-pagination a.disabled, .ds-pagination span.disabled {
    color: var(--color-text-tertiary);
    cursor: not-allowed;
    pointer-events: none;
    background: var(--color-surface-alt);
}

/* =====================================================
   Info bar / Toolbar
   ===================================================== */
.ds-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}
.ds-toolbar-left, .ds-toolbar-right { display: inline-flex; gap: 8px; align-items: center; }
.ds-count {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}
.ds-count strong {
    color: var(--color-primary);
    font-weight: 700;
    font-size: var(--text-md);
    margin: 0 2px;
}

/* =====================================================
   Legacy Compatibility Layer
   ----
   기존 템플릿의 공용 클래스명을 그대로 두고도 디자인 토큰이
   적용되도록 덮어쓰는 레이어. 새 컴포넌트는 ds-* 를 사용.
   ===================================================== */

/* ---- body font (페이지 inline style 덮어쓰기) ---- */
body {
    font-family: var(--font-sans) !important;
    background: var(--color-bg) !important;
    color: var(--color-text);
    letter-spacing: -0.01em;
}
.container {
    background: transparent !important;
    padding: 28px 32px !important;
}

/* ---- Page title (h1) ----
   관리자 페이지의 .container 내부 h1 에만 적용.
   올바로 모바일/공개 페이지의 .header h1 등은 제외.
*/
.container > h1 {
    font-family: var(--font-sans);
    font-size: 26px !important;
    font-weight: 700 !important;
    letter-spacing: -0.03em !important;
    color: var(--color-text) !important;
    border-bottom: 1px solid var(--color-border) !important;
    padding-bottom: 16px !important;
    margin-bottom: 24px !important;
}

/* ---- 올바로 모바일 공개 페이지 헤더 가독성 보강 ---- */
.header h1 {
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.header p {
    color: rgba(255,255,255,0.92) !important;
    font-weight: 500 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: var(--font-sans) !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid transparent !important;
    padding: 0 16px !important;
    height: 34px !important;
    line-height: 1 !important;
    font-size: var(--text-md) !important;
    white-space: nowrap !important;
    vertical-align: middle;
    text-decoration: none !important;
    transition: background 0.15s ease, border-color 0.15s ease, filter 0.15s ease !important;
    box-shadow: var(--shadow-xs);
    box-sizing: border-box;
}
.btn-primary {
    background: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
    color: #fff !important;
}
.btn-primary:hover { background: var(--color-primary-hover) !important; border-color: var(--color-primary-hover) !important; }
.btn-success {
    background: var(--color-success) !important;
    border-color: var(--color-success) !important;
    color: #fff !important;
}
.btn-success:hover { filter: brightness(0.94); }
.btn-danger {
    background: var(--color-danger) !important;
    border-color: var(--color-danger) !important;
    color: #fff !important;
}
.btn-danger:hover { filter: brightness(0.94); }
.btn-disabled {
    background: #e5e7eb !important;
    color: var(--color-text-tertiary) !important;
    border-color: #e5e7eb !important;
}

/* ---- Search / Filter form ---- */
.search-form {
    background: var(--color-surface) !important;
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius-lg) !important;
    padding: 16px 20px !important;
    box-shadow: var(--shadow-xs);
}
.search-form label {
    font-weight: 600 !important;
    color: var(--color-text-secondary) !important;
    font-size: var(--text-sm) !important;
}
.search-form input[type="text"],
.search-form select,
input[type="text"],
input[type="number"],
select {
    font-family: var(--font-sans);
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--color-border-strong) !important;
    padding: 7px 11px !important;
    font-size: var(--text-md) !important;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-form input[type="text"]:focus,
.search-form select:focus,
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15) !important;
}

/* ---- Info bar ---- */
.info-bar {
    background: transparent !important;
    border-radius: 0 !important;
    padding: 4px 0 !important;
    margin-bottom: 14px !important;
}
.total-count {
    font-size: var(--text-sm) !important;
    color: var(--color-text-secondary) !important;
    font-weight: 500 !important;
}
.total-count strong {
    color: var(--color-primary) !important;
    font-size: var(--text-lg) !important;
}
.selected-count {
    color: var(--color-text-secondary) !important;
    font-size: var(--text-sm) !important;
}

/* ---- Data table ---- */
.data-table {
    background: var(--color-surface);
    border: 1px solid var(--color-border) !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    table-layout: fixed;
}
.data-table th,
.data-table td {
    border: none !important;
    border-bottom: 1px solid var(--color-divider) !important;
    padding: 11px 14px !important;
    font-size: var(--text-md) !important;
    line-height: 1.5;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}
.data-table thead th {
    background: var(--color-surface-alt) !important;
    color: var(--color-text-secondary) !important;
    font-weight: 600 !important;
    font-size: var(--text-sm) !important;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--color-border) !important;
    text-transform: none;
    white-space: nowrap !important;
}
.data-table tbody tr:last-child td { border-bottom: none !important; }
.data-table tr:nth-child(even) { background: transparent !important; }
.data-table tbody tr:hover { background: var(--color-surface-alt) !important; }

/* ---- Pagination ---- */
.pagination a,
.pagination span {
    border-radius: var(--radius-md) !important;
    font-weight: 500 !important;
    border: 1px solid var(--color-border) !important;
    color: var(--color-text-secondary) !important;
    background: var(--color-surface) !important;
    min-width: 34px !important;
    height: 34px !important;
    padding: 0 10px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
}
.pagination a.active,
.pagination span.active {
    background: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
    color: #fff !important;
}
.pagination a:hover:not(.disabled):not(.active) {
    background: var(--color-surface-alt) !important;
    color: var(--color-text) !important;
    border-color: var(--color-border-strong) !important;
}

/* ---- Status / Review badges (색감만 미세 조정, 유지) ---- */
.status-badge {
    border-radius: var(--radius-full) !important;
    font-weight: 600 !important;
    font-size: 11px !important;
    letter-spacing: -0.01em;
    padding: 3px 10px !important;
    border: 1px solid transparent;
}
.status-ready      { background: #fef3c7 !important; color: #92400e !important; border-color: #fde68a; }
.status-processing { background: #dbeafe !important; color: #1e40af !important; border-color: #bfdbfe; }
.status-completed  { background: #d1fae5 !important; color: #065f46 !important; border-color: #a7f3d0; }
.status-error      { background: #fee2e2 !important; color: #991b1b !important; border-color: #fecaca; }

.review-status-pending      { background: #f1f5f9 !important; color: #475569 !important; border: 1px solid #e2e8f0; }
.review-status-in_progress  { background: #e0f2fe !important; color: #0369a1 !important; border: 1px solid #bae6fd; }
.review-status-completed    { background: #d1fae5 !important; color: #065f46 !important; border: 1px solid #a7f3d0; }
.review-status-review_required {
    background: #fee2e2 !important;
    color: #991b1b !important;
    border: 1px solid #fecaca;
}
