/* ระบบเผยแพร่หลักเกณฑ์การบริหารทรัพยากรบุคคล */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --text: #1f2937;
    --muted: #6b7280;
    --bg: #f8fafc;
    --card: #ffffff;
    --border: #e5e7eb;
    --radius: 14px;
    --shadow: 0 4px 20px rgba(0,0,0,0.06);
    --shadow-hover: 0 8px 30px rgba(37,99,235,0.12);
}

* { box-sizing: border-box; }

body {
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    margin: 0;
    line-height: 1.6;
}

a { text-decoration: none; color: var(--primary); }

.container { max-width: 1140px; margin: 0 auto; padding: 0 16px; }

/* Navbar */
.navbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 8px rgba(0,0,0,0.03);
    position: sticky; top: 0; z-index: 50;
}
.navbar .inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { font-weight: 600; font-size: 1.1rem; color: var(--text); display: flex; align-items: center; gap: 10px; }
.brand i { color: var(--primary); font-size: 1.4rem; }
.brand-logo { height: 34px; width: auto; border-radius: 6px; }
.nav-links { display: flex; gap: 6px; margin-left: auto; }
.nav-links a {
    color: var(--muted); padding: 8px 14px; border-radius: 10px; font-weight: 500;
    transition: all .15s ease;
}
.nav-links a:hover, .nav-links a.active { background: var(--primary-light); color: var(--primary); }

/* Hero */
.hero { padding: 56px 0 40px; text-align: center; }
.hero h1 { font-size: 2rem; font-weight: 600; margin: 0 0 12px; }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 640px; margin: 0 auto 28px; }

/* Search */
.search-hint {
    max-width: 760px;
    margin: 0 auto 10px;
    color: var(--muted);
    font-size: .86rem;
    text-align: center;
}
.search-box { max-width: 760px; margin: 0 auto; position: relative; }
.search-form { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.search-box input {
    width: auto; flex: 1 1 auto; min-width: 0; padding: 11px 16px 11px 46px; font-size: .94rem;
    border: 1px solid var(--border); border-radius: 14px 0 0 14px;
    box-shadow: var(--shadow); outline: none; transition: all .15s;
    font-family: inherit;
}
.search-box input:focus { border-color: var(--primary); box-shadow: var(--shadow-hover); }
.search-box .fa-search { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.category-filter {
    width: 180px;
    flex: 0 0 180px;
    padding: 11px 38px 11px 14px;
    border: 1px solid rgba(37,99,235,0.14);
    border-radius: 0;
    background: linear-gradient(180deg, #fff, #fbfdff);
    color: var(--text);
    box-shadow: 0 3px 14px rgba(15, 23, 42, 0.05);
    font-family: inherit;
    font-size: .92rem;
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 12px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}
.category-filter:focus { outline: none; border-color: var(--primary); box-shadow: var(--shadow-hover); }
.search-submit {
    flex: 0 0 auto;
    padding: 11px 18px;
    border: 1px solid var(--primary);
    border-radius: 0 14px 14px 0;
    background: linear-gradient(135deg, #1d4ed8, var(--primary-dark));
    color: #fff;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.search-submit:hover { filter: brightness(1.03); box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.search-submit:active { transform: translateY(0); filter: brightness(.98); }
.search-submit i { margin-right: 6px; }

.results-status {
    max-width: 760px;
    margin: 0 auto 12px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: .9rem;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255,255,255,.85);
    box-shadow: var(--shadow);
}
.spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(37,99,235,.18);
    border-top-color: var(--primary);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.autocomplete {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden; z-index: 60; display: none;
}
.autocomplete.show { display: block; }
.autocomplete a { display: block; padding: 12px 18px; color: var(--text); border-bottom: 1px solid var(--border); }
.autocomplete a:last-child { border-bottom: none; }
.autocomplete a:hover { background: var(--primary-light); }
.autocomplete .cat { font-size: .8rem; color: var(--muted); }
.autocomplete-hint {
    padding: 14px 18px;
    color: var(--muted);
    background: linear-gradient(180deg, #fff, #fbfdff);
    border-bottom: 1px solid var(--border);
}
.autocomplete-hint strong {
    display: block;
    color: var(--text);
    font-size: .92rem;
    margin-bottom: 4px;
}
.autocomplete-hint div {
    font-size: .82rem;
    line-height: 1.55;
}
.autocomplete-hint + a {
    border-top: 1px solid var(--border);
}
.autocomplete a .ac-title {
    font-size: .95rem;
    line-height: 1.35;
    color: var(--text);
    margin-bottom: 4px;
}
.autocomplete a .ac-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: .78rem;
    color: var(--muted);
}
.autocomplete a .ac-meta span {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
}

/* Section */
.section { padding: 32px 0; }
.section-title { font-size: 1.35rem; font-weight: 600; margin: 0 0 20px; display: flex; align-items: center; gap: 10px; }
.section-title i { color: var(--primary); }

/* Category chips */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.cat-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; box-shadow: var(--shadow); transition: all .15s; display: block; color: var(--text);
}
.cat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--primary); }
.cat-card .icon { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 14px; }
.cat-card h3 { margin: 0 0 4px; font-size: 1.05rem; font-weight: 600; }
.cat-card .desc { color: var(--muted); font-size: .9rem; margin: 0; }
.cat-card .count { margin-top: 12px; font-size: .8rem; color: var(--primary); font-weight: 500; }

/* Doc cards */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.doc-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden; transition: all .15s; display: flex; flex-direction: column;
}
.doc-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.doc-card .body { padding: 22px; flex: 1; }
.doc-card .badge-cat { display: inline-block; background: var(--primary-light); color: var(--primary); font-size: .78rem; font-weight: 500; padding: 4px 12px; border-radius: 20px; margin-bottom: 12px; }
.doc-card h3 { margin: 0 0 10px; font-size: 1.05rem; font-weight: 600; line-height: 1.4; }
.doc-card .excerpt { color: var(--muted); font-size: .9rem; margin: 0 0 16px; }
.doc-card .meta { display: flex; align-items: center; gap: 16px; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 14px; }
.doc-card .meta i { margin-right: 5px; }

