/** Templates Page Styles - Redesigned for Theme V2 */

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  background: var(--ot-bg-base);
}

body {
  font-family: var(--ot-font-sans);
  background: var(--ot-bg-base);
  color: var(--ot-text-primary);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--ot-font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Content Layout */
.content {
  padding: 22px 24px 36px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 16px;
}

.page-eyebrow {
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ot-text-muted);
  font-weight: 700;
  font-family: var(--ot-font-mono);
}

.page-title {
  font-size: 22px;
  letter-spacing: -.015em;
  color: var(--ot-text-primary);
  font-weight: 700;
  margin-top: 3px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--ot-border);
}

.tab {
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ot-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  transition: var(--ot-transition);
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--ot-text-primary);
}

.tab.active {
  color: var(--ot-text-primary);
  border-bottom-color: var(--ot-accent);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Templates Grid & Channels List */
.templates-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

.channels-list {
  background: var(--ot-bg-surface);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius);
  padding: 8px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--ot-shadow-1);
}

.chan-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--ot-radius-sm);
  cursor: pointer;
  transition: var(--ot-transition);
}

.chan-row:hover {
  background: var(--ot-bg-hover);
}

.chan-row.active {
  background: var(--ot-bg-elevated);
  box-shadow: inset 0 0 0 1px var(--ot-accent) !important;
}

.chan-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ot-text-muted);
  flex-shrink: 0;
}

.chan-dot.has-template {
  background: var(--ot-accent);
  box-shadow: 0 0 4px var(--ot-accent);
}

.chan-info {
  flex: 1;
  min-width: 0;
}

.chan-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ot-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chan-pc {
  font-size: 10px;
  color: var(--ot-text-muted);
  font-family: var(--ot-font-mono);
  margin-top: 1px;
}

.chan-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.chan-badge.tmpl {
  background: var(--ot-accent-soft);
  color: var(--ot-accent);
}

/* Editor Card */
.editor-card {
  background: var(--ot-bg-surface);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius);
  padding: var(--ot-space-lg);
  box-shadow: var(--ot-shadow-2);
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ot-border);
}

.editor-head .name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ot-text-primary);
}

.editor-head .sub {
  font-size: 11px;
  color: var(--ot-text-secondary);
  margin-top: 2px;
}

.editor-head .actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

/* Form Styles */
.form-row {
  margin-bottom: 14px;
}

.form-row label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ot-text-secondary);
  margin-bottom: 5px;
}

.form-row .help {
  font-size: 10.5px;
  color: var(--ot-text-muted);
  margin-top: 3px;
}

.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Preview Card */
.preview-card {
  background: var(--ot-bg-surface);
  border: 1px solid var(--ot-accent-soft);
  border-radius: var(--ot-radius-sm);
  padding: 12px 14px;
  margin-top: 14px;
}

.preview-label {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ot-accent);
  font-weight: 700;
  margin-bottom: 8px;
}

.preview-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ot-text-primary);
  margin-bottom: 6px;
}

.preview-desc {
  font-size: 11.5px;
  color: var(--ot-text-secondary);
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
}

/* Empty Editor State */
.empty-editor {
  text-align: center;
  padding: 80px 30px;
  color: var(--ot-text-muted);
}

.empty-editor svg, .empty-editor [data-oti] {
  opacity: .4;
  margin-bottom: 14px;
  color: var(--ot-text-muted);
}

.empty-editor h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ot-text-secondary);
  margin-bottom: 6px;
}

.empty-editor p {
  font-size: 12px;
  max-width: 400px;
  margin: 0 auto;
}

/* Notifications Card */
.notify-card {
  background: var(--ot-bg-surface);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius);
  padding: var(--ot-space-lg);
  box-shadow: var(--ot-shadow-2);
}

/* Toast System styling using design system standards */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--ot-bg-surface);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius);
  padding: 12px 16px;
  font-size: 12.5px;
  min-width: 280px;
  max-width: 380px;
  box-shadow: var(--ot-shadow-3);
  animation: slidein .25s ease-out;
}

.toast.ok {
  border-left: 3px solid var(--ot-status-success);
}

.toast.err {
  border-left: 3px solid var(--ot-status-danger);
}

@keyframes slidein {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 16px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ot-text-primary);
  letter-spacing: -.01em;
}

.section-sub {
  font-size: 11px;
  color: var(--ot-text-muted);
  margin-top: 2px;
}

/* Premium V2 style for danger button */
.ot-btn-danger {
  background: rgba(239, 68, 68, 0.1) !important;
  color: var(--ot-status-danger) !important;
  border-color: rgba(239, 68, 68, 0.25) !important;
}

.ot-btn-danger:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: var(--ot-status-danger) !important;
}

/* Responsiveness overrides */
@media (max-width: 1000px) {
  .templates-grid {
    grid-template-columns: 1fr;
  }
  .channels-list {
    max-height: 360px;
  }
}

@media (max-width: 760px) {
  .content {
    padding: 16px;
  }
  .form-row.two-col {
    grid-template-columns: 1fr;
  }
}
