/* =====================================================================
   주간교육활동계획 — 화면용 스타일 (외부 CDN·웹폰트 없음, 시스템 폰트)
   인쇄 규칙은 print.css 에 있다.
   ===================================================================== */

:root {
    --font: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", "Nanum Gothic", sans-serif;
    --c-text: #1d232b;
    --c-muted: #5d6673;
    --c-line: #d5d9e0;
    --c-line-strong: #9aa3af;
    --c-bg: #f3f4f6;
    --c-surface: #ffffff;
    --c-head: #e9ecf1;
    --c-primary: #1f4e8c;
    --c-primary-dark: #173c6c;
    --c-primary-soft: #e8eff8;
    --c-danger: #b42318;
    --c-success-bg: #e8f5ec; --c-success-line: #8cc9a0; --c-success-text: #1d5b30;
    --c-error-bg: #fdecea;   --c-error-line: #f0a39b;   --c-error-text: #8a1c12;
    --c-info-bg: #e8f1fb;    --c-info-line: #9cc2ea;    --c-info-text: #1b4a7a;
    --c-warn-bg: #fff6e0;    --c-warn-line: #f0c96a;    --c-warn-text: #7a5300;
    --radius: 6px;
    --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--c-text);
    background: var(--c-bg);
    word-break: keep-all;
    overflow-wrap: anywhere;
}

a { color: var(--c-primary); }
a:hover { color: var(--c-primary-dark); }

h1, h2, h3, h4 { line-height: 1.3; }

