/* ---- เผยแพร่เทมเพลตของ User (My Templates) ---- */

.ip-user-publish-hint {
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), rgba(99, 102, 241, 0.06));
}

.ip-user-published-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 5px 10px;
  border-radius: 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  color: #86efac;
  background: rgba(34, 197, 94, 0.18);
  border: none;
  border-top: 1px solid rgba(34, 197, 94, 0.28);
  border-bottom: 1px solid rgba(34, 197, 94, 0.28);
}

.my-templates-panel .my-template-card .ip-user-published-badge {
  border-radius: 0 0 10px 10px;
}

.my-template-card-actions .ip-user-publish-btn,
.my-template-card-actions .ip-user-unpublish-btn {
  font-size: 10px;
  padding: 5px 4px;
  white-space: nowrap;
  line-height: 1.15;
}

.my-template-card-actions .ip-user-unpublish-btn {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.45);
}

.my-template-card-actions .ip-user-publish-btn {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.45);
}

/* ---- Sidebar icon (หลัง Assets) ---- */

.editor-nav-btn.ip-shared-sidebar-btn svg {
  width: 22px;
  height: 22px;
}

.editor-nav-btn.ip-shared-sidebar-btn.active {
  background: linear-gradient(135deg, #0ea5e9, #6366f1) !important;
  color: #fff !important;
}

.editor-nav-btn.ip-sa-admin-sidebar-btn svg {
  width: 22px;
  height: 22px;
}

/* ---- Inline panel ใน Assets sidebar ---- */

/* โหมดคลังภาพส่วนกลาง — ซ่อน UI ของ Assets ทั้งหมด */
.assets-panel.ip-assets-shared-mode .assets-panel-header,
.assets-panel.ip-assets-shared-mode .assets-search-row,
.assets-panel.ip-assets-shared-mode .assets-group-tabs,
.assets-panel.ip-assets-shared-mode .assets-upload-toolbar,
.assets-panel.ip-assets-shared-mode .assets-dropzone,
.assets-panel.ip-assets-shared-mode .assets-grid:not(.ip-shared-inline-grid),
.assets-panel.ip-assets-shared-mode .assets-admin-group,
.assets-panel.ip-assets-shared-mode > .backend-note {
  display: none !important;
}

.assets-panel.ip-assets-shared-mode {
  padding-top: 4px;
}

.ip-shared-library-inline {
  margin-top: 0;
}

.ip-shared-inline-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #e2e8f0;
}

.ip-shared-inline-header {
  margin-bottom: 10px;
}

.ip-shared-inline-search {
  width: 100%;
  margin-top: 8px;
  box-sizing: border-box;
}

.ip-shared-inline-cats-wrap {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 4px;
}

.ip-shared-inline-cat-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 12px;
}

.ip-shared-inline-cat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
}

.ip-shared-inline-cat-select {
  width: 100%;
  font-size: 0.88rem;
}

.ip-shared-cat-section {
  margin-bottom: 10px;
}

.ip-shared-cat-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #94a3b8;
  margin: 0 0 6px;
  letter-spacing: 0.02em;
}

.ip-shared-inline-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.ip-shared-admin-cat-list-wrap {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
}

.ip-shared-admin-block-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: #312e81;
}

.ip-shared-admin-cat-section {
  margin-bottom: 14px;
}

.ip-shared-admin-cat-section .ip-shared-cat-section-title {
  color: #475569;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.ip-shared-admin-cat-actions {
  display: inline-flex;
  flex-shrink: 0;
  gap: 6px;
  align-items: center;
}

.ip-shared-admin-cat-actions .backend-btn {
  white-space: nowrap;
}

.ip-shared-admin-cat-meta {
  min-width: 0;
}

.ip-shared-inline-cat {
  font-size: 0.82rem;
}

.ip-shared-inline-grid {
  margin-top: 4px;
}

.ip-shared-inline-card {
  position: relative;
}

.ip-shared-inline-grid .assets-card-thumb,
.assets-panel.ip-assets-shared-mode .assets-card-thumb,
.assets-panel .ip-shared-inline-grid .assets-card-thumb {
  overflow: visible !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 136px;
  background: #fff !important;
}

.ip-shared-inline-grid .assets-card-thumb img,
.assets-panel.ip-assets-shared-mode .assets-card-thumb img,
.assets-panel .ip-shared-inline-grid .assets-card-thumb img {
  width: 100% !important;
  height: auto !important;
  max-height: 152px !important;
  min-height: 0 !important;
  aspect-ratio: unset !important;
  -o-object-fit: contain !important;
  object-fit: contain !important;
  object-position: center center !important;
  background: #fff;
}

