/* ==========================================================================
   ระบบเสนอชื่อผู้ดำรงตำแหน่ง มหาวิทยาลัยศิลปากร
   ธีมมินิมอล — สีเขียววิริเดียน (Viridian) จากตราสัญลักษณ์มหาวิทยาลัย
   ========================================================================== */
:root {
    --su: #017369;
    --su-600: #01635a;
    --su-700: #014f48;
    --su-50: #eaf4f3;
    --su-100: #d3e9e6;
    --ink: #1c2a2f;
    --muted: #61707a;
    --line: #e3e8ea;
    --bg: #f5f7f7;
    --card: #ffffff;
    --amber: #b7791f;
    --amber-50: #fdf6e7;
    --red: #b42318;
    --red-50: #fdeeec;
    --radius: 14px;

    --bs-primary: var(--su);
    --bs-primary-rgb: 1, 115, 105;
    --bs-primary-text-emphasis: var(--su-700);
    --bs-primary-bg-subtle: var(--su-50);
    --bs-primary-border-subtle: var(--su-100);
    --bs-link-color: var(--su);
    --bs-link-color-rgb: 1, 115, 105;
    --bs-link-hover-color: var(--su-700);
    --bs-link-hover-color-rgb: 1, 79, 72;
    --bs-body-font-family: 'IBM Plex Sans Thai', 'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--bg);
    --bs-border-color: var(--line);
    --bs-border-radius: 10px;
    --bs-border-radius-lg: 14px;
    --bs-focus-ring-color: rgba(1, 115, 105, .22);
}

