/* Template library panel (#templates) — Scheme C */
.app.view-templates {
  grid-template-columns: 220px 1fr;
  grid-template-areas:
    "sidebar top"
    "sidebar templates";
}
.app.view-templates .inbox-panel,
.app.view-templates .chat-panel,
.app.view-templates .profile-panel,
.app.view-templates .iam-panel,
.app.view-templates .archive-panel {
  display: none !important;
}
.templates-panel {
  grid-area: templates;
  display: none;
  min-height: 0;
  background: #f0f2f5;
  overflow: hidden;
  position: relative;
}
.app.view-templates .templates-panel {
  display: flex;
  flex-direction: column;
}

.tpl-page {
  flex: 1;
  min-height: 0;
  padding: 20px 24px;
  overflow: auto;
}
.tpl-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  padding: 20px 22px 16px;
  min-height: calc(100% - 8px);
}
.tpl-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.tpl-card-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}
.tpl-card-head .muted {
  margin: 0;
  font-size: 13px;
}
.tpl-tabs {
  display: flex;
  gap: 18px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  margin-bottom: 12px;
}
.tpl-tab {
  appearance: none;
  background: none;
  border: none;
  padding: 8px 2px 10px;
  font-size: 14px;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tpl-tab.active {
  color: #0f172a;
  font-weight: 700;
  border-bottom-color: #0d9488;
}
.tpl-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.tpl-toolbar input[type="search"],
.tpl-toolbar select {
  height: 34px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
  background: #fff;
}
.tpl-toolbar input[type="search"] {
  min-width: 200px;
  flex: 1;
}
.tpl-table-wrap {
  overflow: auto;
  border: 1px solid #eef2f7;
  border-radius: 8px;
}
.tpl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tpl-table th,
.tpl-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.tpl-table th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  font-size: 12px;
}
.tpl-table tbody tr {
  cursor: pointer;
}
.tpl-table tbody tr:hover {
  background: #f8fffd;
}
.tpl-table .empty {
  text-align: center;
  color: #94a3b8;
  padding: 40px 14px;
  cursor: default;
}
.tpl-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.tpl-status.active {
  background: #ccfbf1;
  color: #0f766e;
}
.tpl-status.disabled {
  background: #f1f5f9;
  color: #64748b;
}
.tpl-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
  color: #64748b;
}

/* Right drawer */
.tpl-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  z-index: 20;
}
.tpl-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(720px, 78%);
  background: #fff;
  z-index: 21;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.12);
  border-radius: 12px 0 0 12px;
}
.tpl-drawer[hidden],
.tpl-drawer-backdrop[hidden] {
  display: none !important;
}
.tpl-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 12px;
  border-bottom: 1px solid #eef2f7;
}
.tpl-drawer-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}
.tpl-drawer-head .muted {
  margin: 0;
  font-size: 13px;
}
.tpl-drawer-close {
  appearance: none;
  border: none;
  background: #f1f5f9;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #475569;
}
.tpl-steps {
  display: flex;
  gap: 8px;
  padding: 12px 22px;
  border-bottom: 1px solid #eef2f7;
}
.tpl-step {
  appearance: none;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #64748b;
  cursor: pointer;
}
.tpl-step.active {
  border-color: #0d9488;
  color: #0f766e;
  font-weight: 700;
  background: #f0fdfa;
}
.tpl-drawer-body {
  flex: 1;
  overflow: auto;
  padding: 18px 22px;
}
.tpl-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.tpl-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-field.full {
  grid-column: 1 / -1;
}
.tpl-field label {
  font-size: 12px;
  color: #64748b;
}
.tpl-field input,
.tpl-field select,
.tpl-field textarea {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
}
.tpl-field textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.5;
}
.tpl-preview {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  min-height: 180px;
  font-size: 14px;
  line-height: 1.6;
  color: #0f172a;
}
.tpl-drawer-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid #eef2f7;
  background: #fff;
}

/* Composer template picker */
.tpl-picker {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tpl-picker[hidden] {
  display: none !important;
}
.tpl-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}
.tpl-picker-panel {
  position: relative;
  width: min(520px, 92vw);
  max-height: min(70vh, 640px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tpl-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #eef2f7;
}
.tpl-picker-head h3 {
  margin: 0;
  font-size: 16px;
}
.tpl-picker-tools {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid #eef2f7;
}
.tpl-picker-tools input,
.tpl-picker-tools select {
  height: 32px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 13px;
}
.tpl-picker-tools input {
  flex: 1;
}
.tpl-picker-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow: auto;
  flex: 1;
}
.tpl-picker-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.tpl-picker-item:hover {
  background: #f0fdfa;
}
.tpl-picker-item strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}
.tpl-picker-item span {
  display: block;
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tpl-picker-empty {
  padding: 28px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

/* Recent templates in profile */
.tpl-recent {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-recent button {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
  color: #0f172a;
}
.tpl-recent button:hover {
  border-color: #0d9488;
  background: #f0fdfa;
}

.nav-sub-item.is-placeholder {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}