.muted { color: var(--c-muted); font-weight: normal; }
.empty { padding: 32px 0; text-align: center; color: var(--c-muted); }
.sr-only {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------------
   머리(내비게이션)
   --------------------------------------------------------------------- */
.site-header {
    background: var(--c-primary);
    color: #fff;
}
.site-header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px var(--gutter);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
}
.site-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 17px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.site-brand:hover { color: #fff; }
.site-school { font-weight: 400; font-size: 14px; opacity: .85; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.site-nav a {
    color: #fff;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: var(--radius);
    opacity: .88;
}
.site-nav a:hover { background: rgba(255, 255, 255, .12); opacity: 1; color: #fff; }
.site-nav a.is-active { background: rgba(255, 255, 255, .2); opacity: 1; font-weight: 700; }
.site-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.site-user-name { opacity: .9; }
.site-header .btn { color: #fff; border-color: rgba(255, 255, 255, .55); background: transparent; }
.site-header .btn:hover { background: rgba(255, 255, 255, .15); color: #fff; }

.site-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px var(--gutter) 48px;
}

/* ---------------------------------------------------------------------
   페이지 머리·패널·안내
   --------------------------------------------------------------------- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 4px 0 14px;
}
.page-title { margin: 0; font-size: 22px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.lead { margin: 0 0 16px; color: var(--c-muted); }
.lead strong { color: var(--c-text); }

.panel {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 18px;
}
.panel-title { margin: 0 0 12px; font-size: 17px; }

.callout {
    background: var(--c-primary-soft);
    border: 1px solid #c4d5ea;
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

/* ---------------------------------------------------------------------
   버튼
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 7px 14px;
    font: inherit;
    font-size: 14px;
    line-height: 1.2;
    color: var(--c-text);
    background: var(--c-surface);
    border: 1px solid var(--c-line-strong);
    border-radius: var(--radius);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: #f1f3f6; color: var(--c-text); }
.btn:focus-visible { outline: 3px solid #9cc2ea; outline-offset: 1px; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); color: #fff; }
.btn-danger { color: var(--c-danger); border-color: #e3a19a; }
.btn-danger:hover { background: var(--c-error-bg); color: var(--c-danger); }
.btn-ghost { background: transparent; }
.btn-small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn-google {
    width: 100%;
    background: #fff;
    color: #1f1f1f;
    border: 1px solid #747775;
    font-weight: 600;
    min-height: 44px;
}
.btn-google::before {
    content: "G";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #4285f4;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
}
.btn-google:hover { background: #f6f8fb; color: #1f1f1f; }

.inline-form { display: inline; margin: 0; }
.hidden-form { display: none; }

/* ---------------------------------------------------------------------
   플래시 메시지
   --------------------------------------------------------------------- */
.flash {
    padding: 10px 14px;
    margin: 0 0 12px;
    border: 1px solid var(--c-info-line);
    border-radius: var(--radius);
    background: var(--c-info-bg);
    color: var(--c-info-text);
}
.flash-success { background: var(--c-success-bg); border-color: var(--c-success-line); color: var(--c-success-text); }
.flash-error   { background: var(--c-error-bg);   border-color: var(--c-error-line);   color: var(--c-error-text); }
.flash-info    { background: var(--c-info-bg);    border-color: var(--c-info-line);    color: var(--c-info-text); }
.flash-warning { background: var(--c-warn-bg);    border-color: var(--c-warn-line);    color: var(--c-warn-text); }

/* ---------------------------------------------------------------------
   배지
   --------------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.6;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
    vertical-align: middle;
}
.badge-published { background: var(--c-success-bg); color: var(--c-success-text); border-color: var(--c-success-line); }
.badge-draft     { background: var(--c-warn-bg);    color: var(--c-warn-text);    border-color: var(--c-warn-line); }
.badge-current   { background: var(--c-primary-soft); color: var(--c-primary);    border-color: #b9cde6; }
.badge-muted     { background: #f0f1f3; color: var(--c-muted); border-color: var(--c-line); }
.badge-info      { background: var(--c-info-bg); color: var(--c-info-text); border-color: var(--c-info-line); }

/* ---------------------------------------------------------------------
   목록 표 (좁은 화면에서는 카드형)
   --------------------------------------------------------------------- */
.table-wrap { width: 100%; }
.list-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--c-surface);
    border: 1px solid var(--c-line);
}
.list-table th, .list-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--c-line);
    text-align: left;
    vertical-align: middle;
}
.list-table thead th { background: var(--c-head); font-size: 13px; color: #3a414b; white-space: nowrap; }
.list-table tbody tr:hover { background: #fafbfc; }
.list-table tr.is-current { background: #f5f9ff; }
.list-table tr.is-inactive td { color: var(--c-muted); }
.list-table .col-range { white-space: nowrap; }
.list-table .col-status { white-space: nowrap; }
.list-table .col-num { width: 6em; text-align: center; }
.list-table .col-actions { white-space: nowrap; }
.list-table .col-actions .btn,
.list-table .col-actions .inline-form { margin: 2px 2px 2px 0; }
.list-table input[type="text"] { width: 100%; }

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 18px 0; }
.pager-now { color: var(--c-muted); }

/* ---------------------------------------------------------------------
   폼
   --------------------------------------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 16px;
    align-items: start;
}
.form-grid .form-actions { align-self: end; }
.field { margin-bottom: 14px; min-width: 0; }
.form-grid .field { margin-bottom: 0; }
.field-label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.field-help { margin: 4px 0 8px; color: var(--c-muted); font-size: 13px; }
fieldset.field { border: 1px solid var(--c-line); border-radius: var(--radius); padding: 12px 14px; background: var(--c-surface); }
fieldset.field legend { padding: 0 6px; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], select, textarea {
    width: 100%;
    max-width: 100%;
    min-height: 38px;
    padding: 7px 10px;
    font: inherit;
    font-size: 15px;
    color: var(--c-text);
    background: #fff;
    border: 1px solid var(--c-line-strong);
    border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus { outline: 3px solid #bcd5f0; border-color: var(--c-primary); }
textarea { min-height: 240px; resize: vertical; line-height: 1.5; }
input[type="file"] { max-width: 100%; font-size: 14px; }
.input-narrow { max-width: 7em; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-weight: normal; cursor: pointer; }
.check-inline input { width: 18px; height: 18px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.edit-form { max-width: 1000px; }
.attach-edit-list { list-style: none; margin: 0 0 10px; padding: 0; }
.attach-edit-list li { padding: 6px 0; border-bottom: 1px dashed var(--c-line); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.attach-size { color: var(--c-muted); font-size: 13px; }

/* ---------------------------------------------------------------------
   간단 에디터 (editor.js)
   --------------------------------------------------------------------- */
.rte {
    border: 1px solid var(--c-line-strong);
    border-radius: var(--radius);
    background: #fff;
}
.rte:focus-within { outline: 3px solid #bcd5f0; border-color: var(--c-primary); }
.rte-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
    border-bottom: 1px solid var(--c-line);
    background: #f7f8fa;
    border-radius: var(--radius) var(--radius) 0 0;
    position: sticky;
    top: 0;
    z-index: 2;
}
.rte-toolbar button {
    min-width: 34px;
    min-height: 32px;
    padding: 3px 8px;
    font: inherit;
    font-size: 13px;
    background: #fff;
    border: 1px solid var(--c-line);
    border-radius: 4px;
    cursor: pointer;
    color: var(--c-text);
}
.rte-toolbar button:hover { background: var(--c-primary-soft); border-color: #b9cde6; }
.rte-toolbar button[aria-pressed="true"] { background: var(--c-primary-soft); border-color: var(--c-primary); }
.rte-toolbar .rte-sep { width: 1px; background: var(--c-line); margin: 2px 4px; }
.rte-area {
    min-height: 300px;
    max-height: 70vh;
    overflow: auto;
    padding: 12px 14px;
    outline: none;
    line-height: 1.6;
}
.rte-area:empty::before { content: attr(data-placeholder); color: #9aa3af; }
.rte-area table { border-collapse: collapse; width: 100%; margin: 6px 0; table-layout: fixed; }
.rte-area td, .rte-area th { border: 1px solid #8a929e; padding: 4px 6px; vertical-align: top; min-width: 2em; }
.rte-area th { background: var(--c-head); }
.rte-area p { margin: 0 0 .3em; }
.rte-source { display: none; }
.rte-draft-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border: 1px solid var(--c-warn-line);
    border-radius: var(--radius);
    background: var(--c-warn-bg);
    color: var(--c-warn-text);
    font-size: 14px;
}

/* ---------------------------------------------------------------------
   주차 문서(웹 보기 · 인쇄 보기 공용 마크업: render_week_body)
   --------------------------------------------------------------------- */
.doc-frame {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    padding: 28px 32px;
}
.week-doc { color: #111; }
.doc-head { text-align: center; margin-bottom: 18px; }
.doc-school { margin: 0 0 4px; font-size: 14px; color: var(--c-muted); }
.doc-title { margin: 0 0 6px; font-size: 24px; letter-spacing: -0.01em; }
.doc-range { margin: 0; font-size: 15px; color: #333; }
.doc-draft {
    display: inline-block;
    margin: 8px 0 0;
    padding: 1px 10px;
    font-size: 13px;
    color: var(--c-warn-text);
    border: 1px solid var(--c-warn-line);
    border-radius: 4px;
}
.doc-section { margin-top: 18px; }
.doc-h2 {
    margin: 0 0 8px;
    font-size: 16px;
    padding-left: 8px;
    border-left: 4px solid var(--c-primary);
}
.doc-empty { color: var(--c-muted); padding: 12px 0; }
.notice-box { border: 1px solid #555; padding: 10px 12px; }

.plan-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    border: 1.5px solid #333;
}
.plan-table .col-dept { width: 8.5em; }
.plan-table th, .plan-table td {
    border: 1px solid #666;
    padding: 6px 9px;
    vertical-align: top;
    overflow-wrap: anywhere;
}
.plan-table thead th { background: var(--c-head); text-align: center; font-size: 14px; vertical-align: middle; }
.plan-table .dept-name {
    background: #f6f7f9;
    text-align: center;
    vertical-align: middle;
    font-weight: 700;
    font-size: 14px;
}
.dept-edit { display: block; margin-top: 4px; font-size: 12px; font-weight: normal; }

/* 에디터에서 온 본문 */
.rich { line-height: 1.55; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich p { margin: 0 0 .3em; }
.rich h3 { font-size: 1.08em; margin: .5em 0 .3em; }
.rich h4 { font-size: 1em; margin: .45em 0 .25em; }
.rich ul, .rich ol { margin: .2em 0 .4em; padding-left: 1.5em; }
.rich li { margin: .1em 0; }
.rich blockquote { margin: .4em 0; padding: .2em .8em; border-left: 3px solid #bbb; color: #333; }
.rich hr { border: 0; border-top: 1px solid #999; margin: .6em 0; }
.rich table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin: .3em 0 .5em;
}
.rich td, .rich th { border: 1px solid #777; padding: 3px 6px; vertical-align: top; overflow-wrap: anywhere; }
.rich th { background: var(--c-head); }
/* 에디터가 남긴 고정 px 너비는 화면 폭 안으로 */
.rich table[style*="px"] { width: 100% !important; }
.rich td[style*="px"], .rich th[style*="px"], .rich col[style*="px"] { width: auto !important; }

.attach-list { margin: 0; padding-left: 1.2em; }
.attach-list li { margin: 4px 0; }
.attach-dept {
    display: inline-block;
    font-size: 12px;
    padding: 0 6px;
    border-radius: 4px;
    background: #eef0f3;
    color: var(--c-muted);
}

/* ---------------------------------------------------------------------
   로그인 화면 (public/login.php)
   --------------------------------------------------------------------- */
body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px var(--gutter);
    background: linear-gradient(160deg, #e8eef7 0%, #f3f4f6 60%);
}
.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: 10px;
    padding: 28px 26px;
    box-shadow: 0 6px 24px rgba(20, 40, 80, .08);
}
.login-title {
    margin: 0 0 18px;
    font-size: 22px;
    text-align: center;
    color: var(--c-primary);
}
.login-school {
    display: block;
    font-size: 14px;
    font-weight: 400;
    color: var(--c-muted);
    margin-bottom: 4px;
}
.login-section { padding: 16px 0 4px; border-top: 1px solid var(--c-line); }
.login-section:first-of-type { border-top: 0; }
.login-section h2 { margin: 0 0 6px; font-size: 15px; }
.login-help { margin: 0 0 10px; font-size: 13px; color: var(--c-muted); }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 13px; font-weight: 700; margin-top: 4px; }
.login-form .btn { margin-top: 10px; min-height: 44px; }

/* ---------------------------------------------------------------------
   오류 화면 (render_error_page)
   --------------------------------------------------------------------- */
body.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px var(--gutter);
}
.error-box {
    width: 100%;
    max-width: 480px;
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: 10px;
    padding: 28px 24px;
    text-align: center;
}
.error-box h1 { margin: 0 0 16px; font-size: 18px; line-height: 1.5; font-weight: 600; }
.error-box p { margin: 0; }

/* ---------------------------------------------------------------------
   좁은 화면(휴대폰)
   --------------------------------------------------------------------- */
@media (max-width: 720px) {
    body { font-size: 15px; }
    .site-header-inner { gap: 6px 12px; }
    .site-nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
    .site-nav a { white-space: nowrap; }
    .site-user { margin-left: auto; }
    .site-user-name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .page-title { font-size: 19px; }
    .panel { padding: 14px 12px; }

    /* 목록 표 → 카드 */
    .list-table, .list-table tbody, .list-table tr, .list-table td { display: block; width: 100%; }
    .list-table { border: 0; background: transparent; }
    .list-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .list-table tr {
        background: var(--c-surface);
        border: 1px solid var(--c-line);
        border-radius: var(--radius);
        margin-bottom: 10px;
        padding: 6px 4px;
    }
    .list-table td { border: 0; padding: 4px 8px; }
    .list-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 12px;
        color: var(--c-muted);
    }
    .list-table .col-num { width: auto; text-align: left; }
    .list-table .col-actions { white-space: normal; }
    .input-narrow { max-width: none; }

    .doc-frame { padding: 16px 12px; }
    .doc-title { font-size: 20px; }
    .plan-table .col-dept { width: 5.2em; }
    .plan-table th, .plan-table td { padding: 5px 6px; }
    .plan-table .dept-name { font-size: 13px; }
    .rte-area { min-height: 220px; }
    .login-box { padding: 22px 16px; }
}
