@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&display=swap');

:root {
  --navy:       #0A1628;
  --navy-mid:   #0F2040;
  --navy-light: #1A3356;
  --blue:       #0D5EAF;
  --blue-bright:#1472D4;
  --accent:     #FF6B00;
  --accent-2:   #FF8C35;
  --steel:      #4A7BAA;
  --text-main:  #1A2332;
  --text-body:  #3D5166;
  --text-muted: #7A90A8;
  --surface:    #F4F7FB;
  --surface-2:  #E8EFF7;
  --white:      #FFFFFF;
  --border:     rgba(13,94,175,0.15);
  --shadow-sm:  0 2px 8px rgba(10,22,40,0.08);
  --shadow-md:  0 8px 32px rgba(10,22,40,0.12);
  --shadow-lg:  0 20px 60px rgba(10,22,40,0.18);
  --radius:     12px;
  --radius-lg:  20px;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { scroll-behavior:smooth; font-size:16px; }
body { font-family:'Sarabun',sans-serif; color:var(--text-main); background:var(--white); line-height:1.6; overflow-x:hidden; }
img  { max-width:100%; display:block; }
a    { color:inherit; text-decoration:none; }
button { cursor:pointer; font-family:inherit; }

::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background:var(--surface); }
::-webkit-scrollbar-thumb { background:var(--steel); border-radius:3px; }

