/* ธีม PWK Smart School — สีประจำโรงเรียน ส้ม-ขาว
 * รองลงมา: ส้มอ่อน · เหลืองทอง · เทาควันบุหรี่ · เขียว (เล็กน้อยเฉพาะส่วนย่อย)
 * โหลดหลัง styles.css
 */
:root {
  --orange: #F26522;      /* ส้มประจำโรงเรียน */
  --orange-2: #FF8A3D;
  --orange-d: #D2501A;
  --orange-dd: #A63C10;
  --peach: #FFE3D0;       /* ส้มอ่อน */
  --peach-50: #FFF4EC;
  --orange-50: var(--peach-50);
  --orange-100: var(--peach);
  --gold: #E8B020;        /* เหลืองทอง */
  --gold-d: #B8860B;
  --gold-50: #FFF7DE;
  --smoke: #6F6A66;       /* เทาควันบุหรี่ */
  --smoke-d: #4A4643;
  --smoke-50: #F4F3F1;
  --green: #4CAF7A;       /* เขียว (ใช้น้อย) */
  --green-50: #EAF7EF;
  --ink: #3A2A20;
  --ink-2: var(--smoke);
  --line: #FBE0CF;
  --card: rgba(255, 255, 255, .94);
  --shadow: 0 12px 30px -16px rgba(210, 80, 26, .35), 0 2px 6px rgba(74, 70, 67, .06);
}

/* ───── พื้นหน้า: ขาวเป็นหลัก ไล่ส้มอ่อนด้านบน → ขาว → ทองอ่อน → เทาควันบุหรี่อ่อน ───── */
body {
  color: var(--ink);
  background: linear-gradient(180deg, var(--peach-50) 0%, #FFFFFF 26%, #FFFFFF 60%, #FFFBF1 82%, var(--smoke-50) 100%) fixed;
}
.bg { opacity: .16; filter: blur(30px) saturate(1.05); }
.bg::after { background: rgba(255, 255, 255, .6); }

/* ───── ตรา/โลโก้ 3 มิติ + ดุ๊กดิ๊ก + แสงวาบ ───── */
.logo3d {
  position: relative; display: inline-block; flex: none; line-height: 0;
  transform-style: preserve-3d; animation: wiggle3d 5.5s ease-in-out infinite; will-change: transform;
}
.logo3d img {
  display: block;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .9)) drop-shadow(0 3px 2px rgba(120, 50, 10, .25)) drop-shadow(0 10px 14px rgba(120, 50, 10, .22));
}
.logo3d::after { /* แสงวาบวิ่งผ่านเฉพาะรูปทรงโลโก้ */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .75) 48%, transparent 60%) no-repeat;
  background-size: 260% 100%; background-position: 160% 0;
  -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat;
  animation: shine 6s ease-in-out infinite; mix-blend-mode: soft-light;
}
.logo3d.d2 { animation-delay: -1.8s; } .logo3d.d2::after { animation-delay: 2s; }
.logo3d.d3 { animation-delay: -3.4s; } .logo3d.d3::after { animation-delay: 4s; }
@keyframes wiggle3d {
  0%, 100% { transform: perspective(700px) rotateY(-9deg) rotateZ(-1.2deg) translateY(0); }
  25% { transform: perspective(700px) rotateY(0deg) rotateZ(0deg) translateY(-3px); }
  50% { transform: perspective(700px) rotateY(9deg) rotateZ(1.2deg) translateY(0); }
  75% { transform: perspective(700px) rotateY(0deg) rotateZ(0deg) translateY(-2px); }
}
@keyframes shine { 0%, 55% { background-position: 160% 0; } 85%, 100% { background-position: -60% 0; } }

