/* ============================================================
   Resume Creator — UI chrome (ธีม Skill360: ครีม/ทอง serif)
   หมายเหตุ: นี่คือสไตล์ "หน้าเครื่องมือ" เท่านั้น
   ตัวเรซูเม่ที่สร้าง (ใน iframe) มีสไตล์ของตัวเองใน templates.js
   ============================================================ */
:root{
  --bg:#FBFAF7; --surface:#FFFFFF; --desk:#EAE5D9;
  --ink:#17150F; --ink-soft:#5C594E; --muted:#9B968A;
  --line:#E9E5DC; --line-strong:#D9D4C7;
  --gold:#9C7C38; --gold-soft:#C2A468; --gold-tint:#F6F1E6;
  --ok:#4E7A5A; --danger:#B4433A; --danger-tint:#FBEDEC;
  --radius:14px;
  --shadow:0 1px 2px rgba(23,21,15,.04), 0 12px 40px -12px rgba(23,21,15,.08);
  --serif:'Noto Serif Thai', Georgia, serif;
  --sans:'Anuphan', -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --mono:'JetBrains Mono', ui-monospace, monospace;
  --topbar-h:62px;
  --brand:#1f4e79; /* สี accent ของเรซูเม่ (JS ตั้งค่า) — ใช้เฉพาะแถบพรีวิวย่อของเทมเพลต */
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  display:flex;flex-direction:column;
  background:var(--bg);
  color:var(--ink);
  font-family:var(--sans);
  font-size:14px;
  line-height:1.55;
  -webkit-font-smoothing:antialiased;
  overflow:hidden; /* ให้แต่ละ pane เลื่อนเอง (สลับเป็นเลื่อนทั้งหน้าในมือถือ) */
}
h1,h2,h3,p{margin:0}
button,input,select,textarea{font:inherit;color:inherit}
a{color:inherit}
::selection{background:var(--gold-tint);color:var(--gold)}

/* ---------- Topbar ---------- */
.topbar{
  flex:none;min-height:var(--topbar-h);
  display:flex;align-items:center;justify-content:space-between;gap:16px;
  padding:9px 22px;
  background:rgba(251,250,247,.9);backdrop-filter:blur(12px);
  border-bottom:1px solid var(--line);
}
.topbar-left{display:flex;align-items:center;gap:14px;min-width:0}
.brand{display:flex;align-items:center;gap:10px;text-decoration:none;flex:none}
.brand-mark{
  width:34px;height:34px;border:1px solid var(--gold);border-radius:50%;
  display:grid;place-items:center;font-family:var(--serif);font-size:15px;color:var(--gold);
  transition:background .2s,color .2s;
}
.brand:hover .brand-mark{background:var(--gold);color:#fff}
.brand-name{font-family:var(--serif);font-size:16px;font-weight:500;letter-spacing:.02em}
.brand-name em{font-style:normal;color:var(--gold)}
.tool-id{min-width:0}
.tool-id h1{font-family:var(--serif);font-size:15px;font-weight:600;letter-spacing:.01em;white-space:nowrap}
.tag{font-size:11.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar-actions{display:flex;align-items:center;gap:7px;flex-wrap:wrap;justify-content:flex-end}
.divider{width:1px;height:26px;background:var(--line-strong);flex:none}

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  border:1px solid var(--line-strong);
  background:var(--surface);
  color:var(--ink-soft);
  border-radius:10px;
  padding:8px 14px;
  cursor:pointer;
  font-size:13px;font-weight:500;
  white-space:nowrap;
  transition:background .18s,border-color .18s,color .18s,transform .06s;
}
.btn:hover{border-color:var(--gold-soft);color:var(--ink)}
.btn:active{transform:translateY(1px)}
.btn:disabled{opacity:.5;cursor:not-allowed}
.btn.primary{background:var(--ink);border-color:var(--ink);color:#FCFBF8}
.btn.primary:hover{background:#000;color:#fff}
.btn.primary.is-busy{background:var(--gold);border-color:var(--gold)}
.btn.ghost{background:var(--surface)}
.btn.small{padding:5px 10px;font-size:12px;border-radius:8px}
.btn.icon{padding:4px 9px;line-height:1.3;color:var(--ink-soft)}
.btn.danger{color:var(--danger);border-color:#E6CFCB}
.btn.danger:hover{background:var(--danger-tint);border-color:var(--danger)}

/* ---------- Layout (สอง pane เต็มจอ) ---------- */
.layout{
  flex:1;min-height:0;
  display:grid;
  grid-template-columns:minmax(420px,1fr) minmax(460px,1.05fr);
}
.pane{overflow-y:auto;min-width:0}
.pane-form{padding:20px 20px 64px}
.pane-preview{
  background:var(--desk);
  border-left:1px solid var(--line);
  display:flex;flex-direction:column;overflow:hidden;
}
/* scrollbar บาง ๆ ให้เข้าธีม */
.pane::-webkit-scrollbar,.preview-scroll::-webkit-scrollbar{width:10px;height:10px}
.pane::-webkit-scrollbar-thumb,.preview-scroll::-webkit-scrollbar-thumb{background:var(--line-strong);border-radius:99px;border:3px solid transparent;background-clip:content-box}

/* ---------- Cards ---------- */
.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  margin-bottom:16px;
  overflow:hidden;
}
.card-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:15px 18px;
  border-bottom:1px solid var(--line);
  background:linear-gradient(var(--gold-tint),rgba(246,241,230,.35));
}
.card-head h2{font-family:var(--serif);font-size:15.5px;font-weight:600;color:var(--ink)}
.card-head.collapsible{cursor:pointer;user-select:none}
.card-head .chev{color:var(--gold);transition:transform .2s}
.card-head.closed .chev{transform:rotate(-90deg)}
.card-body{padding:18px}
.card-body.hidden{display:none}

/* ---------- Template picker ---------- */
.tpl-grid{
  display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));
  gap:12px;padding:18px;
}
.tpl{
  border:1px solid var(--line-strong);border-radius:11px;padding:9px;
  cursor:pointer;background:var(--surface);text-align:left;
  transition:border-color .18s,box-shadow .18s,transform .06s;
}
.tpl:hover{border-color:var(--gold-soft);box-shadow:var(--shadow)}
.tpl:active{transform:translateY(1px)}
.tpl.active{border-color:var(--gold);box-shadow:0 0 0 3px rgba(156,124,56,.16)}
.tpl-name{font-size:12.5px;font-weight:600;margin-top:8px;color:var(--ink)}
.tpl-desc{font-size:11px;color:var(--muted);line-height:1.4;margin-top:1px}
.tpl-badge{
  display:inline-block;font-size:9.5px;padding:1px 7px;border-radius:99px;
  background:var(--gold-tint);color:var(--gold);margin-left:5px;vertical-align:1px;font-weight:600;
}