mark { background: #fde68a; padding: 0 2px; border-radius: 3px; }

/* Detail */
.detail-wrap { max-width: 820px; margin: 0 auto; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); }
.detail-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px; }
.detail-card h1 { font-size: 1.6rem; font-weight: 600; margin: 0 0 14px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 18px; font-size: .85rem; color: var(--muted); margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.detail-body { font-size: 1rem; line-height: 1.8; }
.detail-body img { max-width: 100%; border-radius: 10px; }
.keywords { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 8px; }
.keywords .kw { background: var(--bg); border: 1px solid var(--border); padding: 5px 12px; border-radius: 20px; font-size: .82rem; color: var(--muted); }

.attach-list { margin-top: 28px; }
.attach-list h4 { font-size: 1rem; font-weight: 600; margin: 0 0 14px; }
.attach-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; transition: all .15s; }
.attach-item:hover { border-color: var(--primary); background: var(--primary-light); }
.attach-item .fi { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.attach-item .info { flex: 1; min-width: 0; }
.attach-item .info .nm { font-weight: 500; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-item .info .sz { font-size: .78rem; color: var(--muted); }

/* Published document table (circular book list style) */
.table-responsive { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.pub-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.pub-table thead th {
    background: var(--primary); color: #fff; font-weight: 500; text-align: left;
    padding: 14px 16px; white-space: nowrap; font-size: .88rem;
}
.pub-table tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.pub-table tbody tr:last-child td { border-bottom: none; }
.pub-table tbody tr:hover { background: var(--primary-light); }
.pub-table tbody tr.is-updating { opacity: .45; transition: opacity .12s ease; }
.doc-empty {
    padding: 18px 20px;
    text-align: center;
    color: var(--muted);
    background: linear-gradient(180deg, #fff, #fbfdff);
    border-top: 1px solid var(--border);
}
.pub-table tbody .col-no { width: 80px; text-align: center; color: var(--muted); font-weight: 600; }
.pub-table tbody .col-book { width: 150px; font-family: monospace; font-size: .85rem; }
.pub-table tbody .col-date { width: 130px; white-space: nowrap; color: var(--muted); }
.pub-table tbody .col-org { width: 180px; }
.pub-table tbody .col-view { width: 110px; text-align: center; }
.pub-table tbody .sub-cat { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.pub-table .btn-view {
    display: inline-flex; align-items: center; gap: 6px; background: var(--primary); color: #fff;
    padding: 7px 14px; border-radius: 8px; font-size: .82rem; font-weight: 500; transition: all .15s;
}
.pub-table .btn-view:hover { background: var(--primary-dark); color: #fff; }
.pub-table .col-title a { font-weight: 500; color: var(--text); }
.pub-table .col-title a:hover { color: var(--primary); }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 8px; margin: 32px 0; }
.pagination a, .pagination span { padding: 9px 15px; border-radius: 10px; border: 1px solid var(--border); color: var(--muted); font-size: .9rem; }
.pagination a:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Footer */
.footer { background: var(--card); border-top: 1px solid var(--border); padding: 28px 0; margin-top: 48px; text-align: center; color: var(--muted); font-size: .88rem; }

/* Alert */
.flash { padding: 14px 20px; border-radius: 12px; margin: 0 0 20px; font-size: .92rem; }
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Responsive */
@media (max-width: 768px) {
    .nav-links a { padding: 8px 10px; font-size: .9rem; }
    .hero h1 { font-size: 1.6rem; }
    .detail-card { padding: 24px; }
    .doc-grid, .cat-grid { grid-template-columns: 1fr; }
    .search-form { flex-direction: column; align-items: stretch; }
    .search-box input,
    .category-filter,
    .search-submit {
        width: 100%;
        border-radius: 14px;
    }
    .search-box input { border-radius: 14px; }
    .category-filter {
        padding-right: 14px;
        background-image: none;
        appearance: auto;
    }
    .search-box .fa-search { top: 24px; }
    .results-status { width: 100%; justify-content: center; }
}
