@font-face {
  font-family: 'Vazirmatn';
  src: url('/Vazirmatn-Regular.ttf') format('truetype');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f3f4f6;
  color: #111827;
  font-family: Vazirmatn, Tahoma, Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.toolbar {
  min-height: 64px;
  display: flex;
  direction: rtl;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.brand-icon {
  display: block;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  object-fit: contain;
}

.brand strong {
  font-size: 19px;
}

.brand span {
  color: #6b7280;
  font-size: 11px;
}

.actions {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 6px;
}

.actions button,
.panel-section button,
.preview-header button {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: #1f2937;
}

.actions button:hover,
.panel-section button:hover,
.preview-header button:hover {
  background: #f9fafb;
}

.actions button.primary {
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.actions button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.status {
  font-size: 11px;
  color: #166534;
  white-space: nowrap;
}

.status[data-state='loading'] {
  color: #92400e;
}

.status[data-state='error'] {
  color: #b91c1c;
}

.workspace {
  direction: ltr;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.variables-panel {
  direction: rtl;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid #e5e7eb;
}

.panel-section {
  padding: 14px;
  border-bottom: 1px solid #eef0f3;
}

.panel-section h2 {
  margin: 0 0 8px;
  font-size: 14px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-title-row h2 {
  margin: 0;
}

.badge {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  text-align: center;
  font-size: 11px;
}

.hint {
  margin: 7px 0 10px;
  color: #6b7280;
  font-size: 11px;
  line-height: 1.8;
}

.panel-section label {
  display: block;
  margin-top: 9px;
  color: #374151;
  font-size: 11px;
}

.panel-section input,
.panel-section textarea {
  width: 100%;
  margin-top: 5px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  outline: none;
}

.panel-section input {
  height: 36px;
  padding: 7px 9px;
}

.panel-section input:focus,
.panel-section textarea:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

.variable-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 9px;
}

.variable-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafafa;
  text-align: right;
}

.variable-item:hover {
  background: #f5f7ff;
  border-color: #c7d2fe;
}

.variable-item[draggable='true'] {
  cursor: grab;
}

.variable-item[draggable='true']:active {
  cursor: grabbing;
}

.variable-key {
  direction: ltr;
  overflow: hidden;
  color: #312e81;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variable-value {
  overflow: hidden;
  max-width: 105px;
  color: #6b7280;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.full-width {
  width: 100%;
  margin-top: 10px;
}

.small {
  padding: 4px 7px !important;
  font-size: 10px;
}

.data-section {
  flex: 1;
  min-height: 260px;
}

#sample-data {
  direction: ltr;
  min-height: 190px;
  resize: vertical;
  padding: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  line-height: 1.6;
  text-align: left;
}

#designer {
  direction: ltr;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  background: #e7e9ed;
}

/* AyarPDF uses its own bottom tools dock; hide pdfme's native vertical toolbar. */
#designer .pdfme-designer-left-sidebar {
  display: none !important;
}

/* pdfme reserves 45px for its native toolbar using inline styles; reclaim it. */
#designer .pdfme-designer-left-sidebar + div {
  margin-left: 0 !important;
  width: 100% !important;
}

.preview-dialog {
  width: min(1100px, 94vw);
  height: 92vh;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

.preview-dialog::backdrop {
  background: rgba(17, 24, 39, 0.58);
}

.preview-header {
  direction: rtl;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
}

#preview-frame {
  width: 100%;
  height: calc(100% - 52px);
  border: 0;
  background: #f3f4f6;
}

noscript {
  padding: 24px;
}

@media (max-width: 1100px) {
  .toolbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .status {
    width: 100%;
  }
}

@media (max-width: 800px) {
  body {
    overflow: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .variables-panel {
    max-height: 430px;
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
  }

  #designer {
    min-height: 850px;
  }
}
