/* ระบบแผนยุทธศาสตร์โรงเรียน มอ. วิทยานุสรณ์ สุราษฎร์ธานี */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --navy: #143a6b;
  --navy-dark: #0d2a4f;
  --blue: #2563eb;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --st-gray: #94a3b8;
  --st-yellow: #eab308;
  --st-red: #dc2626;
  --st-blue: #2563eb;
  --st-green: #16a34a;
}
body { font-family: 'Sarabun', sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }

/* ===== Login ===== */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%); padding: 16px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 36px; max-width: 420px; width: 100%;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { font-size: 56px; margin-bottom: 12px; }
.login-card h1 { font-size: 22px; color: var(--navy); }
.login-school { font-size: 16px; color: var(--muted); margin: 4px 0 20px; }
.login-hint { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
#googleBtn { display: flex; justify-content: center; }
.login-error { margin-top: 14px; color: var(--st-red); font-size: 13px; }

/* ===== Layout ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; background: var(--navy-dark); color: #fff; display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
}
.sidebar-head { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-logo { font-size: 28px; }
.sidebar-title { font-weight: 700; font-size: 16px; }
.sidebar-sub { font-size: 12px; opacity: .7; }
.nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav a {
  display: block; padding: 10px 12px; color: rgba(255,255,255,.82); text-decoration: none;
  border-radius: 8px; margin-bottom: 2px; font-size: 14px; transition: background .15s;
}
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: var(--blue); color: #fff; font-weight: 600; }
.sidebar-user { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.1); }
.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 12px; opacity: .7; margin-bottom: 8px; }

.main { flex: 1; margin-left: 250px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border); padding: 14px 24px;
  display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 40;
}
.topbar h2 { font-size: 18px; color: var(--navy); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; }
.content { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ===== Components ===== */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 18px; }
.card h3 { color: var(--navy); font-size: 16px; margin-bottom: 14px; }
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.toolbar input[type=text], .toolbar select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 14px;
}
.toolbar input[type=text] { flex: 1; min-width: 220px; }

table.data { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; }
table.data th {
  background: var(--navy); color: #fff; padding: 10px 12px; font-size: 13px; text-align: left; font-weight: 600;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: top; }
table.data tr:hover td { background: #f8fafc; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }

.link { color: var(--blue); cursor: pointer; text-decoration: underline; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.85); }
.bg-gray { background: var(--st-gray); } .bg-yellow { background: var(--st-yellow); }
.bg-red { background: var(--st-red); } .bg-blue { background: var(--st-blue); } .bg-green { background: var(--st-green); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border: none; border-radius: 8px;
  background: var(--blue); color: #fff; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn-green { background: var(--st-green); }
.btn-red { background: var(--st-red); }
.btn-gray { background: var(--muted); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: inherit; font-weight: 500; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 14px; background: #fff;
}
.field textarea { min-height: 80px; resize: vertical; }
.dyn-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: flex-start; }
.dyn-row .num { padding-top: 9px; font-size: 13px; color: var(--muted); min-width: 20px; }
.dyn-row input { flex: 1; }
.dyn-row input.amount { flex: 0 0 140px; text-align: right; }
.add-row-btn { background: none; border: 1px dashed var(--blue); color: var(--blue); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-family: inherit; font-size: 13px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--navy); margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.radio-row { display: flex; flex-direction: column; gap: 8px; }
.radio-row label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; font-weight: 400; }

/* multi-select ผู้รับผิดชอบ */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: #e0e7ff; color: var(--navy); border-radius: 999px; padding: 4px 10px; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.chip button { background: none; border: none; cursor: pointer; color: var(--navy); font-weight: 700; }

/* ===== Strategy Map ===== */
.smap-grid { display: grid; gap: 14px; }
.smap-mission { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.smap-mission-head { background: var(--navy); color: #fff; padding: 12px 16px; font-weight: 600; font-size: 14px; }
.smap-mission-body { padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; }
.smap-proj {
  background: #eff6ff; border: 1px solid #bfdbfe; color: var(--navy); border-radius: 8px;
  padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.smap-proj:hover { background: #dbeafe; }
.smap-empty { color: var(--muted); font-size: 13px; align-self: center; }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; }
.modal-box { background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 860px; }
.modal-box h3 { color: var(--navy); margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ===== Public eval ===== */
.public-eval { max-width: 640px; margin: 0 auto; padding: 24px 16px; }
.rating-row { display: flex; gap: 8px; margin: 6px 0 14px; }
.rating-row label {
  flex: 1; text-align: center; border: 1px solid var(--border); border-radius: 8px; padding: 8px 4px;
  cursor: pointer; font-size: 13px;
}
.rating-row input { display: none; }
.rating-row input:checked + span { font-weight: 700; color: var(--blue); }
.rating-row label:has(input:checked) { border-color: var(--blue); background: #eff6ff; }

/* ===== images upload ===== */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.img-slot {
  border: 2px dashed var(--border); border-radius: 10px; aspect-ratio: 4/3; display: flex;
  align-items: center; justify-content: center; cursor: pointer; overflow: hidden; position: relative;
  color: var(--muted); font-size: 13px; background: #f8fafc;
}
.img-slot img { width: 100%; height: 100%; object-fit: cover; }
.img-slot .rm { position: absolute; top: 4px; right: 4px; background: rgba(220,38,38,.9); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 12px; padding: 2px 6px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy);
  color: #fff; padding: 12px 22px; border-radius: 10px; z-index: 200; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

/* ===== Print (พิมพ์เอกสาร / Save PDF) ===== */
.print-area { display: none; }
@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
  body { background: #fff; }
}
.doc { font-family: 'Sarabun', sans-serif; font-size: 16px; line-height: 1.7; color: #000; max-width: 19cm; margin: 0 auto; }
.doc h1 { font-size: 18px; text-align: center; margin-bottom: 4px; }
.doc h2 { font-size: 16px; text-align: center; font-weight: 600; margin-bottom: 18px; }
.doc .sec { font-weight: 700; margin-top: 14px; }
.doc ol { margin-left: 28px; }
.doc table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.doc table th, .doc table td { border: 1px solid #000; padding: 5px 8px; font-size: 15px; }
.doc .sign-block { margin-top: 48px; text-align: center; }
.doc .sign-right { margin-top: 48px; text-align: right; }
.doc .sign-right .inner { display: inline-block; text-align: center; }
.doc .blank-lines { border-bottom: 1px dotted #555; height: 26px; margin: 6px 0; }
.doc .doc-images { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.doc .doc-images img { width: 100%; border: 1px solid #999; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .form-grid { grid-template-columns: 1fr; }
}
