/* Design System & Reset - Light Theme Premium */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #4f46e5;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent-indigo: #4f46e5;
  --accent-purple: #9333ea;
  --accent-gold: #d97706;
  --accent-teal: #0d9488;
  
  --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
  --gradient-gold: linear-gradient(135deg, #b45309 0%, #d97706 50%, #f59e0b 100%);
  --gradient-dark: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 15px rgba(79, 70, 229, 0.1);
  --glass-blur: blur(8px);
  --border-radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.04) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(147, 51, 234, 0.04) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(13, 148, 136, 0.02) 0px, transparent 50%);
  background-attachment: fixed;
}

.hidden {
  display: none !important;
}

.hidden-input {
  display: none !important;
}

/* Page Layout */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.app-footer {
  margin-top: 1rem;
  padding: 1rem 0 0.5rem;
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.footer-counter {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.footer-copy {
  text-align: right;
}

.footer-dashboard-link {
  color: var(--text-secondary);
  opacity: 0.12;
  text-decoration: none;
  letter-spacing: 0;
  line-height: 1;
  user-select: none;
}

.footer-dashboard-link:hover,
.footer-dashboard-link:focus {
  opacity: 0.35;
  outline: none;
}

/* Typography */
h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #0f172a, #334155, #4f46e5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 2.5rem;
  font-weight: 400;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}

.header-actions {
  display: flex;
  gap: 1rem;
}

.language-picker {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 140px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.language-pill-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.language-pill {
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  min-width: 48px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.language-pill:hover {
  border-color: var(--accent-indigo);
  color: var(--accent-indigo);
  background: rgba(79, 70, 229, 0.04);
}

.language-pill.active {
  border-color: var(--accent-indigo);
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.tab-row {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
}

.tab-button {
  background: none;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.tab-button.active {
  color: var(--accent-indigo);
  border-bottom-color: var(--accent-indigo);
}

/* Button Component */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 0 20px rgba(79, 70, 229, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: #e2e8f0;
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(0);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.15);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  transform: translateY(-2px);
}

.btn-small {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.full-width {
  width: 100%;
}

/* Grid Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* White Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
}

.card-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Input Fields */
.form-group {
  margin-bottom: 1.5rem;
}

.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field-toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.field-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
}

.field-toggle input {
  width: 15px;
  height: 15px;
  margin: 0;
}

.host-columns {
  grid-template-columns: 2fr 1fr;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
  background: #ffffff;
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.inline-label {
  margin: 0;
  cursor: pointer;
}

.between-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.helper-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.helper-block {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.code-input {
  min-height: 140px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

.email-body {
  min-height: 100px;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

.form-divider-top {
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.asset-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Dicas Box */
.dicas-box {
  background: rgba(79, 70, 229, 0.03);
  border: 1px dashed rgba(79, 70, 229, 0.2);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.dicas-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-indigo);
  margin-bottom: 0.5rem;
}

.dicas-list {
  list-style: none;
}

.dicas-list li {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  padding-left: 1.2rem;
  position: relative;
}

.dicas-list li::before {
  content: "•";
  color: var(--accent-indigo);
  position: absolute;
  left: 0.2rem;
  font-weight: bold;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.tag-badge {
  border: 1px solid var(--border-color);
  font-size: 0.75rem;
  background: #f1f5f9;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  font-family: inherit;
}

.tag-badge:hover {
  background: rgba(79, 70, 229, 0.08);
  border-color: rgba(79, 70, 229, 0.25);
  color: var(--accent-indigo);
}

/* File Upload Zone */
.upload-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #f8fafc;
  margin-bottom: 1.5rem;
  position: relative;
}

.upload-zone:hover {
  border-color: var(--accent-indigo);
  background: rgba(79, 70, 229, 0.02);
}

.compact-zone {
  padding: 1.25rem;
  margin-top: 0.5rem;
}

.upload-icon {
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

.upload-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 600;
}

.upload-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.asset-preview-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.asset-thumb {
  max-height: 40px;
  max-width: 120px;
  object-fit: contain;
  background: #fff;
  padding: 2px;
  border-radius: 4px;
}

.asset-bg-thumb {
  width: 46px;
  height: 34px;
  background-size: cover;
  background-position: center;
  border-radius: 4px;
}

.asset-status {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Participant List / Table */
.table-container {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-top: 1rem;
}

.participants-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.participants-table th {
  background: #f8fafc;
  padding: 0.75rem;
  font-weight: 650;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
  color: var(--text-secondary);
}

.participants-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.participants-table tr:last-child td {
  border-bottom: none;
}

/* Template Card Selection */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.template-card {
  appearance: none;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: #ffffff;
  font: inherit;
  color: inherit;
}

.template-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-indigo);
  background: rgba(79, 70, 229, 0.02);
}

.template-card.active {
  border-color: var(--accent-indigo);
  background: rgba(79, 70, 229, 0.05);
  box-shadow: 0 0 15px rgba(79, 70, 229, 0.15);
}

.template-thumb {
  height: 70px;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
}

.thumb-classic {
  background: #fafaf9;
  border: 2px solid #b45309;
  color: #7c2d12;
}

.thumb-dark {
  background: #0f172a;
  border: 2px solid #6366f1;
  color: #ffffff;
}

.thumb-gold {
  background: #fbfbfb;
  border: 2px solid #d97706;
  color: #855b14;
}

.thumb-minimal {
  background: #ffffff;
  border: 1px solid #000000;
  color: #000000;
}

.thumb-corporate {
  background: #ffffff;
  border: 2px solid #0b2545;
  color: #0b2545;
}

.thumb-vintage {
  background: #fdfaf2;
  border: 2px double #4a3c24;
  color: #4a3c24;
}

.thumb-tech {
  background: #061826;
  border: 2px solid #22d3ee;
  color: #a7f3d0;
}

.thumb-editorial {
  background: #f8fafc;
  border: 2px solid #be123c;
  color: #111827;
}

.thumb-institutional {
  background: #f7fee7;
  border: 2px solid #166534;
  color: #14532d;
}

.thumb-sideband {
  background: linear-gradient(90deg, #0f766e 0 24%, #ffffff 24%);
  border: 2px solid #0f766e;
  color: #0f172a;
}

.template-name {
  font-size: 0.8rem;
  font-weight: 600;
}

/* Certificate Preview Container */
.preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 100%;
}

.preview-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-buttons {
  display: flex;
  gap: 0.5rem;
}

.action-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

.certificate-scaler {
  width: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: #f1f5f9;
  margin-bottom: 1rem;
  position: relative;
  transition: all 0.3s ease;
}

.certificate-scaler.edit-mode-active {
  outline: 2px solid var(--accent-indigo);
  outline-offset: 3px;
  box-shadow: 0 0 15px rgba(79, 70, 229, 0.2);
}

.editor-panel {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.editor-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-indigo);
}

.editor-help {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.editor-section {
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

.editor-section:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.editor-section-title {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Draggable elements in Edit Mode */
.draggable-element {
  position: absolute;
  cursor: default;
  user-select: none;
  border: 1px dashed transparent;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%); /* Posicionamento centrado em relação à coordenada X,Y */
}

.edit-mode-active .draggable-element {
  cursor: move;
  border-color: rgba(79, 70, 229, 0.4);
  background: rgba(79, 70, 229, 0.02);
}

.edit-mode-active .draggable-element:hover {
  border-color: var(--accent-indigo);
  background: rgba(79, 70, 229, 0.06);
  box-shadow: 0 0 0 1px var(--accent-indigo);
}

.edit-mode-active .draggable-element.dragging {
  border-color: var(--accent-indigo);
  background: rgba(79, 70, 229, 0.12);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 0 2px var(--accent-indigo);
  z-index: 1000;
  transition: none; /* remove delays during dragging */
}

.edit-mode-active .draggable-element.active-selected {
  border-color: var(--accent-indigo);
  border-style: solid;
  border-width: 1.5px;
  background: rgba(79, 70, 229, 0.08);
  box-shadow: 0 0 0 2.5px rgba(79, 70, 229, 0.25), 0 4px 10px rgba(0, 0, 0, 0.05);
  z-index: 1010 !important; /* Sempre acima de outros elementos */
}

/* Certificate Canvas dimensions */
.cert-canvas {
  width: 841px; /* Exato A4 proporção 1.414 */
  height: 595px; 
  position: relative;
  box-sizing: border-box;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  background: white;
}

.cert-custom-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}

.cert-canvas.landscape {
  width: 841px;
  height: 595px;
}

.cert-canvas.portrait {
  width: 595px;
  height: 841px;
}

.badge-sheet-preview {
  width: 595px;
  height: 841px;
  position: relative;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.badge-sheet {
  width: 595px;
  height: 841px;
  display: grid;
  gap: 18px;
  padding: 22px;
  background:
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 28%),
    linear-gradient(180deg, #f8fafc, #ffffff 40%);
}

.badge-sheet.layout-4-landscape {
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr 1fr;
}

.badge-sheet.layout-4-portrait {
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr 1fr;
}

.badge-sheet.layout-8-compact {
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: repeat(4, 1fr);
  gap: 12px;
  padding: 18px;
}

.badge-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 22px;
  overflow: hidden;
  min-height: 0;
  border: 1px solid #dbe3ef;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  background: #ffffff;
}

.layout-4-landscape .badge-card {
  min-height: 188px;
}

.layout-4-portrait .badge-card {
  min-height: 300px;
}

.layout-8-compact .badge-card {
  min-height: 118px;
  border-radius: 16px;
}

.badge-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.1;
}

.badge-top,
.badge-body,
.badge-footer {
  position: relative;
  z-index: 1;
}

.badge-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 10px;
}

.layout-8-compact .badge-top {
  padding: 10px 10px 6px;
  gap: 8px;
}

.badge-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  padding: 6px;
}

.layout-8-compact .badge-logo {
  width: 34px;
  height: 34px;
  padding: 4px;
}

.badge-logo-placeholder {
  min-width: 54px;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
}

.layout-8-compact .badge-logo-placeholder {
  min-width: 34px;
  width: 34px;
  height: 34px;
  font-size: 0.5rem;
}

.badge-org {
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.2;
}

.layout-8-compact .badge-org {
  font-size: 0.68rem;
}

.badge-body {
  padding: 0 16px 12px;
}

.layout-8-compact .badge-body {
  padding: 0 10px 8px;
}

.badge-title {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
}

.layout-8-compact .badge-title {
  font-size: 0.55rem;
}

.badge-name {
  margin-top: 8px;
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1.1;
}

.layout-4-portrait .badge-name {
  font-size: 1.4rem;
}

.layout-8-compact .badge-name {
  margin-top: 4px;
  font-size: 0.82rem;
}

.badge-institution {
  margin-top: 8px;
  font-size: 0.9rem;
  line-height: 1.3;
  color: #475569;
}

.layout-8-compact .badge-institution {
  margin-top: 4px;
  font-size: 0.62rem;
}

.badge-email {
  margin-top: 8px;
  font-size: 0.78rem;
  color: #64748b;
  word-break: break-word;
}

.layout-8-compact .badge-email {
  margin-top: 4px;
  font-size: 0.54rem;
}

.badge-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
}

.badge-footer-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.badge-qr {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
}

.badge-qr svg {
  display: block;
  width: 56px;
  height: 56px;
  background: transparent;
}

.badge-edit-field {
  border-radius: 6px;
}

.edit-mode-active .badge-edit-field {
  cursor: pointer;
  outline: 1px dashed rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.badge-edit-field.active-selected {
  outline: 2px solid #2563eb;
  outline-offset: 3px;
}

.layout-8-compact .badge-footer {
  padding: 6px 10px 8px;
  font-size: 0.52rem;
}

.layout-8-compact .badge-footer-meta {
  gap: 2px;
}

.layout-8-compact .badge-qr {
  width: 34px;
  height: 34px;
}

.layout-8-compact .badge-qr svg {
  width: 34px;
  height: 34px;
}

.badge-classic {
  background: linear-gradient(160deg, #fff7ed, #ffffff 60%);
  color: #7c2d12;
}

.badge-dark {
  background: linear-gradient(145deg, #0f172a, #1e293b);
  color: #f8fafc;
}

.badge-dark .badge-institution,
.badge-dark .badge-email,
.badge-dark .badge-footer {
  color: #cbd5e1;
}

.badge-gold {
  background: linear-gradient(145deg, #fef3c7, #ffffff 58%);
  color: #854d0e;
}

.badge-minimal {
  background: #ffffff;
  color: #111827;
  border: 1.5px solid #cbd5e1;
}

.badge-corporate {
  background: linear-gradient(160deg, #eff6ff, #ffffff 60%);
  color: #1d4ed8;
}

.badge-vintage {
  background: linear-gradient(160deg, #faf5e6, #fffdf7 58%);
  color: #6b4423;
}

.badge-tech {
  background: linear-gradient(145deg, #061826, #102a43);
  color: #e0f2fe;
}

.badge-tech .badge-institution,
.badge-tech .badge-email,
.badge-tech .badge-footer {
  color: #93c5fd;
}

.badge-editorial {
  background: linear-gradient(160deg, #fff1f2, #ffffff 56%);
  color: #881337;
}

.badge-institutional {
  background: linear-gradient(160deg, #ecfdf5, #ffffff 58%);
  color: #166534;
}

.badge-sideband {
  background: linear-gradient(90deg, #0f766e 0 18%, #ffffff 18%);
  color: #0f172a;
}

.badge-sideband .badge-logo-placeholder {
  background: #ccfbf1;
  color: #0f766e;
}

/* Drag Element Label Overlay */
.drag-label {
  display: none;
  position: absolute;
  top: -18px;
  left: 0;
  background: var(--accent-indigo);
  color: white;
  font-size: 0.6rem;
  font-family: sans-serif;
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
}

.edit-mode-active .draggable-element:hover .drag-label,
.edit-mode-active .draggable-element.dragging .drag-label,
.edit-mode-active .draggable-element.active-selected .drag-label {
  display: block;
}

.cert-signature-container,
.cert-qr-container {
  text-align: center;
}

.cert-qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.cert-signature-img {
  display: block;
}

.cert-qr-code {
  display: flex;
  justify-content: center;
}

.cert-qr-code svg {
  display: block;
  width: 104px;
  height: 104px;
  background: transparent;
}

.footer-line {
  border-top: 1px solid currentColor;
}

.footer-strong {
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 2px;
}

.footer-strong.corporate {
  color: #0f172a;
}

/* Designs of Certificate */

/* Template 1: Classic */
.cert-classic {
  background: #fafaf9;
  color: #1c1917;
  border: 20px double #b45309;
  font-family: 'Georgia', serif;
}

.cert-classic::before {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 5px;
  right: 5px;
  border: 2px solid #d97706;
  pointer-events: none;
}

.cert-classic .title {
  font-size: 2.2rem;
  color: #7c2d12;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  font-family: 'Georgia', serif;
}

.cert-classic .sub {
  font-size: 1.1rem;
  font-style: italic;
  color: #78716c;
  text-align: center;
}

.cert-classic .name {
  color: #1c1917;
  font-weight: bold;
  border-bottom: 1px solid #e7e5e4;
  padding-bottom: 5px;
  text-align: center;
}

.cert-classic .body-text {
  line-height: 1.6;
  color: #44403c;
  text-align: center;
  max-width: 600px;
}

.cert-classic .divider {
  width: 80px;
  height: 2px;
  background: #d97706;
}

.cert-classic .footer-label {
  border-top: 1px solid #b45309;
  padding-top: 5px;
  font-size: 0.85rem;
  color: #78716c;
  min-width: 140px;
  text-align: center;
}

/* Template 2: Modern Dark */
.cert-dark {
  background: #0f172a;
  color: #f1f5f9;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  border: 2px solid rgba(255, 255, 255, 0.05);
}

.cert-dark::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 10px;
  height: 100%;
  background: var(--gradient-primary);
}

.cert-dark.portrait::before {
  top: 0;
  left: 0;
  width: 100%;
  height: 10px;
}

.cert-dark .title {
  font-size: 2.3rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

.cert-dark .sub {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #6366f1;
  font-weight: bold;
  text-align: center;
}

.cert-dark .name {
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
  text-align: center;
}

.cert-dark .body-text {
  line-height: 1.6;
  color: #94a3b8;
  text-align: center;
  max-width: 600px;
}

.cert-dark .footer-label {
  font-size: 0.8rem;
  color: #64748b;
  text-align: center;
}

/* Template 3: Creative Gold */
.cert-gold {
  background: #fbfbfb;
  color: #3b2c14;
  font-family: 'Times New Roman', Times, serif;
}

.cert-gold::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 12px;
  right: 12px;
  border: 1px solid #d97706;
  pointer-events: none;
}

.cert-gold-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.12;
  background-image: radial-gradient(circle at 100% 150%, #fbbf24 24%, white 24%, white 28%, #fbbf24 28%, #fbbf24 36%, white 36%, white 40%, #fbbf24 40%, #fbbf24 60%, white 60%);
  z-index: 1;
  pointer-events: none;
}

.cert-gold .title {
  font-size: 2.6rem;
  font-weight: bold;
  color: #855b14;
  letter-spacing: 0.05em;
  text-align: center;
}

.cert-gold .sub {
  font-size: 1.1rem;
  color: #6b5a3e;
  font-style: italic;
  text-align: center;
}

.cert-gold .name {
  font-family: 'Brush Script MT', 'Bickham Script Pro', cursive, serif;
  color: #855b14;
  text-align: center;
}

.cert-gold .body-text {
  line-height: 1.6;
  color: #4a3c24;
  text-align: center;
  max-width: 600px;
}

.cert-gold .footer-label {
  border-top: 1px solid #d97706;
  padding-top: 4px;
  font-size: 0.85rem;
  color: #6b5a3e;
  min-width: 140px;
  text-align: center;
}

/* Template 4: Minimalist */
.cert-minimal {
  background: #ffffff;
  color: #000000;
  border: 1px solid #cbd5e1;
  font-family: Courier, monospace;
}

.cert-minimal .title {
  font-size: 1.8rem;
  font-weight: normal;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  border-bottom: 2px solid #000000;
  padding-bottom: 5px;
  text-align: center;
}

.cert-minimal .sub {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #4b5563;
  text-align: center;
}

.cert-minimal .name {
  font-weight: normal;
  text-transform: uppercase;
  text-align: center;
}

.cert-minimal .body-text {
  line-height: 1.6;
  color: #374151;
  text-align: center;
  max-width: 600px;
}

.cert-minimal .footer-label {
  border-top: 1px solid #000000;
  padding-top: 4px;
  font-size: 0.85rem;
  color: #000000;
  min-width: 120px;
  text-align: center;
}

/* Template 5: Corporate Blue */
.cert-corporate {
  background: #ffffff;
  color: #1e293b;
  font-family: 'Outfit', sans-serif;
  border: 12px solid #0f172a;
}

.cert-corporate::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 120px;
  background: #3b82f6;
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  pointer-events: none;
}

.cert-corporate::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 120px;
  height: 120px;
  background: #1d4ed8;
  clip-path: polygon(0 100%, 0 0, 100% 100%);
  pointer-events: none;
}

.cert-corporate .title {
  font-size: 2.2rem;
  font-weight: 800;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
}

.cert-corporate .sub {
  font-size: 0.95rem;
  font-weight: 600;
  color: #3b82f6;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
}

.cert-corporate .name {
  font-weight: 700;
  color: #1e3a8a;
  border-bottom: 2px solid #3b82f6;
  text-align: center;
}

.cert-corporate .body-text {
  line-height: 1.6;
  color: #475569;
  text-align: center;
  max-width: 600px;
}

.cert-corporate .footer-label {
  border-top: 1.5px solid #0f172a;
  padding-top: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f172a;
  text-align: center;
}

/* Template 6: Vintage Classic */
.cert-vintage {
  background: #fdfaf2;
  color: #3f2c1d;
  font-family: 'Palatino', 'URW Palladio L', serif;
  border: 15px double #4a3c24;
}

.cert-vintage::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 8px;
  right: 8px;
  border: 1px solid #7c623a;
  pointer-events: none;
}

.cert-vintage .title {
  font-size: 2.4rem;
  font-family: 'Didot', 'Times New Roman', serif;
  color: #4a3c24;
  text-align: center;
  letter-spacing: 0.02em;
}

.cert-vintage .sub {
  font-size: 1.05rem;
  font-style: italic;
  color: #634d32;
  text-align: center;
}

.cert-vintage .name {
  font-family: 'Brush Script MT', cursive, serif;
  font-size: 2.8rem;
  color: #5c401f;
  text-align: center;
}

.cert-vintage .body-text {
  line-height: 1.7;
  color: #3f2d1e;
  text-align: center;
  max-width: 600px;
  font-style: italic;
}

.cert-vintage .footer-label {
  border-top: 1px solid #7c623a;
  padding-top: 4px;
  font-size: 0.85rem;
  color: #634d32;
  text-align: center;
}

/* Template 7: Tech Neon */
.cert-tech {
  background: #061826;
  color: #e0f2fe;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  border: 10px solid #0e7490;
}

.cert-tech::before {
  content: "";
  position: absolute;
  inset: 24px;
  border: 1px solid rgba(34, 211, 238, 0.45);
  pointer-events: none;
}

.cert-tech::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 42%;
  height: 100%;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(16, 185, 129, 0.06));
  clip-path: polygon(38% 0, 100% 0, 100% 100%, 0 100%);
  pointer-events: none;
}

.cert-tech .title {
  font-size: 2.25rem;
  font-weight: 900;
  color: #67e8f9;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-align: center;
}

.cert-tech .sub {
  font-size: 0.95rem;
  font-weight: 700;
  color: #86efac;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  text-align: center;
}

.cert-tech .name {
  font-weight: 800;
  color: #ffffff;
  text-align: center;
}

.cert-tech .body-text {
  line-height: 1.6;
  color: #bfdbfe;
  text-align: center;
  max-width: 610px;
}

.cert-tech .footer-label {
  border-top: 1px solid rgba(103, 232, 249, 0.65);
  padding-top: 4px;
  color: #93c5fd;
  font-size: 0.82rem;
  text-align: center;
}

/* Template 8: Editorial Serif */
.cert-editorial {
  background: #fff7f7;
  color: #111827;
  font-family: 'Georgia', serif;
  border: 0;
}

.cert-editorial::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-top: 10px solid #be123c;
  border-bottom: 1px solid #fecdd3;
  pointer-events: none;
}

.cert-editorial .title {
  font-size: 2.35rem;
  color: #111827;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
}

.cert-editorial .sub {
  font-size: 1rem;
  color: #be123c;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  text-align: center;
}

.cert-editorial .name {
  color: #be123c;
  font-weight: 700;
  text-align: center;
}

.cert-editorial .body-text {
  line-height: 1.7;
  color: #374151;
  text-align: center;
  max-width: 590px;
}

.cert-editorial .divider {
  width: 120px;
  height: 3px;
  background: #be123c;
}

.cert-editorial .footer-label {
  border-top: 1px solid #fda4af;
  padding-top: 4px;
  color: #4b5563;
  font-size: 0.85rem;
  text-align: center;
}

/* Template 9: Institutional Green */
.cert-institutional {
  background: #fbfff7;
  color: #14532d;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  border: 14px solid #166534;
}

.cert-institutional::before {
  content: "";
  position: absolute;
  inset: 16px;
  border: 2px solid #bbf7d0;
  pointer-events: none;
}

.cert-institutional .title {
  font-size: 2.15rem;
  color: #14532d;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
}

.cert-institutional .sub {
  font-size: 1rem;
  color: #15803d;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
}

.cert-institutional .name {
  color: #166534;
  font-weight: 800;
  border-bottom: 2px solid #86efac;
  text-align: center;
}

.cert-institutional .body-text {
  line-height: 1.65;
  color: #36553f;
  text-align: center;
  max-width: 610px;
}

.cert-institutional .divider {
  width: 90px;
  height: 2px;
  background: #16a34a;
}

.cert-institutional .footer-label {
  border-top: 1px solid #16a34a;
  padding-top: 4px;
  color: #166534;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* Template 10: Clean Side Band */
.cert-sideband {
  background: #ffffff;
  color: #0f172a;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  border: 1px solid #cbd5e1;
}

.cert-sideband::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 96px;
  background: #0f766e;
  pointer-events: none;
}

.cert-sideband.portrait::before {
  width: 72px;
}

.cert-sideband .title {
  font-size: 2.1rem;
  color: #0f172a;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}

.cert-sideband .sub {
  font-size: 0.98rem;
  color: #0f766e;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

.cert-sideband .name {
  color: #0f766e;
  font-weight: 800;
  text-align: center;
}

.cert-sideband .body-text {
  line-height: 1.6;
  color: #475569;
  text-align: center;
  max-width: 590px;
}

.cert-sideband .footer-label {
  border-top: 1px solid #14b8a6;
  padding-top: 4px;
  color: #334155;
  font-size: 0.85rem;
  text-align: center;
}


/* Logs and Status Console */
.console-box {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 1.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: #10b981;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 1.5rem;
}

.console-line {
  margin-bottom: 0.35rem;
  display: flex;
  gap: 0.5rem;
}

.console-timestamp {
  color: #64748b;
}

.console-info {
  color: #3b82f6;
}

.console-success {
  color: #10b981;
}

.console-error {
  color: #ef4444;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 550px;
  padding: 2rem;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.04);
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--text-primary);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--text-primary);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Progress bar */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Global Preview Modal Styles */
.global-preview-modal-content {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 95%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.global-preview-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex-grow: 1;
  background: #f8fafc;
}

.global-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.global-preview-item {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.global-preview-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-scaler {
  width: 100%;
  overflow: hidden;
  position: relative;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: #f1f5f9;
  transition: all 0.3s ease;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.offscreen-root {
  position: absolute;
  left: -9999px;
  top: -9999px;
}

@media (max-width: 900px) {
  .two-columns,
  .host-columns {
    grid-template-columns: 1fr;
  }

  .preview-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .preview-buttons {
    width: 100%;
    flex-wrap: wrap;
  }

  .app-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-copy {
    text-align: left;
  }
}