/* ───── แบนเนอร์ด้านบน ───── */
.site-head {
  position: relative; overflow: hidden;
  background: linear-gradient(100deg, #FFFFFF 0%, #FFFFFF 30%, var(--peach-50) 52%, var(--peach) 72%, #FFB989 88%, var(--orange-2) 100%);
  background-size: 200% 100%;
  animation: headFlow 16s ease-in-out infinite alternate;
  border-bottom: 5px solid var(--orange);
  box-shadow: 0 8px 22px -14px rgba(210, 80, 26, .6);
}
.site-head::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.site-head::after { /* ภาพปราสาทจาง ๆ ฝั่งขวา */
  content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 46%; opacity: .14; pointer-events: none;
  background: url('assets/prasat.jpg') center 30% / cover no-repeat;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 60%); mask-image: linear-gradient(90deg, transparent, #000 60%);
  filter: saturate(.8) sepia(.3);
}
@keyframes headFlow { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }
.head-inner {
  position: relative; z-index: 1; max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: clamp(8px, 1.2vw, 12px) clamp(12px, 3vw, 28px);
}
.school { display: flex; align-items: center; gap: clamp(10px, 1.6vw, 18px); color: inherit; text-decoration: none; min-width: 0; }
.site-head .logo-school { width: clamp(48px, 5.6vw, 76px); height: auto; }
.name-box {
  min-width: 0; background: rgba(255, 255, 255, .95); border-radius: 16px; padding: clamp(5px, .8vw, 8px) clamp(10px, 1.4vw, 16px);
  border: 1px solid var(--line); box-shadow: 0 6px 18px -12px rgba(210, 80, 26, .45);
}
.name-box h1 { margin: 0; font: 700 clamp(17px, 2.3vw, 29px)/1.15 'Prompt', sans-serif; color: var(--orange-d); letter-spacing: -.3px; white-space: nowrap; }
.name-box .en { font: 500 clamp(9.5px, .95vw, 12.5px) 'Prompt'; color: var(--smoke); letter-spacing: .6px; margin-top: 2px; }
.name-box .motto { font-size: clamp(10.5px, .95vw, 12.5px); color: var(--smoke-d); }
.ministry { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none; }
.ministry .logo-obec { height: clamp(44px, 5.2vw, 70px); width: auto; display: block; }
.ministry small { font: 500 clamp(9px, .8vw, 11px)/1.2 'Prompt'; color: var(--smoke-d); white-space: nowrap; background: rgba(255, 255, 255, .8); padding: 1px 7px; border-radius: 99px; }

/* ───── หัวเรื่องประจำหน้า ───── */
.hero { max-width: 1240px; margin: 0 auto; padding: clamp(12px, 2.2vw, 24px) clamp(12px, 3vw, 28px) 4px; }
.hero-card {
  position: relative; overflow: hidden; isolation: isolate; display: block;
  min-height: clamp(160px, 16vw, 210px);
  padding: clamp(52px, 4.6vw, 60px) clamp(18px, 36%, 440px) clamp(18px, 3vw, 34px) clamp(18px, 4vw, 52px);
  border-radius: 26px; border: 1px solid var(--line); border-left: 8px solid var(--orange);
  background: linear-gradient(115deg, #FFFFFF 0%, #FFFFFF 30%, var(--peach-50) 55%, var(--gold-50) 75%, #FFFFFF 100%);
  background-size: 300% 300%; animation: heroFlow 22s ease-in-out infinite;
  box-shadow: 0 18px 40px -26px rgba(210, 80, 26, .55);
}
@keyframes heroFlow { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.hero-text { position: relative; z-index: 3; min-width: 0; }
.hero-eyebrow {
  display: inline-block; font: 500 clamp(12px, 1.3vw, 15px) 'Prompt'; color: var(--orange-d);
  background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: 3px 12px; margin-bottom: 8px;
  box-shadow: 0 2px 8px -4px rgba(210, 80, 26, .4);
}
.hero h2 { margin: 0; font: 700 clamp(24px, 3.2vw, 42px)/1.12 'Prompt', sans-serif; color: var(--ink); letter-spacing: -.5px; }
.hero h2.swap { animation: titleIn .5s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes titleIn { from { opacity: 0; transform: translateY(10px); } }
.hero p { margin: 6px 0 0; font-size: clamp(13px, 1.3vw, 17px); color: var(--smoke); max-width: 640px; }
/* นาฬิกา: มุมซ้ายบนของการ์ด (ไม่ทับภาพประกอบ) */
.hero-side { position: absolute; top: clamp(12px, 1.4vw, 16px); left: clamp(18px, 4vw, 52px); z-index: 4; }
.clock {
  background: rgba(255, 255, 255, .92); border: 1.5px solid var(--line); border-radius: 12px; padding: 6px 14px;
  font: 500 clamp(12.5px, 1.2vw, 15px) 'Prompt'; color: var(--smoke-d); white-space: nowrap; backdrop-filter: blur(6px);
  box-shadow: 0 6px 16px -10px rgba(210, 80, 26, .45); font-variant-numeric: tabular-nums;
}
.clock .t { color: var(--orange-d); font-weight: 600; }

/* ภาพประกอบ: ปราสาท (ภาพถ่ายเบลอจาง) + ช้างทรงเครื่อง */
.hero-art { position: absolute; top: 0; bottom: 0; right: 0; width: min(38%, 460px); z-index: 1; pointer-events: none; }
.hero-prasat {
  position: absolute; inset: 0; background: url('assets/prasat.jpg') center 35% / cover no-repeat;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, .5) 30%, #000 65%); mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, .5) 30%, #000 65%);
  filter: blur(1.5px) saturate(.9); opacity: .55; animation: kenburns 30s ease-in-out infinite alternate;
}
.hero-prasat::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255, 244, 236, .5), rgba(255, 255, 255, .1) 60%, rgba(255, 244, 236, .65)); }
@keyframes kenburns { from { transform: scale(1); } to { transform: scale(1.08) translateX(-2%); } }
.hero-elephant {
  position: absolute; right: clamp(6px, 4%, 44px); bottom: 0; height: 94%; aspect-ratio: 688 / 720;
  transform-origin: 50% 100%; animation: sway 6s ease-in-out infinite;
}
.hero-elephant::before { /* เงาบนพื้น */
  content: ''; position: absolute; left: 8%; right: 4%; bottom: 0; height: 9%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(74, 40, 20, .38), transparent); animation: shadowPulse 6s ease-in-out infinite;
}
.hero-elephant img { position: relative; display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(74, 40, 20, .25)); }
@keyframes sway { 0%, 100% { transform: rotate(-1.4deg) translateX(0); } 50% { transform: rotate(1.2deg) translateX(-4px) translateY(-2px); } }
@keyframes shadowPulse { 50% { transform: scaleX(.92); opacity: .8; } }

