/*
 * 사내 파일 서버 스타일시트
 *
 * 엑스서버에는 Node 가 없어 자산 빌드를 할 수 없으므로 Vite/Tailwind 를
 * 쓰지 않고 이 파일 하나로 끝낸다. FTP 로 올리면 그대로 동작한다.
 */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-alt: #f0f2f5;
    --border: #dfe3e8;
    --text: #1b1f24;
    --text-dim: #626b75;
    --accent: #1f6feb;
    --accent-dark: #1857b8;
    --danger: #c0392b;
    --danger-bg: #fdecea;
    --ok: #1a7f4b;
    --ok-bg: #e7f5ed;
    --warn: #9a6700;
    --warn-bg: #fff8e1;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 22, 26, .06), 0 2px 8px rgba(16, 22, 26, .04);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171a;
        --surface: #1c2026;
        --surface-alt: #232830;
        --border: #313842;
        --text: #e6e9ed;
        --text-dim: #99a3ae;
        --accent: #4d8ef7;
        --accent-dark: #3d7ae0;
        --danger: #f26b5e;
        --danger-bg: #3a2320;
        --ok: #4cc38a;
        --ok-bg: #1e3329;
        --warn: #e0b341;
        --warn-bg: #352c14;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .2);
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
        "Noto Sans JP", "Noto Sans KR", "Malgun Gothic", "Yu Gothic UI", Meiryo,
        Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 레이아웃 ---------- */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.brand {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.nav { display: flex; gap: 16px; flex: 1; min-width: 0; }
.nav a { color: var(--text-dim); font-size: 13px; white-space: nowrap; }
.nav a:hover, .nav a.active { color: var(--accent); text-decoration: none; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-dim);
    white-space: nowrap;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 64px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }

/* ---------- 카드 / 패널 ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    font-weight: 600;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.card-body { padding: 16px; }

/* ---------- 이동 경로 ---------- */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 12px;
}
.breadcrumb span.sep { opacity: .5; }

/* ---------- 표 ---------- */

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    font-weight: 600;
    color: var(--text-dim);
    font-size: 12px;
    background: var(--surface-alt);
    white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }

td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.nowrap, th.nowrap { white-space: nowrap; }

.name-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.name-cell .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.snippet {
    margin: 4px 0 0 24px;
    font-size: 12px;
    color: var(--text-dim);
    overflow-wrap: anywhere;
}
.snippet mark { background: #fde68a; color: inherit; padding: 0 1px; border-radius: 2px; }

/* 검색어가 파일 안의 어디에서 걸렸는지 (몇 페이지·몇 번째 슬라이드·어느 시트) */
.snippet-at {
    display: inline-block;
    margin-right: 6px;
    padding: 0 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface-alt);
    font-size: 11px;
    line-height: 17px;
    white-space: nowrap;
    vertical-align: 1px;
}

/* 걸린 대목의 앞뒤 구간 (앞 슬라이드·뒤 슬라이드) */
.snippet-near {
    margin: 2px 0 0 24px;
    font-size: 11px;
    color: var(--text-dim);
    opacity: .8;
    overflow-wrap: anywhere;
}

.snippet-near .arrow { display: inline-block; width: 11px; }
.snippet-near .snippet-at { font-size: 10px; padding: 0 4px; line-height: 15px; }

.icon { flex: none; width: 16px; text-align: center; opacity: .75; }

.empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

/* ---------- 버튼 ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 폼 ---------- */

.field { margin-bottom: 16px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

label.inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    margin-bottom: 0;
}

input[type=text], input[type=email], input[type=password], input[type=search],
input[type=date], input[type=number], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}

textarea { resize: vertical; min-height: 72px; }

.hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0 20px;
}

/* ---------- 알림 ---------- */

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid transparent;
}
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- 배지 ---------- */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--surface-alt);
    color: var(--text-dim);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

/* ---------- 로그인 ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 32px 28px;
}

.login-card h1 { font-size: 18px; margin-bottom: 4px; text-align: center; }
.login-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }

/* ---------- 업로드 ---------- */

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    color: var(--text-dim);
    background: var(--surface-alt);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dropzone.dragover { border-color: var(--accent); background: var(--surface); color: var(--accent); }
.dropzone strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 6px; }

.queue { list-style: none; margin: 16px 0 0; padding: 0; }

.queue li {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 10px;
    background: var(--surface);
}

