/* 通告頁：版面、分頁、範本卡、歷史側欄 */

.notices-page__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.notices-page__head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
}

#notices .quick-notice-section {
  padding: 24px;
  border-radius: var(--sw-radius-lg);
  margin-bottom: 12px;
}

#notices .notices-page__notice-month-toolbar {
  margin-bottom: 14px;
}

.notices-page__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.notices-toolbar-btn--history,
.notices-toolbar-btn--templates {
  background: var(--sw-surface);
  color: var(--sw-primary);
  border: 1px solid var(--sw-border-strong);
  box-shadow: var(--sw-shadow-sm);
}

.notices-toolbar-btn--history:hover,
.notices-toolbar-btn--templates:hover {
  background: var(--sw-surface-muted);
  color: var(--sw-primary-dark);
}

.notices-page__layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
  margin-top: 8px;
}

@media (min-width: 1100px) {
  .notices-page__layout {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  }
}

.notices-page__main {
  min-width: 0;
}

.notices-page__aside {
  min-width: 0;
}

@media (min-width: 1100px) {
  .notices-page__aside {
    position: sticky;
    top: 16px;
  }
}

.notices-aside-title {
  margin: 0 0 12px 0;
  font-size: 1.1em;
  color: #1e293b;
}

.notices-history-panel {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
  outline: none;
}

.notices-section-title {
  margin: 0 0 20px 0;
  color: #fff;
  font-size: 1.3em;
}

.notices-inline-heading {
  margin: 0 0 10px 0;
  color: var(--sw-primary);
  font-size: 1em;
}

/* 分頁列 */
.notice-tab-nav {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}

.notice-tab-btn {
  flex: 1;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
}

.notice-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.notice-tab-btn.is-active {
  background: rgba(255, 255, 255, 0.95);
  color: var(--sw-primary);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* 分頁內容：以 .is-active 控制顯示，不依賴 inline display */
.notice-tab-content:not(.is-active) {
  display: none !important;
}

.notice-tab-content.is-active {
  display: block;
}

/* 範本網格 */
.notice-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

#notices .notice-template-card.template-item {
  position: relative;
  padding: 20px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: #fff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

#notices .notice-template-card.template-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.15);
  border-color: rgba(2, 132, 199, 0.35);
}

#notices .notice-template-card.template-item.is-picked {
  border-color: var(--sw-primary);
  background: #e0f2fe;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.2);
}

#notices .notice-template-card .btn[data-notice-action="edit-template"] {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: #ff9800;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(255, 152, 0, 0.35);
  z-index: 1;
}

#notices .notice-template-edit {
  width: 32px;
  height: 32px;
}

#notices .notice-template-card .btn[data-notice-action="edit-template"]:hover {
  filter: brightness(1.05);
}

.notice-action-row {
  display: flex;
  gap: 15px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.notice-action-row--wide {
  margin-top: 25px;
}

.notice-action-btn {
  flex: 1 1 180px;
  border: none;
  border-radius: 10px;
  padding: 15px;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

.notice-action-btn:hover,
.notice-mini-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.notice-action-btn--preview {
  background: #2196f3;
}

.notice-action-btn--send {
  background: #4caf50;
}

.notice-action-btn--primary {
  flex: 2 1 260px;
}

.notice-recipient-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.notice-mini-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: #fff;
}

.notice-mini-btn--ok {
  background: #4caf50;
}

.notice-mini-btn--danger {
  background: #f44336;
}

.recipient-item {
  display: flex;
  align-items: center;
  padding: 5px;
  margin-bottom: 5px;
  border-bottom: 1px solid #eee;
}

.recipient-item label {
  margin-left: 5px;
  font-size: 13px;
}

.notice-history-item {
  padding: 8px;
  border-bottom: 1px solid #eee;
  font-size: 12px;
}

.notice-history-item .date {
  color: #666;
  font-size: 10px;
  margin-top: 3px;
}

/* 編輯範本：可點擊插入的變數 */
.notice-var-chips-wrap {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 8px;
  margin: 15px 0;
}

.notice-var-chips-title {
  margin: 0 0 10px 0;
  color: #4f46e5;
  font-size: 14px;
  font-weight: 700;
}

.notice-var-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 2px;
}

.notice-var-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  color: #334155;
  line-height: 1.25;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.notice-var-chip:hover {
  background: #eef2ff;
  border-color: #6366f1;
}

.notice-var-chip__tok {
  font-weight: 700;
  color: #1e293b;
}

.notice-var-chip__lab {
  font-size: 11px;
  color: #64748b;
}

/* 範本選擇、編輯表單、自訂 Tab（自 index 內聯移出） */
.template-selection {
  margin-bottom: 25px;
}

.notice-tpl-pick-label {
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
  display: block;
}

.notice-template-card__icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.notice-template-card__title {
  margin: 0 0 10px 0;
  color: #333;
  font-weight: 600;
  font-size: 16px;
}

.notice-template-card__desc {
  margin: 0;
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

.notice-template-editor,
.notice-custom-panel {
  background: #f8f9fa;
  padding: 25px;
  border-radius: 12px;
}

.notice-template-editor {
  margin-top: 25px;
}

.notice-fg {
  margin-bottom: 20px;
}

.notice-form-label {
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  display: block;
}

.notice-form-label__editable {
  color: #4caf50;
}

.notice-input,
.notice-select,
.notice-textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  box-sizing: border-box;
}

.notice-textarea {
  min-height: 150px;
  resize: vertical;
}

.notice-input--filter {
  padding: 10px;
  margin-bottom: 10px;
}

.notice-filter-stack {
  margin-bottom: 15px;
}

.notice-muted {
  color: #666;
}

.notice-recipient-box {
  overflow-y: auto;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 15px;
  background: #fff;
  box-sizing: border-box;
}

.notice-recipient-box--sm {
  max-height: 200px;
}

.notice-recipient-box--lg {
  max-height: 250px;
}

/* 通告預覽 Modal（#noticePreviewBody）— 預覽與 WhatsApp 佇列共用 */
#noticePreviewBody .notice-preview-panel {
  padding: 0;
}

.notice-preview-sample-note {
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
}

.notice-preview-content {
  white-space: pre-wrap;
  font-family: inherit;
  margin-bottom: 16px;
  line-height: 1.5;
  color: #0f172a;
}

.notice-preview-intro {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: #334155;
  line-height: 1.45;
}

.notice-preview-recipients {
  margin-top: 4px;
}

.notice-preview-recipients__title {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

#noticePreviewBody .notice-recipient-list {
  max-height: min(52vh, 320px);
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.notice-recipient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 14px;
}

.notice-recipient-row:last-child {
  border-bottom: none;
}

.notice-recipient-row--readonly {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.notice-recipient-row__name {
  font-weight: 500;
  color: #0f172a;
}

.notice-recipient-row__phone {
  color: #64748b;
  font-size: 13px;
  margin-left: 4px;
}

.notice-recipient-row__send {
  flex-shrink: 0;
}
