/* ─── 真道學房 Frontend CSS ─────────────────────────────────────── */
:root {
  --zd-primary: #c0392b;
  --zd-bg: #fafafa;
  --zd-card-bg: #ffffff;
  --zd-border: #e0e0e0;
  --zd-text: #2c3e50;
  --zd-muted: #7f8c8d;
  --zd-green: #27ae60;
  --zd-radius: 10px;
  --zd-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.zd-wrap { font-family: 'Noto Sans TC', sans-serif; color: var(--zd-text); font-size: 15px; }
.zd-wrap *, .zd-wrap *::before, .zd-wrap *::after { box-sizing: border-box; }

/* ─── Home Layout ─── */
.zd-home-layout { display: grid; grid-template-columns: 1fr 1fr 320px; gap: 24px; padding: 24px; min-height: 80vh; }
@media(max-width:900px){ .zd-home-layout{ grid-template-columns:1fr; } }

.zd-home-courses { grid-column: 1/3; }
.zd-home-sidebar { grid-column: 3/4; }

.zd-section-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; color: var(--zd-primary); }
.zd-subtitle { font-size: 15px; font-weight: 400; color: var(--zd-muted); margin-left: 8px; }

/* ─── Course Grid ─── */
.zd-course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 16px; }

.zd-course-card {
  background: var(--zd-card-bg);
  border: 2px solid var(--zd-border);
  border-radius: var(--zd-radius);
  padding: 16px;
  cursor: default;
  transition: all 0.2s;
  position: relative;
}
.zd-course-card.zd-selectable { cursor: pointer; }
.zd-course-card.zd-selectable:hover { border-color: var(--zd-primary); box-shadow: var(--zd-shadow); }
.zd-course-card.zd-selected { border-color: var(--zd-primary); background: #fff5f5; }
.zd-course-card.zd-enrolled { border-color: var(--zd-green); }

.zd-card-code { font-size: 12px; font-weight: 700; color: var(--zd-primary); text-transform: uppercase; margin-bottom: 4px; }
.zd-card-code-inline { font-size: 13px; font-weight: 700; color: var(--zd-primary); margin-right: 4px; }
.zd-card-title { font-size: 17px; font-weight: 700; margin: 4px 0 8px; }
.zd-card-desc { font-size: 13px; color: var(--zd-muted); margin-bottom: 8px; line-height: 1.5; }
.zd-card-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--zd-muted); margin-bottom: 10px; }
.zd-card-meta span { background: #f0f0f0; border-radius: 4px; padding: 2px 6px; }

.zd-card-select-btn { background: var(--zd-primary); color: #fff; border: none; border-radius: 6px; padding: 6px 16px; cursor: pointer; font-size: 14px; display: inline-block; margin-top: 4px; text-align: center; }
.zd-card-select-btn:hover { background: #a93226; }
.zd-card-enrolled-badge { background: var(--zd-green); color: #fff; border-radius: 6px; padding: 4px 12px; font-size: 13px; font-weight: 600; display: inline-block; margin-top: 4px; }

/* ─── Select Bar ─── */
.zd-select-bar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 10px 0; background: #fff8f8; border-radius: 8px; padding: 10px 16px; margin-bottom: 12px; border: 1px solid #ffd6d6; }
.zd-select-hint { font-size: 13px; color: var(--zd-muted); }

/* ─── Login Box ─── */
.zd-login-box, .zd-user-box { background: #fff; border: 1px solid var(--zd-border); border-radius: var(--zd-radius); padding: 24px; box-shadow: var(--zd-shadow); }
.zd-login-box h3 { margin: 0 0 16px; color: var(--zd-primary); font-size: 20px; }
.zd-user-box { text-align: center; }
.zd-user-box h3.zd-user-name { margin: 0 0 4px; color: var(--zd-primary); font-size: 18px; line-height: 1.4; }
.zd-user-name .zd-user-en { display: block; font-size: 14px; color: #555; font-weight: 400; }
.zd-user-box .zd-btn { text-align: center; justify-content: center; }
.zd-user-box-gap { height: 10px; }
.zd-field { margin-bottom: 14px; }
.zd-field label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.zd-field input[type=text], .zd-field input[type=email], .zd-field input[type=password],
.zd-field input[type=tel], .zd-field input[type=date], .zd-field select, .zd-field textarea {
  width: 100%; border: 1px solid var(--zd-border); border-radius: 6px; padding: 8px 12px; font-size: 14px;
}
.zd-field input:focus, .zd-field select:focus { outline: none; border-color: var(--zd-primary); }

.zd-btn { display: inline-block; padding: 8px 18px; border-radius: 6px; border: none; cursor: pointer; font-size: 14px; font-weight: 600; text-decoration: none; transition: all 0.2s; }
.zd-btn-primary { background: var(--zd-primary); color: #fff; }
.zd-btn-primary:hover { background: #a93226; color: #fff; }
.zd-btn-ghost { background: #fff; color: var(--zd-primary); border: 1px solid var(--zd-primary); }
.zd-btn-ghost:hover { background: #fff5f5; }
.zd-btn-danger { background: #e74c3c; color: #fff; }
.zd-btn-sm { padding: 4px 10px; font-size: 12px; }
.zd-btn-xs { padding: 2px 6px; font-size: 11px; }
.zd-btn-disabled { background: #ccc; color: #666; cursor: not-allowed; border: none; border-radius: 6px; padding: 6px 16px; font-size: 14px; }
.zd-full-width { width: 100%; }
.zd-link-btn { background: none; border: none; color: var(--zd-primary); cursor: pointer; font-size: 14px; text-decoration: underline; padding: 0; }
.zd-register-link { margin-top: 16px; text-align: center; font-size: 14px; }

/* ─── Alerts ─── */
.zd-alert { border-radius: 6px; padding: 10px 14px; font-size: 13px; margin: 8px 0; }
.zd-alert-error { background: #fdecea; color: #c0392b; border: 1px solid #f5c6cb; }
.zd-alert-info  { background: #e8f4fd; color: #1a5276; border: 1px solid #bee5eb; }
.zd-alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.zd-req { color: #e74c3c; }

/* ─── Radio / Checkbox groups ─── */
.zd-radio-group, .zd-checkbox-group { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.zd-radio-group label, .zd-checkbox-group label { font-weight: 400; display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* ─── Modals ─── */
.zd-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.zd-modal-inner { background: #fff; border-radius: var(--zd-radius); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.zd-modal-lg { max-width: 740px; }
.zd-modal-cert { max-width: 650px; }
.zd-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--zd-border); position: sticky; top: 0; background: #fff; z-index: 1; }
.zd-modal-header h3 { margin: 0; font-size: 18px; }
.zd-modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--zd-muted); }
.zd-modal-body { padding: 20px; }
.zd-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─── Dashboard ─── */
.zd-dash-header { display: flex; align-items: center; justify-content: space-between; background: var(--zd-primary); color: #fff; padding: 12px 24px; }
.zd-dash-logo { font-size: 22px; font-weight: 800; letter-spacing: 2px; }
.zd-dash-user { display: flex; align-items: center; gap: 12px; }
.zd-dash-user .zd-link-btn { color: rgba(255,255,255,0.85); }
.zd-dash-user .zd-logout-btn { color: rgba(255,255,255,0.7); }

/* ─── Tabs ─── */
.zd-tabs { display: flex; border-bottom: 2px solid var(--zd-border); background: #fff; overflow-x: auto; margin-top: 12px; }
.zd-tab { background: none; border: none; border-bottom: 3px solid transparent; padding: 12px 20px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--zd-muted); white-space: nowrap; margin-bottom: -2px; transition: all 0.15s; }
.zd-tab.active, .zd-tab:hover { color: var(--zd-primary); border-bottom-color: var(--zd-primary); }
.zd-tab-content { display: none; }
.zd-tab-content.active { display: block; }
.zd-tab-inner { padding: 20px 24px; }

/* ─── Offering selector ─── */
.zd-offering-selector { padding: 10px 24px; background: #f8f8f8; border-bottom: 1px solid var(--zd-border); }
.zd-offering-selector select { margin-left: 8px; border: 1px solid var(--zd-border); border-radius: 4px; padding: 4px 8px; }

/* ─── Enrolled layout ─── */
.zd-enrolled-layout { display: grid; grid-template-columns: 1fr 280px; gap: 24px; }
@media(max-width:700px){ .zd-enrolled-layout{ grid-template-columns:1fr; } }
.zd-enrolled-item { background: #fff; border: 1px solid var(--zd-border); border-radius: 8px; padding: 14px; margin-bottom: 10px; }
.zd-student-info-sidebar { background: #fff; border: 1px solid var(--zd-border); border-radius: 8px; padding: 16px; height: fit-content; text-align: center; }
.zd-avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid var(--zd-border); margin: 0 auto 12px; display: block; }
.zd-avatar-sm { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid var(--zd-border); display: block; margin: 0 auto 10px; }
.zd-login-notice { background: #fff8e1; border: 1px solid #ffe082; border-radius: 6px; padding: 10px 16px; margin-bottom: 16px; font-size: 14px; color: #7a5c00; font-weight: 500; }
.zd-user-role { color: var(--zd-muted); font-size: 13px; margin: 0 0 16px; }.zd-avatar-xs { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.4); }
.zd-info-table { width: 100%; font-size: 13px; text-align: left; }
.zd-info-table th { color: var(--zd-muted); font-weight: 600; padding: 3px 4px; white-space: nowrap; }
.zd-info-table td { padding: 3px 4px; }
/* .zd-user-role moved above */

/* ─── Profile form ─── */
.zd-profile-layout { display: grid; grid-template-columns: 140px 1fr; gap: 24px; }
@media(max-width:600px){ .zd-profile-layout{ grid-template-columns:1fr; } }
.zd-profile-form .zd-field { margin-bottom: 12px; }

/* ─── Tables ─── */
.zd-table-wrap { overflow-x: auto; }
.zd-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.zd-table th { background: #f5f5f5; padding: 8px 10px; text-align: left; font-weight: 700; border-bottom: 2px solid var(--zd-border); white-space: nowrap; }
.zd-table td { padding: 8px 10px; border-bottom: 1px solid var(--zd-border); vertical-align: middle; }
.zd-table tr:last-child td { border-bottom: none; }
.zd-table tr:hover td { background: #fafafa; }

/* ─── Badges ─── */
.zd-badge { display: inline-block; background: #eee; color: #555; border-radius: 4px; padding: 1px 8px; font-size: 11px; font-weight: 700; margin-left: 4px; }
.zd-badge-green { background: #d4edda; color: var(--zd-green); }
.zd-badge-grey  { background: #f0f0f0; color: #888; }
.zd-tag { display: inline-block; background: #e8f4fd; color: #1a5276; border-radius: 4px; padding: 1px 6px; font-size: 11px; margin-right: 4px; }
.zd-tag-grey { background: #f0f0f0; color: #888; }

/* ─── Lessons ─── */
.zd-section-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.zd-lesson-item { background: #fff; border: 1px solid var(--zd-border); border-radius: 8px; padding: 14px; margin-bottom: 10px; }
.zd-lesson-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.zd-lesson-preview { font-size: 13px; color: var(--zd-muted); max-height: 80px; overflow: hidden; }

/* ─── Assignments ─── */
.zd-assignment-item { background: #fff; border: 1px solid var(--zd-border); border-radius: 8px; padding: 14px; margin-bottom: 10px; }
.zd-assignment-header { display: flex; justify-content: space-between; align-items: flex-start; }
.zd-submission-types { margin-top: 6px; }

/* ─── Grade table ─── */
.zd-grade-table .zd-att-col { min-width: 60px; text-align: center; }
.zd-grade-cell { position: relative; white-space: nowrap; }
.zd-grade-input { width: 60px; border: 1px solid var(--zd-border); border-radius: 4px; padding: 2px 4px; font-size: 13px; }
.zd-dot-red { display: inline-block; width: 8px; height: 8px; background: var(--zd-primary); border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* ─── Attendance ─── */
.zd-attendance-table .zd-att-col { text-align: center; font-size: 11px; }
.zd-att-check { width: 16px; height: 16px; cursor: pointer; }

/* ─── History table ─── */
.zd-history-table td, .zd-history-table th { white-space: nowrap; }

/* ─── No data ─── */
.zd-no-data { color: var(--zd-muted); font-style: italic; padding: 20px 0; }

/* ─── Hint ─── */
.zd-hint { font-size: 12px; color: var(--zd-muted); margin-top: 4px; }

/* ─── Print ─── */
@media print {
  .zd-modal-header, .zd-tabs, .zd-dash-header, .zd-offering-selector { display: none !important; }
}

/* ─── Enrollment Deadline ─── */
.zd-deadline-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.zd-deadline-msg { font-size: 12px; color: var(--zd-primary); font-weight: 600; }
.zd-btn-disabled { background: #ccc !important; color: #fff !important; border-color: #ccc !important; cursor: not-allowed !important; }

/* ─── Student Lessons & Assignments tab ─── */
.zd-student-course-section { background: #fff; border: 1px solid var(--zd-border); border-radius: var(--zd-radius); margin-bottom: 24px; overflow: hidden; }
.zd-student-course-heading { background: var(--zd-primary); color: #fff; padding: 12px 20px; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.zd-student-course-heading .zd-card-code-inline { color: rgba(255,255,255,0.8); font-size: 13px; }
.zd-meta-small { font-size: 12px; font-weight: 400; opacity: 0.85; margin-left: auto; }
.zd-student-lessons, .zd-student-assignments { padding: 16px 20px; }
.zd-student-lessons h4, .zd-student-assignments h4 { margin: 0 0 12px; color: var(--zd-primary); font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--zd-border); padding-bottom: 8px; }
.zd-student-lesson-item { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px dashed var(--zd-border); }
.zd-student-lesson-item:last-child { border-bottom: none; }
.zd-student-lesson-title { font-weight: 700; font-size: 15px; color: #333; margin-bottom: 8px; }
.zd-student-lesson-body { font-size: 14px; line-height: 1.7; color: #444; }
.zd-student-lesson-body p { margin: 0 0 8px; }
.zd-student-asn-item { background: #f9f9f9; border-radius: 6px; padding: 14px 16px; margin-bottom: 12px; }
.zd-student-asn-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.zd-student-asn-desc { font-size: 14px; color: #444; margin: 6px 0; line-height: 1.6; }
.zd-student-asn-submit { font-size: 13px; color: var(--zd-muted); margin-top: 8px; }