/* ── Header ── */
#header {
  position:fixed; top:0; left:0; right:0; z-index:900;
  background:rgba(10,22,40,0.96);
  backdrop-filter:blur(16px);
  border-bottom:1px solid rgba(255,255,255,0.06);
  transition:var(--transition);
}
#header.scrolled { background:rgba(10,22,40,0.99); box-shadow:0 4px 24px rgba(0,0,0,0.3); }
.nav-wrap { max-width:1400px; margin:0 auto; padding:0 24px; display:flex; align-items:center; gap:24px; height:70px; }
.logo { display:flex; align-items:center; gap:12px; flex-shrink:0; }
.logo-mark { width:42px; height:42px; background:linear-gradient(135deg,var(--blue-bright),var(--accent)); border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:20px; font-weight:800; color:#fff; box-shadow:0 4px 16px rgba(255,107,0,0.35); letter-spacing:-1px; }
.logo-text strong { display:block; font-size:15px; font-weight:700; color:#fff; letter-spacing:0.5px; }
.logo-text span { font-size:10.5px; color:var(--accent-2); font-weight:500; letter-spacing:1px; text-transform:uppercase; }
.logo-img { height:52px; width:auto; max-width:240px; object-fit:contain; display:block; }
.logo:has(.logo-img) .logo-mark, .logo:has(.logo-img) .logo-text { display:none; }
.logo:hover .logo-img { opacity:0.85; }
.nav-links { display:flex; align-items:center; gap:2px; margin-left:auto; list-style:none; flex-wrap:nowrap; }
.nav-links a { padding:7px 10px; border-radius:8px; font-size:13.5px; font-weight:500; color:rgba(255,255,255,0.75); transition:var(--transition); white-space:nowrap; }
.nav-links a:hover, .nav-links a.active { color:#fff; background:rgba(255,255,255,0.1); }
.nav-cta { padding:8px 14px !important; background:var(--accent) !important; color:#fff !important; border-radius:8px !important; font-weight:600 !important; }
.nav-cta:hover { background:var(--accent-2) !important; transform:translateY(-1px); }
.nav-login-btn { padding:8px 14px; border-radius:8px; font-size:13px; font-weight:500; background:rgba(255,255,255,0.08); color:rgba(255,255,255,0.8); border:1px solid rgba(255,255,255,0.12); transition:var(--transition); white-space:nowrap; }
.nav-login-btn:hover { background:rgba(255,255,255,0.14); color:#fff; }
.nav-user { display:flex; align-items:center; gap:6px; color:rgba(255,255,255,0.9); font-size:12.5px; flex-shrink:0; }
.nav-user-role { padding:3px 8px; border-radius:4px; background:rgba(255,107,0,0.2); color:var(--accent-2); font-size:11px; font-weight:600; }
.nav-admin-btn { padding:6px 10px; border-radius:6px; background:rgba(20,114,212,0.2); border:1px solid rgba(20,114,212,0.3); color:var(--blue-bright); font-size:12px; white-space:nowrap; }
.nav-admin-btn:hover { background:rgba(20,114,212,0.35); }
.nav-user-logout { padding:6px 10px; border-radius:6px; background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.1); color:rgba(255,255,255,0.6); font-size:12px; transition:var(--transition); white-space:nowrap; }
.nav-user-logout:hover { color:#fff; background:rgba(255,255,255,0.12); }
.hamburger { display:none; flex-direction:column; gap:5px; background:none; border:none; padding:6px; margin-left:auto; flex-shrink:0; }
.hamburger span { width:24px; height:2px; background:rgba(255,255,255,0.85); border-radius:2px; transition:var(--transition); }
.mobile-menu { display:none; position:fixed; inset:0; z-index:800; background:var(--navy); padding:80px 24px 32px; flex-direction:column; gap:8px; }
.mobile-menu.open { display:flex; }
.mobile-menu a { padding:16px; border-radius:10px; font-size:18px; font-weight:500; color:rgba(255,255,255,0.85); border-bottom:1px solid rgba(255,255,255,0.06); }
.mobile-menu a:hover { color:#fff; background:rgba(255,255,255,0.06); }

/* ── Nav responsive scaling ── */
@media(max-width:1280px){
  .nav-links a { padding:6px 8px; font-size:12.5px; }
  .nav-cta { padding:7px 12px !important; font-size:12.5px !important; }
  .nav-wrap { gap:12px; }
}
@media(max-width:1100px){
  .nav-links a { padding:6px 7px; font-size:12px; }
  .nav-cta { padding:7px 10px !important; font-size:12px !important; }
  .logo-text span { display:none; }
}

/* ── Section ── */
section { padding:100px 24px; }
.container { max-width:1400px; margin:0 auto; }
.section-tag { font-size:12px; font-weight:700; letter-spacing:2px; text-transform:uppercase; color:var(--accent); margin-bottom:10px; }
.section-title { font-family:'IBM Plex Sans Thai',sans-serif; font-size:clamp(28px,3.5vw,44px); font-weight:800; color:var(--text-main); line-height:1.2; letter-spacing:-0.5px; }
.section-sub { font-size:16px; color:var(--text-muted); margin-top:12px; max-width:560px; }
.section-header { display:flex; align-items:flex-end; justify-content:space-between; margin-bottom:56px; gap:24px; flex-wrap:wrap; }

/* ── Buttons ── */
.btn { display:inline-flex; align-items:center; gap:6px; padding:10px 20px; border-radius:8px; font-family:inherit; font-size:14px; font-weight:600; border:none; transition:var(--transition); cursor:pointer; }
.btn-blue   { background:var(--navy); color:#fff; }
.btn-blue:hover   { background:var(--navy-mid); }
.btn-accent { background:var(--accent); color:#fff; }
.btn-accent:hover { background:var(--accent-2); }
.btn-ghost  { background:var(--surface); color:var(--text-body); border:1.5px solid var(--border); }
.btn-ghost:hover  { background:var(--surface-2); }
.btn-danger { background:#ff3b3b; color:#fff; }
.btn-danger:hover { background:#cc0000; }
.btn-outline-white { display:inline-flex; align-items:center; gap:8px; padding:13px 26px; border-radius:10px; background:rgba(255,255,255,0.08); color:rgba(255,255,255,0.85); font-size:15.5px; font-weight:500; border:1px solid rgba(255,255,255,0.2); transition:var(--transition); }
.btn-outline-white:hover { background:rgba(255,255,255,0.14); color:#fff; }
.btn-primary-lg { display:inline-flex; align-items:center; gap:8px; padding:14px 28px; border-radius:10px; background:var(--accent); color:#fff; font-size:15.5px; font-weight:600; border:none; transition:var(--transition); box-shadow:0 8px 24px rgba(255,107,0,0.35); }
.btn-primary-lg:hover { background:var(--accent-2); transform:translateY(-2px); }
.btn-sm   { padding:7px 14px; font-size:13px; }
.btn-icon { padding:8px; border-radius:8px; background:var(--surface); border:1px solid var(--border); color:var(--text-muted); }
.btn-icon:hover { background:var(--surface-2); color:var(--text-main); }

/* ── Forms ── */
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.form-group { margin-bottom:16px; }
.form-group.full { grid-column:1/-1; }
label { display:block; font-size:13.5px; font-weight:600; color:var(--text-body); margin-bottom:6px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width:100%; padding:11px 14px; border-radius:8px; border:1.5px solid var(--border);
  font-family:inherit; font-size:14.5px; color:var(--text-main); background:var(--surface);
  outline:none; transition:var(--transition);
}
input:focus, select:focus, textarea:focus { border-color:var(--blue); background:#fff; box-shadow:0 0 0 4px rgba(13,94,175,0.08); }
textarea { resize:vertical; min-height:100px; }
select { cursor:pointer; }

/* ── Modal ── */
.modal-overlay { position:fixed; inset:0; z-index:1000; background:rgba(5,12,25,0.85); backdrop-filter:blur(6px); display:none; align-items:flex-start; justify-content:center; padding:24px; overflow-y:auto; }
.modal-overlay[style*="flex"] { display:flex !important; }
.modal { background:var(--white); border-radius:var(--radius-lg); width:100%; max-width:760px; box-shadow:var(--shadow-lg); margin:auto; overflow:hidden; }
.modal.modal-wide { max-width:960px; }
.modal-header { display:flex; align-items:center; justify-content:space-between; padding:20px 28px; border-bottom:1px solid var(--border); background:var(--navy); color:#fff; }
.modal-title { font-size:18px; font-weight:700; }
.modal-close { background:rgba(255,255,255,0.08); border:none; color:rgba(255,255,255,0.7); width:32px; height:32px; border-radius:8px; font-size:18px; display:flex; align-items:center; justify-content:center; transition:var(--transition); }
.modal-close:hover { background:rgba(255,255,255,0.18); color:#fff; }
.modal-body { padding:28px; }
.modal-footer { padding:16px 28px; border-top:1px solid var(--border); display:flex; gap:10px; justify-content:flex-end; background:var(--surface); }

/* ── Cards / Project ── */
.project-card { background:var(--white); border-radius:var(--radius-lg); overflow:hidden; border:1px solid var(--border); transition:var(--transition); cursor:pointer; }
.project-card:hover { box-shadow:var(--shadow-lg); transform:translateY(-6px); border-color:transparent; }
.project-card-img { aspect-ratio:16/10; overflow:hidden; background:var(--surface-2); position:relative; }
.project-card-img img { width:100%; height:100%; object-fit:cover; transition:transform 0.5s ease; }
.project-card:hover .project-card-img img { transform:scale(1.06); }
.project-card-cat { position:absolute; top:12px; left:12px; padding:4px 10px; border-radius:6px; background:rgba(10,22,40,0.75); backdrop-filter:blur(8px); color:#fff; font-size:12px; font-weight:600; }
.project-card-body { padding:20px 22px 24px; }
.project-card-year { font-size:12px; color:var(--text-muted); font-weight:600; letter-spacing:0.5px; margin-bottom:8px; }
.project-card-title { font-size:17px; font-weight:700; color:var(--text-main); line-height:1.35; margin-bottom:10px; }
.project-card-meta { display:flex; gap:14px; flex-wrap:wrap; }
.pmeta { display:flex; align-items:center; gap:5px; font-size:13px; color:var(--text-muted); }
.project-card-tags { display:flex; flex-wrap:wrap; gap:6px; margin-top:14px; }
.ptag { padding:2px 8px; border-radius:4px; background:var(--surface); color:var(--text-muted); font-size:11.5px; font-weight:500; }
.project-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr)); gap:24px; }

/* ── Status badge ── */
.status-badge { display:inline-block; padding:3px 10px; border-radius:20px; font-size:11.5px; font-weight:600; }
.status-published { background:#e6f7ec; color:#1a7c3e; }
.status-draft { background:#fff3e0; color:#b86100; }

/* ── Filter ── */
.filter-wrap { display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-bottom:32px; }
.filter-search { position:relative; flex:1; min-width:220px; max-width:340px; }
.filter-search input { width:100%; padding:11px 16px 11px 42px; border-radius:10px; border:1.5px solid var(--border); font-family:inherit; font-size:14.5px; background:var(--surface); outline:none; transition:var(--transition); }
.filter-search input:focus { border-color:var(--blue); background:#fff; }
.filter-search-icon { position:absolute; left:14px; top:50%; transform:translateY(-50%); color:var(--text-muted); pointer-events:none; }
.filter-chips { display:flex; flex-wrap:wrap; gap:8px; }
.chip { padding:8px 16px; border-radius:30px; font-size:13.5px; font-weight:500; background:var(--surface); color:var(--text-body); border:1.5px solid transparent; transition:var(--transition); cursor:pointer; }
.chip:hover { border-color:var(--blue); color:var(--blue-bright); }
.chip.active { background:var(--navy); color:#fff; border-color:transparent; }
.year-filter { padding:10px 14px; border-radius:10px; border:1.5px solid var(--border); font-family:inherit; font-size:14px; background:var(--surface); outline:none; cursor:pointer; }

/* ── Image upload ── */
.img-upload-area { border:2px dashed var(--border); border-radius:var(--radius); padding:32px; text-align:center; cursor:pointer; transition:var(--transition); background:var(--surface); }
.img-upload-area:hover, .img-upload-area.drag { border-color:var(--blue); background:rgba(13,94,175,0.04); }
.img-previews { display:flex; flex-wrap:wrap; gap:10px; margin-top:14px; }
.img-preview-item { position:relative; width:90px; height:90px; border-radius:8px; overflow:hidden; border:2px solid var(--border); }
.img-preview-item img { width:100%; height:100%; object-fit:cover; }
.img-preview-del { position:absolute; top:4px; right:4px; width:20px; height:20px; border-radius:50%; background:rgba(0,0,0,0.6); color:#fff; font-size:12px; border:none; display:flex; align-items:center; justify-content:center; }
.img-preview-cover { position:absolute; bottom:0; left:0; right:0; background:var(--accent); color:#fff; font-size:9px; font-weight:700; text-align:center; padding:2px; }

/* ── Footer ── */
footer { background:var(--navy); border-top:1px solid rgba(255,255,255,0.06); padding:48px 24px; color:rgba(255,255,255,0.5); text-align:center; font-size:14px; }
footer strong { color:rgba(255,255,255,0.85); }
.footer-links { display:flex; gap:16px; justify-content:center; flex-wrap:wrap; margin-top:16px; }
.footer-links a { color:rgba(255,255,255,0.5); font-size:13px; transition:opacity .2s; }
.footer-links a:hover { color:rgba(255,255,255,0.85); }

/* ── Toast ── */
@keyframes toastIn { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:none} }

/* ── Loading ── */
.loading-spinner { display:inline-block; width:20px; height:20px; border:2px solid rgba(255,255,255,0.3); border-top-color:#fff; border-radius:50%; animation:spin 0.7s linear infinite; }
@keyframes spin { to{transform:rotate(360deg)} }
.page-loading { text-align:center; padding:80px 24px; color:var(--text-muted); }
.page-loading .spinner { width:40px; height:40px; border:3px solid var(--border); border-top-color:var(--blue); border-radius:50%; animation:spin 0.8s linear infinite; margin:0 auto 16px; }

/* ── Responsive ── */

/* Tablet landscape */
@media(max-width:1024px){
  .nav-wrap { padding:0 16px; gap:16px; }
  .section-header { flex-direction:column; align-items:flex-start; gap:16px; }
}

/* Switch to hamburger at 1200px — nav has too many items for smaller screens */
@media(max-width:1200px){
  .nav-links { display:none; }
  #auth-area .nav-login-btn, #auth-area .nav-user { display:none; }
  .hamburger { display:flex; }
}

/* Tablet portrait */
@media(max-width:768px){
  section { padding:64px 16px; }
  .form-row { grid-template-columns:1fr; }
  .project-grid { grid-template-columns:repeat(2,1fr) !important; gap:16px; }
  .modal { width:calc(100% - 16px); margin:8px; max-width:none !important; }
  .modal-body { padding:16px; }
  .modal-footer { padding:12px 16px; }
  .modal-header { padding:14px 16px; }
  .btn-primary-lg { padding:12px 20px; font-size:14px; }
  .section-title { font-size:26px; }
}

/* Mobile */
@media(max-width:540px){
  section { padding:56px 14px; }
  .project-grid { grid-template-columns:1fr !important; gap:14px; }
  .project-card-title { font-size:15px; }
  .project-card-body { padding:14px 16px 18px; }
  .filter-wrap { flex-direction:column; align-items:stretch; gap:8px; }
  .filter-search { max-width:100%; }
  .filter-chips { overflow-x:auto; flex-wrap:nowrap; padding-bottom:4px; -webkit-overflow-scrolling:touch; }
  .chip { white-space:nowrap; flex-shrink:0; padding:7px 14px; font-size:13px; }
  .year-filter { width:100%; }
  .section-header { flex-direction:column; align-items:flex-start; gap:12px; }
  .section-title { font-size:24px; }
  .btn { padding:9px 16px; font-size:13px; }
  .logo-text strong { font-size:13px; }
  .logo-text span { display:none; }
  .logo-mark { width:36px; height:36px; font-size:17px; }
  footer { padding:32px 14px; font-size:13px; }
  .footer-links { gap:12px; }
}

/* Small mobile */
@media(max-width:400px){
  section { padding:48px 12px; }
  .project-card-title { font-size:14px; }
  .nav-wrap { height:60px; padding:0 12px; }
  .section-title { font-size:22px; }
}