html, body { height: 100%; }
body {
    display: flex;
    flex-direction: column;
    font-size: .95rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
.app-main { flex: 1 0 auto; padding: 28px 0 48px; }
a { text-decoration: none; }
.min-w-0 { min-width: 0; }
.fw-semibold { font-weight: 600 !important; }

/* ---------- ปุ่ม ---------- */
.btn { border-radius: 10px; font-weight: 500; padding: .45rem .95rem; }
.btn-sm { border-radius: 8px; padding: .3rem .7rem; font-size: .85rem; }
.btn-lg { border-radius: 12px; padding: .7rem 1.3rem; }
.btn-primary {
    --bs-btn-bg: var(--su); --bs-btn-border-color: var(--su);
    --bs-btn-hover-bg: var(--su-600); --bs-btn-hover-border-color: var(--su-600);
    --bs-btn-active-bg: var(--su-700); --bs-btn-active-border-color: var(--su-700);
    --bs-btn-disabled-bg: var(--su); --bs-btn-disabled-border-color: var(--su);
}
.btn-outline-primary {
    --bs-btn-color: var(--su); --bs-btn-border-color: var(--su-100);
    --bs-btn-hover-bg: var(--su-50); --bs-btn-hover-color: var(--su-700); --bs-btn-hover-border-color: var(--su);
    --bs-btn-active-bg: var(--su-100); --bs-btn-active-color: var(--su-700); --bs-btn-active-border-color: var(--su);
}
.btn-light { --bs-btn-bg: #fff; --bs-btn-hover-bg: #f1f4f5; --bs-btn-border-color: var(--line); }
.btn-soft-danger { color: var(--red); background: #fff; border: 1px solid #f3d3cf; }
.btn-soft-danger:hover { background: var(--red-50); color: var(--red); border-color: #e9b4ad; }
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; border: 1px solid var(--line); background: #fff; }
.btn-icon:hover { background: #f1f4f5; }

.form-control, .form-select { border-radius: 10px; border-color: #d6dde0; padding: .5rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--su); box-shadow: 0 0 0 .2rem rgba(1,115,105,.15); }
.form-check-input:checked { background-color: var(--su); border-color: var(--su); }
.form-label { font-weight: 500; font-size: .88rem; color: #39474d; margin-bottom: .35rem; }
.form-text { color: var(--muted); }
.req { color: var(--red); }
.input-group-text { background: #f8fafa; border-color: #d6dde0; color: var(--muted); }

/* ---------- แถบนำทาง ---------- */
.app-nav {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.app-brand { display: flex; align-items: center; gap: 12px; color: var(--ink); min-width: 0; }
.app-brand img { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; }
.app-brand > span { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.app-brand-title { font-weight: 600; font-size: 1rem; white-space: nowrap; }
.app-brand-sub { font-size: .78rem; color: var(--muted); }
.app-nav-links { display: flex; gap: 4px; margin-left: 18px; }
.app-nav-links a {
    white-space: nowrap;
    color: var(--muted); padding: 8px 12px; border-radius: 9px; font-weight: 500; font-size: .9rem; display: inline-flex; gap: 7px; align-items: center;
}
.app-nav-links a:hover { color: var(--ink); background: #f2f5f5; }
.app-nav-links a.active { color: var(--su-700); background: var(--su-50); }
.app-nav-user { display: flex; align-items: center; gap: 10px; }
.app-nav-user .btn { white-space: nowrap; }
.app-user-chip .fw-semibold { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.app-user-chip { display: flex; align-items: center; gap: 9px; font-size: .86rem; }
.app-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--su-50); color: var(--su); display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 991.98px) {
    .app-nav .container-xl { flex-wrap: wrap; }
    .app-nav-collapse { flex-basis: 100%; }
    .app-nav-links { flex-direction: column; margin: 10px 0 0; }
    .app-nav-user { justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }
    .app-brand-title { white-space: normal; }
}

/* ---------- หัวเรื่องหน้า ---------- */
.page-head { margin-bottom: 22px; }
.page-title { font-size: 1.4rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.page-sub { color: var(--muted); margin-top: 4px; font-size: .9rem; }
.app-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.app-crumbs a { color: var(--muted); }
.app-crumbs a:hover { color: var(--su); }
.app-crumbs i { font-size: .65rem; opacity: .6; }

/* ---------- การ์ด ---------- */
.card-app { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-app-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.card-app-title { font-size: 1rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-app-title i { color: var(--su); }
.card-app-body { padding: 20px; }
.section-gap { margin-bottom: 20px; }

/* ---------- ตัวเลขสรุป ---------- */
.stat {
    background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; height: 100%;
}
.stat-label { color: var(--muted); font-size: .82rem; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 1.6rem; font-weight: 600; line-height: 1.2; margin-top: 4px; }
.stat-note { font-size: .8rem; color: var(--muted); }
.stat-accent { border-left: 3px solid var(--su); }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- สถานะ ---------- */
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.status-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-open { color: #08724a; background: #e7f6ee; border-color: #c4e8d4; }
.status-upcoming { color: #8a5a0b; background: var(--amber-50); border-color: #f2dfb5; }
.status-closed { color: #5c6870; background: #f0f2f3; border-color: #e1e5e7; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; background: #f1f4f5; color: #4a585e; border: 1px solid var(--line); white-space: nowrap; }
.pill-su { background: var(--su-50); color: var(--su-700); border-color: var(--su-100); }
.pill-warn { background: var(--amber-50); color: #8a5a0b; border-color: #f2dfb5; }
.pill-danger { background: var(--red-50); color: var(--red); border-color: #f3cfca; }
.pill-ok { background: #e7f6ee; color: #08724a; border-color: #c4e8d4; }

/* ---------- ตาราง ---------- */
.table-app { margin: 0; font-size: .9rem; }
.table-app > :not(caption) > * > * { padding: .7rem .9rem; border-color: var(--line); }
.table-app thead th { background: #f8fafa; color: #4a585e; font-weight: 600; font-size: .82rem; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table-app tbody tr:hover > * { background: #fafcfc; }
.table-app td.num, .table-app th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { max-height: 520px; overflow: auto; }
.table-scroll thead th { position: sticky; top: 0; z-index: 2; }
.progress-thin { height: 6px; background: #edf1f2; border-radius: 99px; overflow: hidden; }
.progress-thin > span { display: block; height: 100%; background: var(--su); border-radius: 99px; }

@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 10px; padding: 6px 4px; background: #fff; }
    .table-stack td { border: 0 !important; display: flex; justify-content: space-between; gap: 12px; text-align: right !important; padding: .35rem .7rem !important; }
    .table-stack td::before { content: attr(data-label); color: var(--muted); font-weight: 500; text-align: left; flex-shrink: 0; }
    .table-stack td.td-full { display: block; text-align: left !important; }
    .table-stack td.td-full::before { display: block; margin-bottom: 2px; }
}

/* ---------- ช่องค้นหา ---------- */
.search-box { position: relative; }
.search-box i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box .form-control { padding-left: 34px; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .empty-icon { display: flex; margin: 0 auto 8px; }
.empty-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--su-50); color: var(--su); display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; }

/* ---------- Modal ---------- */
.modal-content { border: 0; border-radius: 16px; }
.modal-header { border-bottom: 1px solid var(--line); padding: 16px 22px; }
.modal-title { font-size: 1.05rem; font-weight: 600; }
.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--line); padding: 14px 22px; }
.form-section-title { font-size: .8rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; margin: 4px 0 10px; }

/* ---------- Dropzone ---------- */
.dropzone { border: 1.5px dashed #b9cfcc; border-radius: 12px; background: #fafcfc; padding: 26px 16px; text-align: center; cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.dragover { border-color: var(--su); background: var(--su-50); }
.dropzone i { font-size: 1.8rem; color: var(--su); }

/* ---------- Toast ---------- */
#appToastArea { top: 64px !important; }
.toast { border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(16, 40, 45, .10); }
.toast-body { display: flex; gap: 10px; align-items: flex-start; }

/* ---------- ฟอร์มเสนอชื่อ (ผู้ใช้) ---------- */
.choice {
    display: flex; gap: 12px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 12px; padding: 14px 16px; cursor: pointer; background: #fff; height: 100%;
}
.choice:hover { border-color: #b9cfcc; }
.choice input { margin-top: .3rem; }
.choice.is-active { border-color: var(--su); background: var(--su-50); }
.choice.is-active.choice-no { border-color: #c9a227; background: var(--amber-50); }
.nominee { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; background: #fff; }
.nominee + .nominee { margin-top: 12px; }
.nominee-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.nominee-no { width: 28px; height: 28px; border-radius: 8px; background: var(--su-50); color: var(--su-700); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; }
.is-disabled-block { opacity: .45; pointer-events: none; }

/* ---------- Hero หน้าเข้าสู่ระบบ ---------- */
.auth-wrap { flex: 1 0 auto; display: flex; align-items: center; padding: 40px 0; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 36px 32px; }
.auth-logo { width: 84px; height: 84px; object-fit: contain; }
.auth-accent { height: 4px; width: 48px; background: var(--su); border-radius: 4px; margin: 14px auto 18px; }

/* ---------- Footer ---------- */
.app-footer { border-top: 1px solid var(--line); background: #fff; padding: 14px 0; font-size: .8rem; color: var(--muted); flex-shrink: 0; }

/* ---------- Topic card (ผู้ใช้) ---------- */
.topic { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px; height: 100%; display: flex; flex-direction: column; }
.topic-title { font-weight: 600; font-size: 1.02rem; margin: 10px 0 12px; line-height: 1.5; }
.topic-meta { font-size: .86rem; color: var(--muted); display: grid; gap: 6px; margin-bottom: 16px; }
.topic-meta i { color: var(--su); margin-right: 6px; }

/* ---------- ช่วยเหลือ ---------- */
.text-su { color: var(--su) !important; }
.bg-su-50 { background: var(--su-50) !important; }
.border-dashed { border-style: dashed !important; }
.small-muted { font-size: .82rem; color: var(--muted); }
.datepicker { z-index: 2060 !important; }
.swal2-popup { font-family: var(--bs-body-font-family); border-radius: 16px; }
.swal2-styled.swal2-confirm { background: var(--su) !important; border-radius: 10px !important; }
.swal2-styled.swal2-cancel { border-radius: 10px !important; }
.dropdown-menu { border-color: var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(16,40,45,.10); padding: 6px; }
.dropdown-item { border-radius: 8px; padding: .45rem .75rem; font-size: .9rem; }
.dropdown-item:active { background: var(--su); }
.nav-tabs-app { border-bottom: 1px solid var(--line); gap: 4px; }
.nav-tabs-app .nav-link { border: 0; color: var(--muted); font-weight: 500; padding: 10px 14px; border-bottom: 2px solid transparent; border-radius: 0; }
.nav-tabs-app .nav-link.active { color: var(--su-700); border-bottom-color: var(--su); background: transparent; }

/* ---------- ไทล์คำสั่ง ---------- */
.action-tile { border: 1px solid var(--line); background: #fff; transition: border-color .15s, background .15s; color: var(--ink); }
.action-tile:hover { border-color: var(--su); background: #fbfdfd; }

/* ---------- นับถอยหลัง ---------- */
.countdown { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: #eef2ff; color: #3730a3; font-size: .86rem; }
.countdown i { font-size: 1rem; }
.countdown b { font-variant-numeric: tabular-nums; }
.countdown [data-countdown] { font-weight: 600; font-variant-numeric: tabular-nums; }
.countdown.is-urgent { background: #fff1f2; color: #be123c; }
.countdown.is-ended { background: #f1f4f5; color: var(--muted); }
.countdown.is-open-soon { background: #fff7ed; color: #9a3412; }
.cd-big [data-countdown] { display: flex; gap: 6px; flex-wrap: wrap; }
.cd-part { display: inline-flex; flex-direction: column; align-items: center; min-width: 46px; padding: 4px 6px; border-radius: 8px; background: rgba(255,255,255,.75); line-height: 1.1; font-size: .72rem; font-weight: 500; }
.cd-part b { font-size: 1.15rem; font-weight: 700; }

/* ---------- แถบหัวข้อที่กำลังดำเนินการ ---------- */
.live-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.live-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.live-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, #6366f1, #06b6d4); }
.live-card.is-upcoming::before { background: linear-gradient(180deg, #f59e0b, #f97316); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 0 rgba(16,185,129,.6); animation: livePulse 1.8s infinite; display: inline-block; }
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,.55); } 70% { box-shadow: 0 0 0 8px rgba(16,185,129,0); } 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); } }
.progress-thin.vivid > span { background: linear-gradient(90deg, #6366f1, #06b6d4); }