.queue-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 8px;
}
.queue-name { font-weight: 600; word-break: break-all; }
.queue-meta { color: var(--text-dim); font-size: 12px; white-space: nowrap; }

.progress {
    height: 6px;
    background: var(--surface-alt);
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width .2s;
}
.progress-bar.done { background: var(--ok); }
.progress-bar.failed { background: var(--danger); }

.queue-status { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.queue-status.failed { color: var(--danger); }
.queue-status.done { color: var(--ok); }

/* ---------- 상세 / 정의 목록 ---------- */

dl.detail { margin: 0; display: grid; grid-template-columns: 160px 1fr; gap: 0; }
dl.detail dt {
    padding: 8px 0;
    color: var(--text-dim);
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
dl.detail dd {
    padding: 8px 0;
    margin: 0;
    border-bottom: 1px solid var(--border);
    word-break: break-all;
}
dl.detail dt:last-of-type, dl.detail dd:last-of-type { border-bottom: none; }

@media (max-width: 640px) {
    dl.detail { grid-template-columns: 1fr; }
    dl.detail dt { border-bottom: none; padding-bottom: 0; }
}

code, .mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
    background: var(--surface-alt);
    padding: 1px 5px;
    border-radius: 4px;
    word-break: break-all;
}

/* ---------- 통계 ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.stat {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    background: var(--surface);
}
.stat .k { font-size: 12px; color: var(--text-dim); }
.stat .v { font-size: 18px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- 페이지네이션 ---------- */

.pagination {
    display: flex;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 16px 0 0;
    flex-wrap: wrap;
    font-size: 13px;
}
.pagination li span, .pagination li a {
    display: block;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}
.pagination li a:hover { background: var(--surface-alt); text-decoration: none; }
.pagination .active span { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .disabled span { opacity: .4; }
.pagination svg { width: 14px; height: 14px; }

/* ---------- 필터 바 ---------- */

.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filter-bar .field { margin-bottom: 0; }
.filter-bar .field.grow { flex: 1; min-width: 180px; }

.inline-form { display: inline; }

/* 목록 위의 검색칸 + 검색 버튼 */
.search-form { display: flex; gap: 6px; align-items: center; }
.search-form input[type=search] { width: 200px; }
.search-form .btn { flex: none; }

@media (max-width: 640px) {
    .search-form input[type=search] { width: 140px; }
    .topbar-inner { gap: 12px; }
    .nav { gap: 12px; overflow-x: auto; }
    .topbar-user .uname { display: none; }
    .container { padding: 16px 12px 48px; }
}

/* ---------- 언어 전환 ---------- */

.lang-switch {
    display: flex;
    align-items: center;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface);
    flex: none;
}

.lang-switch .lang-current,
.lang-switch .lang-link {
    display: block;
    padding: 4px 9px;
    font-size: 12px;
    font-family: inherit;
    line-height: 1.5;
    white-space: nowrap;
    border: none;
    background: transparent;
}

.lang-switch .lang-current {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.lang-switch .lang-link {
    color: var(--text-dim);
    cursor: pointer;
}

.lang-switch .lang-link:hover {
    background: var(--surface-alt);
    color: var(--accent);
}

/* 로그인 화면에서는 카드 아래 가운데에 놓는다 */
.login-lang {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

/* ---------- 사외 공개 페이지 (공유 링크) ---------- */

.public-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.public-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 32px 28px;
}

.public-brand {
    font-weight: 700;
    font-size: 15px;
    text-align: center;
    color: var(--text-dim);
    margin-bottom: 20px;
}

.public-lead {
    text-align: center;
    font-size: 14px;
    margin: 0 0 20px;
}

.public-file {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-alt);
    padding: 16px;
    margin-bottom: 20px;
    text-align: center;
}

.public-file-name {
    font-weight: 600;
    word-break: break-all;
    margin-bottom: 4px;
}

.public-file-meta { font-size: 12px; color: var(--text-dim); }

.public-notes {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
}
.public-notes p { margin: 4px 0; }

.public-lang {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

/* ---------- 공유 링크 관리 ---------- */

.share-copy {
    display: flex;
    gap: 6px;
    align-items: center;
}

.share-copy input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    padding: 5px 8px;
    min-width: 0;
}

.share-copy .btn { flex: none; }

.share-fresh {
    border: 1px solid var(--ok);
    background: var(--ok-bg);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 20px;
}

.share-fresh-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ok);
    margin-bottom: 6px;
}

.share-fresh .hint { margin-bottom: 0; }