.ip-shared-assets-card img {
  object-position: center top;
}

.ip-shared-inline-status {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: #64748b;
}

.ip-shared-inline-status.success {
  color: #059669;
}

.ip-shared-inline-status.error {
  color: #dc2626;
}

.ip-shared-inline-admin-link {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #e2e8f0;
}

.ip-shared-inline-empty {
  padding: 12px 0;
}

/* ---- Admin modal ---- */

.ip-shared-assets-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.ip-shared-assets-modal {
  width: min(960px, 100%);
  max-height: min(88vh, 900px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ip-shared-assets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.ip-shared-assets-header strong {
  font-size: 1.05rem;
}

.ip-sa-admin-tabs {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 10px 16px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.ip-sa-admin-tab {
  flex: 0 0 auto;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ip-sa-admin-tab:hover {
  border-color: #c7d2fe;
  background: #eef2ff;
}

.ip-sa-admin-tab.is-active {
  border-color: #4f46e5;
  background: #4f46e5;
  color: #fff;
}

.ip-shared-assets-body {
  padding: 12px 20px 20px;
  overflow: auto;
  flex: 1;
}

.ip-sa-admin-panel {
  display: grid;
  gap: 0;
  min-height: 120px;
}

.ip-sa-admin-panel > .ip-shared-assets-admin-form:last-child,
.ip-sa-admin-panel > .ip-shared-admin-cat-list-wrap:last-child {
  margin-bottom: 0;
}

.ip-sa-gen-preview {
  margin-top: 4px;
  padding: 14px;
  border: 1px solid #ddd6fe;
  border-radius: 12px;
  background: #faf5ff;
}

.ip-sa-gen-preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.ip-sa-gen-preview-head strong {
  font-size: 0.95rem;
  color: #5b21b6;
}

.ip-sa-gen-preview-meta {
  font-size: 0.85rem;
  color: #6b7280;
}

.ip-sa-gen-preview .backend-note {
  margin: 0 0 10px;
}

.ip-sa-gen-preview-grid {
  margin-top: 4px;
}

.ip-sa-gen-preview .ip-shared-assets-empty {
  padding: 24px 12px;
  background: #fff;
  border-radius: 10px;
  border: 1px dashed #d8b4fe;
}

.ip-shared-assets-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.ip-shared-assets-cat {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.88rem;
}

.ip-shared-assets-cat.active {
  border-color: #6366f1;
  background: #eef2ff;
  color: #4338ca;
}

.ip-shared-assets-more-wrap {
  display: flex;
  justify-content: center;
  margin: 14px 0 4px;
}

.ip-shared-assets-more-btn {
  min-width: 180px;
}

.ip-shared-inline-grid + .ip-shared-assets-more-wrap {
  margin-top: 12px;
}

.ip-shared-assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.ip-shared-assets-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #f8fafc;
}

.ip-shared-assets-card img {
  width: 100%;
  height: auto;
  min-height: 140px;
  max-height: 200px;
  aspect-ratio: unset;
  object-fit: contain;
  object-position: center center;
  background: #fff;
  display: block;
}

.ip-shared-assets-card-name {
  display: block;
  padding: 8px;
  font-size: 0.78rem;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ip-shared-assets-empty {
  padding: 32px 16px;
  text-align: center;
  color: #64748b;
}

.ip-shared-assets-admin-form {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.ip-shared-assets-admin-form label {
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
}

.ip-shared-assets-admin-form input,
.ip-shared-assets-admin-form select,
.ip-shared-assets-admin-form textarea {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: inherit;
}

.ip-shared-assets-generate-form {
  border-color: #c4b5fd;
  background: linear-gradient(180deg, #faf5ff 0%, #f8fafc 100%);
}

.ip-shared-assets-generate-form .backend-note {
  margin: 0;
  font-size: 0.8rem;
  color: #64748b;
}

.ip-shared-assets-generate-form .backend-note code {
  font-size: 0.78rem;
}

.ip-sa-cat-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 10px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}

.ip-sa-cat-picker label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

.ip-sa-cat-picker select,
.ip-sa-cat-picker input[type="search"] {
  width: 100%;
  box-sizing: border-box;
}

.ip-sa-cat-list {
  min-height: 140px;
  font-size: 0.85rem;
}

.ip-sa-cat-count {
  font-size: 0.75rem;
  color: #64748b;
}

.ip-shared-admin-cat-picker {
  margin-top: 4px;
}

.ip-shared-admin-cat-picker select {
  width: 100%;
  max-width: 420px;
}

.ip-sas-form.is-editing {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #f8fafc 100%);
}

.ip-shared-sections-admin-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.ip-shared-sections-admin-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  font-size: 0.85rem;
}

.ip-shared-sections-admin-list em {
  color: #94a3b8;
  font-style: normal;
  font-size: 0.78rem;
}

.ip-sas-icon-field {
  margin: 10px 0 4px;
}

.ip-sas-icon-field > label {
  display: block;
  margin-bottom: 8px;
}

.ip-sas-icon-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.ip-sas-icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.ip-sas-icon-btn:hover {
  border-color: #a78bfa;
  background: #faf5ff;
}

.ip-sas-icon-btn.is-selected {
  border-color: #7c3aed;
  background: #ede9fe;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.ip-sas-list-icon {
  font-size: 1rem;
  line-height: 1;
}

.ip-sac-form.is-editing {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #f8fafc 100%);
}

.ip-sac-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ip-sa-gen-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #334155;
}

.ip-sa-gen-check input {
  width: auto;
  margin: 0;
}

.ip-sa-gen-layered-check {
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid rgba(14, 116, 144, 0.28);
  border-radius: 8px;
  background: rgba(14, 116, 144, 0.06);
}

.ip-sa-gen-layer-preview {
  margin-top: 4px;
  color: #0f766e !important;
}

.ip-sa-gen-layer-reason {
  color: #64748b;
  font-size: 0.8em;
}

.ip-sa-gen-progress {
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid #ddd6fe;
  border-radius: 10px;
  background: #fff;
}

.ip-sa-gen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.ip-sa-gen-batch-txt {
  margin: 12px 0 14px;
  padding: 14px;
  border: 2px solid #c4b5fd;
  border-radius: 12px;
  background: linear-gradient(180deg, #faf5ff 0%, #f8fafc 100%);
}

.ip-sa-gen-batch-title {
  display: block;
  margin-bottom: 6px;
  color: #5b21b6;
}

.ip-sa-gen-txt-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.ip-sa-gen-txt-browse-btn {
  cursor: pointer;
  margin: 0;
  font-weight: 600;
}

.ip-sa-gen-txt-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ip-sa-gen-txt-summary {
  font-size: 0.85rem;
  color: #64748b;
}

.ip-sa-gen-txt-run-btn {
  margin-top: 10px;
  width: 100%;
}

.ip-sa-gen-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
  color: #94a3b8;
  font-size: 0.82rem;
}

.ip-sa-gen-divider::before,
.ip-sa-gen-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.ip-sa-gen-txt-queue {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ip-sa-gen-txt-queue li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 0.82rem;
  color: #334155;
}

.ip-sa-gen-txt-queue-index {
  font-weight: 700;
  color: #7c3aed;
}

.ip-sa-gen-txt-queue-name {
  flex: 1;
  min-width: 120px;
  word-break: break-all;
}

.ip-sa-gen-txt-queue-count {
  color: #64748b;
  white-space: nowrap;
}

.ip-sa-gen-txt-queue-error {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}

.ip-sa-gen-txt-queue-loading {
  color: #64748b;
  font-style: italic;
}

.ip-sa-gen-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: #ede9fe;
  overflow: hidden;
}

.ip-sa-gen-progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.ip-sa-gen-progress-text {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: #334155;
}

.ip-sa-gen-progress-bar-active span {
  animation: ip-sa-gen-pulse 1.4s ease-in-out infinite;
}

@keyframes ip-sa-gen-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.ip-sa-gen-wait {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: #64748b;
}

#ip-sa-gen-cancel {
  margin-top: 8px;
}

.ip-sa-gen-progress-errors {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 0.78rem;
  color: #b91c1c;
}

.ip-shared-assets-admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.ip-shared-assets-admin-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}

.ip-shared-assets-card-admin {
  position: relative;
}

.ip-shared-assets-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  border: none;
  background: rgba(239, 68, 68, 0.92);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
}

.ip-shared-assets-card-admin .ip-shared-assets-delete,
.ip-shared-inline-card .ip-shared-assets-delete {
  z-index: 3;
}

.ip-shared-assets-note {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: #64748b;
}

.ip-shared-assets-note.error {
  color: #dc2626;
}

.ip-shared-assets-note.success {
  color: #059669;
}