/* หัวข้อเดิมที่ซ้ำกับหัวเรื่อง → ซ่อน (เหลือปุ่มเครื่องมือ) */
#app > .section-head:first-child h2 { display: none; }
#app > .section-head:first-child { justify-content: flex-end; min-height: 0; margin-top: 0; }
#app > .section-head:first-child:not(:has(.toolbar, .btn, .muted)) { display: none; }

/* ───── แถบเมนู ───── */
.tabs { background: rgba(255, 255, 255, .9); border-bottom: 1px solid var(--line); box-shadow: 0 6px 16px -14px rgba(210, 80, 26, .5); }
.tabs button { color: var(--smoke-d); }
.tabs button:hover { background: var(--peach-50); color: var(--orange-d); }
.tabs button.active { background: linear-gradient(135deg, var(--orange-2), var(--orange)); color: #fff; }
.badge { background: var(--orange-dd); }

/* ───── การ์ด / ส่วนย่อย ───── */
.card { background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.card h3 { color: var(--orange-dd); }
.card h3::after { content: ''; flex: 1; height: 2px; margin-left: 6px; border-radius: 2px; background: linear-gradient(90deg, rgba(232, 176, 32, .55), transparent); }
.section-head h2 { color: var(--orange-d); }
.muted { color: var(--smoke); }
.stat::after { background: var(--peach); }
.stat.red::after { background: #FFE0D6; }
.stat.amber::after { background: var(--gold-50); }
.stat.green::after { background: var(--green-50); }
.stat.red b { color: var(--orange-dd); }
.stat.amber b { color: var(--gold-d); }
.stat.green b { color: #2E8B57; }
.pill.ok, .pill.พร้อมใช้, .pill.เสร็จ, .pill.อนุมัติ { background: var(--green-50); color: #237A4B; }
.pill.soon, .pill.ขออนุมัติ, .pill.รออนุมัติ { background: var(--gold-50); color: #8A6100; }
.pill.overdue, .pill.ซ่อม, .pill.ด่วน, .pill.แจ้งซ่อม, .pill.ไม่อนุมัติ { background: #FFE3D8; color: #A3300B; }
.pill.กำลังซ่อม { background: var(--peach); color: var(--orange-dd); }
.pill.nodata, .pill.งดใช้, .pill.จำหน่าย { background: var(--smoke-50); color: var(--smoke-d); }
.aitem { border-left-color: var(--gold); }
.aitem.overdue { border-left-color: var(--orange); background: #FFF7F2; }
.bar { background: var(--smoke-50); }
.bar i { background: linear-gradient(90deg, var(--green), #8FD3A8); }
.bar i.soon { background: linear-gradient(90deg, var(--gold), #FFD66B); }
.bar i.overdue { background: linear-gradient(90deg, var(--orange-d), var(--orange-2)); }
.chart-bars .r .bar i { background: linear-gradient(90deg, var(--orange), var(--gold)); }
th { background: linear-gradient(180deg, var(--peach-50), #FFF9F4); color: var(--orange-d); }
.btn { background: linear-gradient(135deg, var(--orange-2), var(--orange)); }
.btn:hover { background: var(--orange-d); }
.btn.ghost { background: #fff; color: var(--orange-d); border-color: var(--line); }
.btn.ghost:hover { background: var(--peach-50); }
.kv div { background: linear-gradient(180deg, var(--peach-50), #FFFBF8); }
.check { background: var(--peach-50); }
.subtabs button.active { background: var(--orange); border-color: var(--orange); }
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(242, 101, 34, .14); }
.vcard .art, .type-card .art, .detail-art, .art-preview { background: radial-gradient(120% 90% at 50% 100%, #fff, var(--peach-50) 55%, var(--peach)); }
.modal > header { background: linear-gradient(90deg, var(--peach-50), #fff); }
.chat > header { background: linear-gradient(115deg, var(--orange-d), var(--orange-2)); }
.msg.me { background: var(--orange); }

/* ───── แบนเนอร์ด้านล่าง: ลายผ้าไหมเคลื่อนไหว ───── */
.site-foot {
  position: relative; overflow: hidden; isolation: isolate; color: #fff; text-align: center;
  background: linear-gradient(100deg, var(--orange-dd), var(--orange-d) 35%, var(--orange) 65%, var(--orange-d));
  background-size: 220% 100%; animation: footFlow 18s ease-in-out infinite alternate;
  padding: 18px 16px calc(18px + var(--safe-b)); border-top: 4px solid var(--gold);
}
@keyframes footFlow { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }
.foot-pattern { /* ลายมัดหมี่ (ข้าวหลามตัด) 2 ชั้น เลื่อนสวนทางกันช้า ๆ */
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cpath d='M32 4 60 32 32 60 4 32Z' fill='none' stroke='%23FFD27A' stroke-opacity='.45' stroke-width='1.5'/%3E%3Cpath d='M32 18 46 32 32 46 18 32Z' fill='%23FFFFFF' fill-opacity='.13'/%3E%3Ccircle cx='32' cy='32' r='3.2' fill='%23FFE08A' fill-opacity='.6'/%3E%3Cpath d='M0 0h7L0 7Zm64 0h-7l7 7ZM0 64h7l-7-7Zm64 0h-7l7-7Z' fill='%238FD3A8' fill-opacity='.35'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='24' viewBox='0 0 48 24'%3E%3Cpath d='M0 18 12 6 24 18 36 6 48 18' fill='none' stroke='%23FFFFFF' stroke-opacity='.12' stroke-width='2'/%3E%3C/svg%3E");
  background-size: 64px 64px, 48px 24px;
  animation: ikat 26s linear infinite;
}
@keyframes ikat { from { background-position: 0 0, 0 0; } to { background-position: 128px 64px, -192px 0; } }
.foot-silk {
  position: absolute; left: clamp(-30px, -1vw, 0px); bottom: -14px; width: clamp(120px, 13vw, 180px); z-index: 0; opacity: .95;
  filter: drop-shadow(0 8px 12px rgba(60, 20, 0, .35)); transform-origin: 30% 100%; animation: silkWave 7s ease-in-out infinite;
}
@keyframes silkWave { 0%, 100% { transform: rotate(-2deg) skewX(0deg); } 50% { transform: rotate(1deg) skewX(-2deg) translateY(-3px); } }
.foot-inner { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; display: grid; gap: 3px; }
.site-foot p { margin: 0; font: 400 clamp(11.5px, 1vw, 13.5px)/1.55 'Prompt'; text-shadow: 0 1px 2px rgba(80, 25, 0, .35); }
.site-foot .l1 { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 12px; }
.foot-logo { width: 30px; height: 30px; }
.site-foot .l1 b { font-size: clamp(13px, 1.2vw, 15.5px); }
.site-foot a { color: #fff; text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 4px; }
.site-foot .l3 { font-size: 11px; opacity: .85; }
.site-foot .demo-tag { color: #6a4300; text-shadow: none; }
main { padding-bottom: 40px; }

/* ───── iPad ───── */
@media (max-width: 1024px) {
  .name-box .motto { display: none; }
  .hero-card { padding-right: 40%; }
  .hero-art { width: 40%; }
  .foot-silk { width: 110px; opacity: .75; }
  .foot-inner { padding: 0 80px 0 90px; }
}

/* ───── มือถือ ───── */
@media (max-width: 700px) {
  .head-inner { gap: 8px; }
  .name-box h1 { white-space: normal; font-size: 16px; }
  .name-box .en { font-size: 9px; letter-spacing: .3px; }
  .site-head .logo-school { width: 44px; }
  .ministry .logo-obec { height: 38px; }
  .ministry small { font-size: 8.5px; padding: 0 5px; }
  .site-head::after { width: 60%; opacity: .1; }
  .hero { padding-top: 10px; }
  .hero-card { border-radius: 20px; border-left-width: 6px; min-height: 0; padding: 52px 40% 14px 14px; }
  .hero-side { left: 12px; right: 12px; top: 10px; }
  .clock { white-space: normal; font-size: 11.5px; padding: 5px 10px; display: flex; flex-wrap: wrap; justify-content: center; gap: 0 6px; }
  .hero h2 { font-size: 21px; }
  .hero p { font-size: 12.5px; }
  .hero-eyebrow { font-size: 11px; }
  .hero-art { width: 36%; top: 50px; }
  .hero-elephant { height: auto; width: 100%; max-height: 100%; right: 0; }
  .foot-silk { width: 84px; left: -14px; bottom: -8px; opacity: .45; }
  .foot-inner { padding: 0 62px 0 0; }
  .site-foot { padding-bottom: calc(86px + var(--safe-b)); }
  .site-foot .l1 span { flex-basis: 100%; }
}
@media (max-width: 380px) {
  .name-box h1 { font-size: 15px; }
  .ministry small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .logo3d, .logo3d::after, .site-head, .hero-card, .hero-prasat, .hero-elephant, .hero-elephant::before, .site-foot, .foot-pattern, .foot-silk { animation: none !important; }
}
@media print { .hero-art, .site-foot { display: none !important; } }

/* ───── v5: แบนเนอร์ล่าง โลโก้ชิดชื่อ PWK Smart School ───── */
.foot-brand { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.site-foot .l1 .foot-brand { justify-content: center; }
.site-foot .l1 .foot-brand .logo3d { flex: none; }
@media (max-width: 700px) { .site-foot .l1 { gap: 2px 8px; } .foot-logo { width: 26px; height: 26px; } }

/* ปุ่มเข้าสู่ระบบผู้ดูแล (ท้ายแถบเมนู) */
.tabs .admin-btn { margin-left: auto; opacity: .75; }
.tabs .admin-btn:hover { opacity: 1; }

/* ───── ไปราชการ ───── */
.trip-now { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.trip-chip { display: grid; gap: 3px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); border-left: 5px solid var(--gold); background: linear-gradient(135deg, #fff, var(--peach-50)); min-width: 0; }
.trip-chip span { font-weight: 500; overflow-wrap: anywhere; }
.trip-chip .btn { justify-self: start; margin-top: 4px; }
.tabs button[hidden] { display: none !important; }
