/* =========================================================
   E-Portfolio : สไตล์หลัก
   ========================================================= */
:root {
  --ink: #142235;
  --navy: #0f2a4a;
  --navy-2: #1b3d66;
  --gold: #c8902e;
  --paper: #f6f4ef;
  --line: #e6e1d6;
  --muted: #6b7380;
  --radius: 14px;
  --bs-primary: #1b3d66;
  --bs-primary-rgb: 27, 61, 102;
  --bs-body-font-family: 'IBM Plex Sans Thai', 'Sarabun', system-ui, sans-serif;
}
body { background: var(--paper); color: var(--ink); font-family: var(--bs-body-font-family); }
a { color: var(--navy-2); }
.btn-primary { --bs-btn-bg: var(--navy-2); --bs-btn-border-color: var(--navy-2); --bs-btn-hover-bg: var(--navy); --bs-btn-hover-border-color: var(--navy); --bs-btn-active-bg: var(--navy); }
.btn-gold { background: var(--gold); color: #fff; border: 0; }
.btn-gold:hover { background: #b07a1f; color: #fff; }
.form-control:focus, .form-select:focus { border-color: var(--navy-2); box-shadow: 0 0 0 .2rem rgba(27, 61, 102, .15); }
.pagination { --bs-pagination-active-bg: var(--navy-2); --bs-pagination-active-border-color: var(--navy-2); --bs-pagination-color: var(--navy-2); }

/* ---------- Navbar ---------- */
.site-nav { background: var(--navy); }
.site-nav .navbar-brand { font-weight: 600; letter-spacing: .2px; }
.site-nav .navbar-brand small { display: block; font-size: .72rem; font-weight: 400; opacity: .7; }
.site-nav .nav-link { color: rgba(255,255,255,.78); font-size: .95rem; }
.site-nav .nav-link:hover, .site-nav .nav-link.active { color: #fff; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--gold); display: inline-grid; place-items: center; color: #fff; font-size: 1.2rem; }

/* ---------- Hero / Profile ---------- */
.hero { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff; padding: 56px 0 88px; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -120px; top: -120px; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(200,144,46,.12); }
.hero-photo { width: 168px; height: 168px; border-radius: 50%; object-fit: cover; border: 5px solid rgba(255,255,255,.9); box-shadow: 0 10px 30px rgba(0,0,0,.25); background: #fff; }
.hero-photo-empty { width: 168px; height: 168px; border-radius: 50%; background: rgba(255,255,255,.12); display: grid; place-items: center; font-size: 4rem; color: rgba(255,255,255,.6); border: 5px solid rgba(255,255,255,.4); }
.hero h1 { font-weight: 600; font-size: clamp(1.6rem, 3vw, 2.3rem); }
.hero .position { color: #f0d39b; font-size: 1.05rem; }
.hero .affil { opacity: .8; }
.hero-contact a { color: #fff; opacity: .85; text-decoration: none; margin-right: 18px; }
.hero-contact a:hover { opacity: 1; }
.stat-strip { margin-top: -54px; position: relative; z-index: 2; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 18px 20px; box-shadow: 0 6px 24px rgba(15,42,74,.08); display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--ink); transition: transform .15s; border-top: 4px solid var(--accent, var(--gold)); }
.stat-card:hover { transform: translateY(-3px); color: var(--ink); }
.stat-card .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, white); }
.stat-card .num { font-size: 1.6rem; font-weight: 600; line-height: 1; }
.stat-card .lbl { font-size: .85rem; color: var(--muted); }

/* ---------- Sections ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 42px 0 18px; padding-bottom: 10px; border-bottom: 2px solid var(--line); }
.section-head h2 { font-size: 1.35rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 10px; }
.section-head h2 .dot { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--accent); font-size: 1.05rem; }
.section-head .count { font-size: .85rem; color: var(--muted); font-weight: 400; }

/* ---------- Record card ---------- */
.record-card { border: 0; border-radius: var(--radius); overflow: hidden; box-shadow: 0 2px 12px rgba(15,42,74,.06); transition: transform .15s, box-shadow .15s; color: var(--ink); background: #fff; }
.record-card:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(15,42,74,.12); color: var(--ink); }
.record-cover { aspect-ratio: 16/10; position: relative; background: #eef1f5; overflow: hidden; }
.record-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.record-card:hover .record-cover img { transform: scale(1.04); }
.record-cover-empty { width: 100%; height: 100%; display: grid; place-items: center; font-size: 3rem; color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, white); }
.badge-count { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; padding: 3px 8px; border-radius: 20px; }
.record-cover > img { position: absolute; inset: 0; }
.record-thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; background: #fff; position: relative; z-index: 2; }
.record-thumbs a { display: block; aspect-ratio: 4/3; border-radius: 6px; overflow: hidden; background: #eef1f5; }
.record-thumbs img { width: 100%; height: 100%; object-fit: cover; transition: opacity .15s; }
.record-thumbs a:hover img { opacity: .8; }
.record-card .card-body { border-top: 3px solid var(--accent); }
.record-title a { color: inherit; text-decoration: none; }
.record-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 14px; position: relative; z-index: 2; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; padding: 4px 10px; border-radius: 20px; border: 1px solid var(--line); background: #fafaf7; color: var(--ink); text-decoration: none; }
.file-chip:hover { border-color: var(--accent); color: var(--accent); }
.record-date { font-size: .8rem; color: var(--accent); font-weight: 500; margin-bottom: 6px; }
.record-title { font-size: 1.02rem; font-weight: 600; line-height: 1.45; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.record-meta { font-size: .84rem; color: var(--muted); }

/* ---------- Row view (มุมมองแบบแถว) ---------- */
.record-rows { display: flex; flex-direction: column; gap: 12px; }
.record-row { position: relative; display: flex; gap: 18px; background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: 0 2px 12px rgba(15,42,74,.06); border-left: 4px solid var(--accent); transition: box-shadow .15s, transform .15s; }
.record-row:hover { box-shadow: 0 10px 24px rgba(15,42,74,.11); transform: translateX(2px); }
.row-thumb { position: relative; flex: 0 0 180px; aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; background: #eef1f5; align-self: flex-start; }
.row-thumb > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.row-thumb .record-cover-empty { font-size: 2.2rem; }
.row-body { flex: 1; min-width: 0; }
.record-row .record-title { -webkit-line-clamp: 2; font-size: 1.05rem; }
.record-row .record-title a { color: var(--ink); text-decoration: none; }
.record-row:hover .record-title a { color: var(--accent); }
.row-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .86rem; color: var(--muted); }
.row-desc { font-size: .88rem; color: #4b5563; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; position: relative; z-index: 2; }
.mini-thumb { display: block; width: 52px; aspect-ratio: 4/3; border-radius: 6px; overflow: hidden; background: #eef1f5; }
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mini-thumb:hover img { opacity: .8; }
.view-toggle .btn { display: inline-flex; align-items: center; }
@media (max-width: 575.98px) {
  .record-row { gap: 12px; padding: 10px; }
  .row-thumb { flex-basis: 96px; }
  .row-desc { display: none; }
  .view-toggle .btn span { display: none; }
}

/* ---------- Detail ---------- */
.detail-card { background: #fff; border-radius: var(--radius); box-shadow: 0 2px 16px rgba(15,42,74,.06); overflow: hidden; }
.detail-head { padding: 28px 30px; border-left: 6px solid var(--accent); }
.detail-head .kicker { color: var(--accent); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .5px; }
.detail-head h1 { font-size: clamp(1.3rem, 2.4vw, 1.8rem); font-weight: 600; margin: 6px 0 0; }
.detail-table th { width: 220px; color: var(--muted); font-weight: 500; background: #fafaf7; }
.gallery-item { display: block; border-radius: 10px; overflow: hidden; aspect-ratio: 4/3; background: #eee; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.gallery-item:hover img { transform: scale(1.05); }
.file-link { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; background: #fff; }
.file-link:hover { border-color: var(--navy-2); }
.file-link i { font-size: 1.6rem; }

/* ---------- Search results ---------- */
.result-item { display: flex; gap: 14px; padding: 14px; border-radius: 12px; background: #fff; text-decoration: none; color: var(--ink); margin-bottom: 10px; box-shadow: 0 1px 6px rgba(15,42,74,.05); border-left: 4px solid var(--accent); }
.result-item:hover { box-shadow: 0 6px 18px rgba(15,42,74,.1); color: var(--ink); }
.result-item img, .result-item .ph { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; flex-shrink: 0; background: #eef1f5; display: grid; place-items: center; color: var(--accent); font-size: 1.6rem; }
mark { background: #fde9b8; padding: 0 2px; border-radius: 3px; }

/* ---------- Filter / misc ---------- */
.filter-bar { border-radius: var(--radius); }
.period-chip { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); padding: 6px 14px; border-radius: 30px; font-size: .9rem; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-state i { font-size: 3rem; opacity: .4; display: block; margin-bottom: 10px; }
.site-footer { background: var(--navy); color: rgba(255,255,255,.7); padding: 28px 0; margin-top: 64px; font-size: .9rem; }
.site-footer a { color: #fff; }
.about-box { background: #fff; border-radius: var(--radius); padding: 22px 24px; box-shadow: 0 2px 12px rgba(15,42,74,.05); height: 100%; }
.about-box h3 { font-size: 1rem; font-weight: 600; color: var(--navy-2); margin-bottom: 10px; }

/* =========================================================
   ระบบหลังบ้าน
   ========================================================= */
.admin-body { background: #f3f5f8; }
.admin-sidebar { width: 260px; min-height: 100vh; background: var(--navy); color: #fff; position: fixed; top: 0; left: 0; z-index: 1030; transition: transform .2s; display: flex; flex-direction: column; }
.admin-sidebar .brand { padding: 20px 22px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; gap: 12px; align-items: center; text-decoration: none; color: #fff; }
.admin-sidebar .brand small { display: block; opacity: .6; font-size: .72rem; }
.admin-sidebar .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; opacity: .45; padding: 18px 22px 6px; }
.admin-sidebar .nav-link { color: rgba(255,255,255,.75); padding: 10px 22px; display: flex; gap: 12px; align-items: center; border-left: 3px solid transparent; font-size: .94rem; }
.admin-sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.admin-sidebar .nav-link.active { color: #fff; background: rgba(255,255,255,.08); border-left-color: var(--gold); }
.admin-main { margin-left: 260px; min-height: 100vh; }
.admin-topbar { background: #fff; border-bottom: 1px solid #e6e9ee; padding: 12px 24px; position: sticky; top: 0; z-index: 1020; }
.admin-content { padding: 24px; }
.page-title { font-size: 1.4rem; font-weight: 600; margin: 0; }
.admin-card { background: #fff; border: 0; border-radius: var(--radius); box-shadow: 0 1px 8px rgba(15,42,74,.06); }
.table-admin th { font-weight: 500; color: var(--muted); font-size: .85rem; white-space: nowrap; background: #fafbfc; }
.table-admin td { vertical-align: middle; }
.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: #eef1f5; }
.thumb-empty { width: 64px; height: 48px; border-radius: 6px; background: #eef1f5; display: grid; place-items: center; color: #9aa3ae; }
.img-slot { position: relative; border-radius: 10px; overflow: hidden; aspect-ratio: 4/3; background: #eef1f5; border: 2px solid transparent; }
.img-slot img { width: 100%; height: 100%; object-fit: cover; }
.img-slot.removing { opacity: .35; border-color: #dc3545; }
.img-slot .btn-remove { position: absolute; top: 6px; right: 6px; }
.img-slot .tag-new { position: absolute; left: 6px; top: 6px; }
.dropzone { border: 2px dashed #c5ccd6; border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; background: #fafbfc; }
.dropzone:hover, .dropzone.drag { border-color: var(--navy-2); background: #f0f4fa; color: var(--navy-2); }
.img-counter.bad { color: #dc3545; font-weight: 600; }
.img-counter.ok { color: #198754; font-weight: 600; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%); padding: 16px; }
.login-card { width: 100%; max-width: 420px; border: 0; border-radius: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }

@media (max-width: 991.98px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.show { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .admin-main { margin-left: 0; }
  .detail-table th { width: 140px; }
}
@media print {
  .site-nav, .site-footer, .filter-bar, .no-print { display: none !important; }
}
