/* EduProLink Forms — shared styles for the staff area and public forms */

:root {
    --brand: #2f5bea;
    --ink: #1c2230;
    --muted: #5d6677;
    --line: #dfe3ea;
    --soft: #f4f6f9;
    --bg: #eef1f5;
    --white: #ffffff;
    --danger: #c62f3b;
    --ok: #1d7f4e;
    --warn: #a86500;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 14px rgba(20, 30, 50, .06);
    --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.55; font-size: 15px; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
small, .muted { color: var(--muted); }
[x-cloak] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons & inputs ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4em;
    padding: .55em 1em; border-radius: 8px; border: 1px solid var(--line); background: var(--white);
    color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand); filter: brightness(.93); }
.btn-danger { color: var(--danger); border-color: #f0c5c9; }
.btn-danger:hover { background: #fdf0f1; }
.btn-sm { padding: .3em .7em; font-size: .88rem; }
.btn-link { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 600; cursor: pointer; font: inherit; }

.input, select.input, textarea.input {
    width: 100%; padding: .6em .75em; border: 1px solid #c9cfd9; border-radius: 8px; background: #fff;
    font: inherit; color: inherit;
}
.input:focus, .input:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 1px; border-color: var(--brand); }
textarea.input { min-height: 6em; resize: vertical; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; min-height: 14em; }
.label { display: block; font-weight: 600; margin-bottom: .35em; }
.hint { font-size: .86rem; color: var(--muted); margin-top: .3em; }
.error { color: var(--danger); font-size: .88rem; margin-top: .35em; }
.has-error .input, .has-error .choice-list, .has-error .sig-box { border-color: var(--danger); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.check { display: flex; gap: .55em; align-items: flex-start; }
.check input { margin-top: .3em; width: 1.05em; height: 1.05em; accent-color: var(--brand); flex: none; }

/* ---------- Cards, tables, badges ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 1.25rem; }
.alert { padding: .8em 1em; border-radius: 8px; margin-bottom: 1rem; }
.alert-ok { background: #e7f5ed; color: var(--ok); }
.alert-error { background: #fdecee; color: var(--danger); }
.alert-warn { background: #fff4e0; color: var(--warn); }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65em .8em; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .82rem; color: var(--muted); font-weight: 600; background: var(--soft); white-space: nowrap; }
.table tr:hover td { background: #fafbfd; }
.badge { display: inline-block; white-space: nowrap; padding: .15em .6em; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--soft); color: var(--muted); }
.badge-published, .badge-done { background: #e7f5ed; color: var(--ok); }
.badge-draft, .badge-new { background: #e8eefc; color: #2c4fc2; }
.badge-closed { background: #f1f1f1; color: #777; }
.badge-reviewed { background: #fff4e0; color: var(--warn); }
.badge-alert { background: #fdecee; color: var(--danger); }
.swatch { display: inline-block; width: .9em; height: .9em; border-radius: 3px; vertical-align: -1px; }

/* ---------- Staff layout ---------- */
.topbar { background: #141a26; color: #fff; }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 1.5rem; height: 56px; }
.topbar a { color: #cdd5e4; text-decoration: none; font-weight: 600; }
.topbar a.active, .topbar a:hover { color: #fff; }
.topbar .logo { color: #fff; font-weight: 800; letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }
.topbar form { margin: 0; }
.topbar .btn-link { color: #cdd5e4; }
.page { max-width: 1280px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.crumbs { font-size: .88rem; color: var(--muted); margin-bottom: .3rem; }
.crumbs a { color: var(--muted); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs button, .tabs a { border: 0; background: none; padding: .7em 1em; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; text-decoration: none; }
.tabs .active { color: var(--brand); border-bottom-color: var(--brand); }
.pagination { display: flex; gap: .3rem; margin-top: 1rem; flex-wrap: wrap; }
.pagination a, .pagination span { padding: .35em .75em; border: 1px solid var(--line); border-radius: 6px; background: #fff; text-decoration: none; color: var(--ink); }
.pagination .current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .disabled { color: #aaa; }

/* ---------- Form builder ---------- */
.builder { display: grid; grid-template-columns: 210px minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
.palette { position: sticky; top: 1rem; }
.palette button { display: block; width: 100%; text-align: left; margin-bottom: .35rem; }
.canvas { min-height: 300px; }
.canvas-empty { padding: 3rem 1rem; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }
.b-field { display: flex; gap: .6rem; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .7rem .8rem; margin-bottom: .5rem; cursor: pointer; }
.b-field:hover { border-color: #b8c2d4; }
.b-field.selected { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); }
.b-field.is-break { background: var(--soft); border-style: dashed; }
.b-handle { cursor: grab; color: #9aa3b2; user-select: none; padding: 0 .2rem; font-size: 1.1rem; line-height: 1.3; }
.b-main { flex: 1; min-width: 0; }
.b-type { font-size: .75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.b-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.b-meta { font-size: .8rem; color: var(--muted); }
.b-actions { display: flex; gap: .25rem; }
.sortable-ghost { opacity: .4; }
.props { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
.savebar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: .5rem 0; }

/* ---------- Public form ---------- */
.public { padding: 24px 16px 60px; }
.public-card { max-width: 780px; margin: 0 auto; background: #fff; border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.public-head { border-top: 6px solid var(--brand); padding: 1.6rem 1.6rem 1rem; }
.public-head img.logo { max-height: 54px; max-width: 220px; display: block; margin-bottom: 1rem; }
.public-body { padding: 0 1.6rem 1.6rem; }
.preview-flag { background: #fff4e0; color: var(--warn); text-align: center; padding: .5em; font-weight: 600; font-size: .9rem; }
.progress { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; margin: .25rem 0 1.25rem; }
.progress > div { height: 100%; background: var(--brand); transition: width .2s; }
.q { margin: 0 0 1.4rem; }
.q-label { font-weight: 600; display: block; margin-bottom: .45rem; }
.q-label .req { color: var(--danger); margin-left: .15em; }
.q-heading { font-size: 1.2rem; font-weight: 700; margin: 1.6rem 0 .8rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.input[readonly], .input:disabled { background: var(--soft); color: var(--muted); }
.hours-out { display: inline-block; min-width: 160px; padding: .55em .9em; border-radius: 8px; background: var(--soft); font-size: 1.1rem; }
.choice-list { display: grid; gap: .45rem; border: 1px solid transparent; border-radius: 8px; }
.rich { overflow-wrap: anywhere; }
.rich table { border-collapse: collapse; max-width: 100%; width: auto !important; }
.rich td, .rich th { border: 1px solid #c9cfd9; padding: .4em .6em; vertical-align: top; width: auto !important; }
.rich-box { border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.1rem; background: #fcfcfd; max-height: 460px; overflow-y: auto; margin-bottom: 1.4rem; }
.rich-box.open { max-height: none; }
.sig-box { border: 1px solid #c9cfd9; border-radius: 8px; background: #fff; position: relative; }
.sig-box canvas { display: block; width: 100%; height: 180px; touch-action: none; }
.sig-foot { display: flex; justify-content: space-between; align-items: center; padding: .35em .6em; border-top: 1px dashed var(--line); font-size: .85rem; color: var(--muted); }
.t-table { width: 100%; border-collapse: collapse; }
.t-table th { font-size: .82rem; text-align: left; color: var(--muted); padding: .3em .3em; }
.t-table td { padding: .25em .3em; }
.nav-buttons { display: flex; justify-content: space-between; gap: .75rem; margin-top: 1.5rem; }
.done { text-align: center; padding: 2.5rem 1rem; }
.done .tick { width: 56px; height: 56px; border-radius: 50%; background: #e7f5ed; color: var(--ok); display: inline-flex; align-items: center; justify-content: center; font-size: 1.8rem; margin-bottom: 1rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.public-foot { max-width: 780px; margin: 1rem auto 0; text-align: center; font-size: .82rem; color: var(--muted); white-space: pre-line; }

/* ---------- Submission detail ---------- */
.answer-list { display: grid; grid-template-columns: minmax(180px, 34%) 1fr; }
.answer-list > div { padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
.answer-list .a-label { color: var(--muted); font-size: .9rem; }
.answer-list .a-value { overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }
.sig-img { max-width: 320px; max-height: 120px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.audit { font-size: .85rem; }
.audit dt { color: var(--muted); }
.audit dd { margin: 0 0 .6rem; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
    .builder { grid-template-columns: 1fr; }
    .palette { position: static; display: flex; flex-wrap: wrap; gap: .35rem; }
    .palette button { width: auto; margin: 0; }
    .props { position: static; max-height: none; }
}
@media (max-width: 640px) {
    .grid-2 { grid-template-columns: 1fr; }
    .answer-list { grid-template-columns: 1fr; }
    .answer-list .a-label { border-bottom: 0; padding-bottom: 0; }
    .public { padding: 0 0 40px; }
    .public-card { border-radius: 0; }
    .public-head, .public-body { padding-left: 16px; padding-right: 16px; }
    .topbar-inner { gap: 1rem; overflow-x: auto; }
}
