/* =============================================
   KMS คณะแพทยศาสตร์ ม.บูรพา — Main Stylesheet
   ============================================= */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
:root {
  --green:      #0F6E56;
  --green-mid:  #1D9E75;
  --green-light:#E1F5EE;
  --text:       #1a1a1a;
  --text-muted: #6b7280;
  --border:     #e5e7eb;
  --bg:         #f9fafb;
  --white:      #ffffff;
  --radius:     10px;
  --shadow:     0 1px 4px rgba(0,0,0,.08);
}
body { font-family:'Sarabun','Noto Sans Thai',sans-serif; background:var(--bg); color:var(--text); line-height:1.7; font-size:16px; }
a { color:var(--green); text-decoration:none; }
a:hover { text-decoration:underline; }

/* ---- Hero ---- */
.hero { background:linear-gradient(135deg,#0a4a38 0%,var(--green) 60%,var(--green-mid) 100%); color:#fff; padding:4rem 1.5rem; text-align:center; }
.hero-inner { max-width:700px; margin:0 auto; }
.hero h1 { font-size:2.2rem; font-weight:700; margin-bottom:.5rem; }
.hero p   { font-size:1.1rem; opacity:.85; margin-bottom:1.5rem; }
.hero-btns { display:flex; justify-content:center; gap:1rem; flex-wrap:wrap; }

/* ---- Buttons ---- */
.btn { display:inline-flex; align-items:center; gap:.4rem; padding:9px 20px; border-radius:8px; font-size:.95rem; font-weight:500; cursor:pointer; border:2px solid transparent; transition:all .18s; text-decoration:none; font-family:inherit; }
.btn:hover { text-decoration:none; }
.btn-primary { background:var(--green); color:#fff; border-color:var(--green); }
.btn-primary:hover { background:#085041; border-color:#085041; }
.btn-outline { background:transparent; color:var(--green); border-color:var(--green); }
.btn-outline:hover { background:var(--green-light); }
.btn-success { background:#16a34a; color:#fff; border-color:#16a34a; }
.btn-danger  { background:#dc2626; color:#fff; border-color:#dc2626; }
.btn-block   { width:100%; justify-content:center; }
.btn-sm      { padding:4px 10px; font-size:.82rem; }

/* ---- Container ---- */
.container { max-width:1200px; margin:0 auto; padding:0 1.5rem; }

/* ---- Stats ---- */
.stats-row { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:1rem; margin:1.5rem 0; }
.stat-card { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:1.2rem; text-align:center; }
.stat-icon { font-size:1.8rem; margin-bottom:.3rem; }
.stat-num  { font-size:1.8rem; font-weight:700; color:var(--green); }
.stat-label{ font-size:.85rem; color:var(--text-muted); margin-top:.2rem; }
.stat-trend{ font-size:.8rem; color:var(--green-mid); margin-top:.3rem; }

/* ---- Category grid ---- */
.cat-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:1rem; }
.cat-card { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:1.2rem 1rem; text-align:center; transition:box-shadow .18s,transform .18s; text-decoration:none; color:var(--text); display:block; }
.cat-card:hover { box-shadow:0 4px 16px rgba(0,0,0,.1); transform:translateY(-2px); text-decoration:none; }
.cat-icon  { font-size:2rem; margin-bottom:.4rem; }
.cat-name  { font-size:.9rem; font-weight:600; }
.cat-count { font-size:.8rem; color:var(--text-muted); margin-top:.2rem; }

/* ---- Section title ---- */
.section-title { font-size:1.2rem; font-weight:700; margin-bottom:1rem; display:flex; align-items:center; gap:.5rem; }
.section-title::before { content:''; display:inline-block; width:4px; height:1.1em; background:var(--green); border-radius:4px; }
.page-title { font-size:1.6rem; font-weight:700; margin-bottom:1.5rem; }

/* ---- Document cards ---- */
.doc-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:1rem; }
.doc-card { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:1.2rem; transition:box-shadow .18s; }
.doc-card:hover { box-shadow:0 4px 16px rgba(0,0,0,.1); }
.doc-badge { display:inline-block; font-size:.78rem; font-weight:600; padding:3px 10px; border-radius:20px; margin-bottom:.6rem; }
.doc-card h3 { font-size:.95rem; font-weight:600; margin-bottom:.4rem; line-height:1.4; }
.doc-card h3 a { color:var(--text); }
.doc-card h3 a:hover { color:var(--green); text-decoration:none; }
.doc-desc { font-size:.85rem; color:var(--text-muted); line-height:1.5; margin-bottom:.6rem; }
.doc-meta { font-size:.8rem; color:var(--text-muted); display:flex; flex-wrap:wrap; gap:.6rem; margin-top:.8rem; padding-top:.8rem; border-top:1px solid var(--border); }

/* ---- Auth ---- */
.auth-wrap { min-height:70vh; display:flex; align-items:center; justify-content:center; padding:2rem 1rem; }
.auth-card { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:2.5rem 2rem; width:100%; max-width:400px; box-shadow:var(--shadow); }
.auth-logo { font-size:3rem; text-align:center; margin-bottom:.5rem; }
.auth-card h2 { text-align:center; font-size:1.4rem; font-weight:700; margin-bottom:.2rem; }
.auth-sub  { text-align:center; font-size:.85rem; color:var(--text-muted); margin-bottom:1.5rem; }

/* ---- Forms ---- */
.form-group  { margin-bottom:1rem; }
.form-group label { display:block; font-size:.9rem; font-weight:600; margin-bottom:.3rem; }
.form-control { width:100%; padding:9px 12px; border:1px solid var(--border); border-radius:7px; font-size:.95rem; font-family:inherit; background:var(--white); transition:border-color .15s; }
.form-control:focus { outline:none; border-color:var(--green); box-shadow:0 0 0 3px rgba(15,110,86,.12); }
textarea.form-control { resize:vertical; }
.form-row    { display:grid; grid-template-columns:1fr 1fr; gap:1rem; }
.form-actions{ display:flex; gap:.8rem; margin-top:1.5rem; }
.form-card   { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:2rem; }

/* ---- Alerts ---- */
.alert         { padding:12px 16px; border-radius:8px; margin-bottom:1rem; font-size:.9rem; }
.alert-success { background:#d1fae5; color:#065f46; border:1px solid #a7f3d0; }
.alert-danger  { background:#fee2e2; color:#991b1b; border:1px solid #fca5a5; }
.alert-warning { background:#fef3c7; color:#92400e; border:1px solid #fcd34d; }

/* ---- Badges ---- */
.badge        { display:inline-block; font-size:.75rem; font-weight:600; padding:2px 8px; border-radius:20px; }
.badge-green  { background:#d1fae5; color:#065f46; }
.badge-amber  { background:#fef3c7; color:#92400e; }
.badge-red    { background:#fee2e2; color:#991b1b; }
.badge-gray   { background:#f3f4f6; color:#374151; }

/* ---- Tags ---- */
.tag-row { display:flex; flex-wrap:wrap; gap:.4rem; margin-bottom:.5rem; }
.tag { display:inline-block; font-size:.78rem; padding:3px 10px; background:var(--bg); border:1px solid var(--border); border-radius:20px; color:var(--text-muted); }
.tag:hover,.tag.active { border-color:var(--green); color:var(--green); text-decoration:none; }

/* ---- Search ---- */
.search-bar-form { display:flex; gap:.8rem; margin-bottom:1.5rem; }
.search-input    { flex:1; padding:10px 16px; border:1px solid var(--border); border-radius:8px; font-size:1rem; font-family:inherit; }
.search-input:focus { outline:none; border-color:var(--green); box-shadow:0 0 0 3px rgba(15,110,86,.12); }
.search-layout   { display:grid; grid-template-columns:220px 1fr; gap:1.5rem; }
.filter-sidebar  { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:1.2rem; align-self:start; }
.filter-sidebar h3  { font-size:.95rem; font-weight:700; margin-bottom:.7rem; }
.filter-list     { list-style:none; }
.filter-list li  { margin-bottom:.2rem; }
.filter-list a   { display:block; padding:5px 8px; border-radius:6px; font-size:.88rem; color:var(--text-muted); }
.filter-list a:hover,.filter-list a.active { background:var(--green-light); color:var(--green); text-decoration:none; }
.search-results-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:1rem; font-size:.9rem; }
.sort-select     { padding:5px 10px; border:1px solid var(--border); border-radius:6px; font-family:inherit; font-size:.88rem; }
.empty-state     { text-align:center; padding:3rem; color:var(--text-muted); }

/* ---- Document view ---- */
.doc-view-header  { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:1.8rem; margin-bottom:1.5rem; }
.doc-view-header h1 { font-size:1.5rem; font-weight:700; margin:.8rem 0; line-height:1.4; }
.doc-view-meta    { display:flex; flex-wrap:wrap; gap:1rem; font-size:.85rem; color:var(--text-muted); margin-bottom:1rem; }
.doc-view-actions { display:flex; flex-wrap:wrap; gap:.8rem; margin-top:1rem; }
.doc-section      { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:1.5rem; margin-bottom:1.2rem; }
.doc-section h2   { font-size:1rem; font-weight:700; margin-bottom:.8rem; padding-bottom:.5rem; border-bottom:2px solid var(--green-light); color:var(--green); }
.doc-content      { line-height:1.8; white-space:pre-wrap; }

/* ---- Comments ---- */
.comment-item   { display:flex; gap:1rem; margin-bottom:1.2rem; }
.comment-avatar { width:40px; height:40px; border-radius:50%; background:var(--green-light); color:var(--green); display:flex; align-items:center; justify-content:center; font-weight:700; font-size:1rem; flex-shrink:0; }
.comment-author { font-size:.85rem; font-weight:600; margin-bottom:.2rem; }
.comment-author span { font-weight:400; color:var(--text-muted); margin-left:.5rem; }
.comment-body p { font-size:.9rem; line-height:1.6; }

/* ---- Table ---- */
.table         { width:100%; border-collapse:collapse; font-size:.9rem; background:var(--white); border-radius:var(--radius); overflow:hidden; border:1px solid var(--border); }
.table th      { background:var(--bg); padding:10px 14px; text-align:left; font-weight:600; border-bottom:1px solid var(--border); font-size:.85rem; color:var(--text-muted); }
.table td      { padding:10px 14px; border-bottom:1px solid var(--border); vertical-align:middle; }
.table tr:last-child td { border-bottom:none; }
.table tr:hover td { background:#fafafa; }

/* ---- Section box ---- */
.section-box        { background:var(--white); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; }
.section-box-header { display:flex; align-items:center; justify-content:space-between; padding:1rem 1.2rem; border-bottom:1px solid var(--border); }
.section-box-header h2 { font-size:1rem; font-weight:700; margin:0; }
.section-box .table { border:none; border-radius:0; }

/* ---- Tabs ---- */
.tab-bar   { display:flex; gap:.3rem; margin-bottom:1.2rem; border-bottom:2px solid var(--border); }
.tab-link  { padding:8px 18px; font-size:.9rem; color:var(--text-muted); border-radius:6px 6px 0 0; text-decoration:none; }
.tab-link:hover { background:var(--green-light); color:var(--green); text-decoration:none; }
.tab-link.active { background:var(--green); color:#fff; }

/* ---- Pagination ---- */
.pagination { display:flex; gap:.4rem; justify-content:center; margin-top:1.5rem; }
.pagination a { padding:6px 12px; border:1px solid var(--border); border-radius:6px; font-size:.9rem; color:var(--text-muted); }
.pagination a:hover,.pagination a.active { background:var(--green); color:#fff; border-color:var(--green); text-decoration:none; }

/* ---- Footer ---- */
.footer { background:var(--white); border-top:1px solid var(--border); padding:1.5rem; text-align:center; font-size:.85rem; color:var(--text-muted); margin-top:3rem; }
.footer a { color:var(--green); }

/* ---- Misc ---- */
.text-center { text-align:center; }
mark { background:#fff3cd; padding:0 2px; border-radius:3px; }

/* ---- Responsive ---- */
@media (max-width:768px) {
  .hero h1 { font-size:1.5rem; }
  .form-row { grid-template-columns:1fr; }
  .search-layout { grid-template-columns:1fr; }
  .filter-sidebar { display:none; }
  .doc-grid { grid-template-columns:1fr; }
  .stats-row { grid-template-columns:1fr 1fr; }
}