/* mini thumbnail (ตัวอย่างเลย์เอาต์เทมเพลต) */
.thumb{
  height:76px;border:1px solid var(--line);border-radius:7px;
  background:#fff;overflow:hidden;padding:7px;display:flex;gap:4px;
}
.thumb .col{display:flex;flex-direction:column;gap:3px;flex:1;min-width:0}
.thumb .bar{height:3px;border-radius:2px;background:#E2DED4}
.thumb .bar.dark{background:#B7B1A2}
.thumb .bar.accent{background:var(--brand)}
.thumb .bar.w70{width:70%}
.thumb .bar.w50{width:50%}
.thumb .bar.w40{width:40%}
.thumb .bar.w85{width:85%}
.thumb .bar.tall{height:6px}
.thumb .bar.center{margin:0 auto}
.thumb .side{width:32%;background:#4A4438;border-radius:4px;padding:5px 4px;display:flex;flex-direction:column;gap:3px}
.thumb .side .bar{background:#8C8474}
.thumb .rule{height:1px;background:#CFC9BB;margin:1px 0}

/* ---------- Fields ---------- */
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.field{display:flex;flex-direction:column;gap:6px;min-width:0}
.field > span{font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--ink-soft);font-weight:500}
.field.full{grid-column:1/-1}
.field.checkline{flex-direction:row;align-items:center;gap:8px}
.field.checkline > span{font-size:13px;letter-spacing:0;text-transform:none;color:var(--ink)}
input[type=text],input[type=email],input[type=tel],select,textarea{
  width:100%;
  border:1px solid var(--line-strong);
  border-radius:9px;
  padding:9px 11px;
  background:var(--bg);
  outline:none;
  transition:border-color .2s,box-shadow .2s,background .2s;
}
input[type=text]:focus,input[type=email]:focus,input[type=tel]:focus,select:focus,textarea:focus{
  border-color:var(--gold-soft);background:var(--surface);
  box-shadow:0 0 0 3px rgba(156,124,56,.12);
}
input::placeholder,textarea::placeholder{color:var(--muted)}
textarea{resize:vertical;min-height:82px;line-height:1.55}
input[type=range]{width:100%;accent-color:var(--gold)}
input[type=color]{width:44px;height:34px;padding:2px;border:1px solid var(--line-strong);border-radius:9px;background:var(--surface);cursor:pointer}
.color-row{display:flex;align-items:center;gap:10px}
.swatches{display:flex;gap:6px;flex-wrap:wrap}
.sw{width:20px;height:20px;border-radius:6px;border:1px solid rgba(23,21,15,.12);cursor:pointer;transition:transform .1s}
.sw:hover{transform:scale(1.12)}
.hint{font-size:11px;color:var(--muted);margin-top:5px}

/* photo */
.photo-row{display:flex;gap:14px;align-items:center;margin-top:16px;padding-top:16px;border-top:1px dashed var(--line-strong)}
.photo-preview{
  width:70px;height:70px;border-radius:12px;border:1px dashed var(--line-strong);
  display:grid;place-items:center;overflow:hidden;flex:none;background:var(--bg);
}
.photo-preview span{font-size:10px;color:var(--muted)}
.photo-preview img{width:100%;height:100%;object-fit:cover}
.photo-actions{display:flex;flex-direction:column;gap:7px;align-items:flex-start}
.photo-actions .btn{display:inline-flex}

/* ---------- Sections ---------- */
.section-card{
  border:1px solid var(--line);border-radius:12px;margin-bottom:12px;
  background:var(--surface);overflow:hidden;box-shadow:0 1px 2px rgba(23,21,15,.03);
}
.section-card.hiddenSec{opacity:.55}
.sec-head{
  display:flex;align-items:center;gap:9px;padding:10px 12px;
  background:var(--gold-tint);border-bottom:1px solid var(--line);
}
.sec-head .kind-tag{
  font-size:10px;padding:2px 8px;border-radius:99px;
  background:var(--surface);color:var(--gold);border:1px solid var(--gold-soft);
  white-space:nowrap;flex:none;font-weight:600;
}
.sec-head input.sec-title{
  flex:1;min-width:60px;font-weight:600;font-size:13.5px;
  border:1px solid transparent;background:transparent;border-radius:7px;padding:5px 7px;
}
.sec-head input.sec-title:hover{background:var(--surface);border-color:var(--line-strong)}
.sec-head input.sec-title:focus{background:var(--surface);border-color:var(--gold-soft);box-shadow:0 0 0 3px rgba(156,124,56,.12)}
.sec-tools{display:flex;gap:5px;flex:none}
.sec-body{padding:12px}

.item{
  border:1px solid var(--line);border-radius:10px;padding:12px;margin-bottom:10px;background:var(--bg);
}
.item:last-of-type{margin-bottom:10px}
.item-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:10px}
.item-num{font-family:var(--mono);font-size:10.5px;letter-spacing:.04em;color:var(--muted);text-transform:uppercase}
.item-tools{display:flex;gap:5px}
.item-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.item-grid .full{grid-column:1/-1}
.empty-note{font-size:12px;color:var(--muted);padding:4px 2px 8px}

.add-section{display:flex;gap:9px;margin-top:8px}
.add-section select{flex:1}
.footnote{font-size:11.5px;color:var(--muted);text-align:center;padding:10px 0 24px}

/* ---------- Preview ---------- */
.preview-bar{
  display:flex;align-items:center;justify-content:space-between;
  padding:11px 18px;background:rgba(251,250,247,.9);backdrop-filter:blur(8px);
  border-bottom:1px solid var(--line);flex:none;
}
.pv-title{font-family:var(--serif);font-size:13px;font-weight:500;color:var(--ink-soft)}
.zoom{display:flex;align-items:center;gap:8px;font-family:var(--mono);font-size:12px;color:var(--ink-soft)}
.zoom span{min-width:44px;text-align:center}
.preview-scroll{flex:1;overflow:auto;padding:26px;display:flex;justify-content:center;align-items:flex-start}
.preview-wrap{transform-origin:top left;flex:none}
#preview{
  width:794px;border:0;display:block;background:#fff;
  transform-origin:top left;border-radius:2px;
  box-shadow:0 6px 30px -6px rgba(23,21,15,.28), 0 2px 8px rgba(23,21,15,.10);
}

/* ---------- Mobile ---------- */
.mobile-tabs{display:none}
@media (max-width:960px){
  body{overflow:visible;display:block;height:auto}
  .layout{grid-template-columns:1fr;height:auto;display:block}
  .pane{height:auto;overflow:visible}
  .pane-preview{height:calc(100vh - 130px);overflow:hidden}
  .mobile-tabs{
    display:flex;gap:8px;padding:9px 16px;background:var(--surface);
    border-bottom:1px solid var(--line);position:sticky;top:0;z-index:30;
  }
  .mtab{
    flex:1;border:1px solid var(--line-strong);background:var(--surface);border-radius:99px;
    padding:9px;cursor:pointer;font-size:13px;font-weight:500;color:var(--ink-soft);transition:all .18s;
  }
  .mtab.active{background:var(--ink);color:#FCFBF8;border-color:var(--ink)}
  .pane[hidden]{display:none}
  .topbar{flex-wrap:wrap;gap:10px}
  .tool-id .tag{display:none}
  .grid2,.item-grid{grid-template-columns:1fr}
}
@media (max-width:560px){
  .topbar{padding:9px 14px}
  .pane-form{padding:16px 14px 60px}
  .tool-id{display:none}
}
