/* ════════════════════════════════════════════════════════════════════════════════ */
/* TEMPLATES PAGE - Styles */
/* ════════════════════════════════════════════════════════════════════════════════ */

:root {
  --primary-color: #036e7e;
  --secondary-color: #f39c12;
  --dark-color: #1a1a1a;
  --light-color: #ecf0f1;
  --border-color: #bdc3c7;
  --success-color: #10b981;
  --warning-color: #f39c12;
  --danger-color: #e74c3c;
  --info-color: #3498db;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Layout Base */
/* ────────────────────────────────────────────────────────────────────────────────── */

.app-layout {
  display: flex;
  height: 100vh;
  background-color: #f8f9fa;
}

.sidebar {
  width: 300px;
  background: linear-gradient(135deg, var(--primary-color) 0%, #0d3d47 100%);
  border-right: 2px solid var(--secondary-color);
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  color: white;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.sidebar-title i {
  font-size: 24px;
  color: var(--secondary-color);
}

.btn-icon {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 18px;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

#btnToggleSidebar {
  position: absolute;
  right: 10px;
  top: 10px;
}


/* Template List */
.template-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.template-item {
  padding: 15px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-left: 4px solid var(--secondary-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.template-item:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateX(5px);
}

.template-item.active {
  background: var(--secondary-color);
  color: white;
  border-left-color: white;
}

.template-item.bloqueado {
  border-left-color: var(--danger-color);
  background: rgba(231, 76, 60, 0.08);
}

.template-item.bloqueado:hover {
  background: rgba(231, 76, 60, 0.15);
}

.template-item-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-item-meta {
  font-size: 12px;
  opacity: 0.8;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.template-item-status {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 15px;
  opacity: 0.6;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Main Content Area */
/* ────────────────────────────────────────────────────────────────────────────────── */

.templates-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f8f9fa;
  position: relative;
}

.templates-header {
  background: linear-gradient(180deg, #ffffff 0%, #f4fbff 100%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 24px;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: 0 20px 60px rgba(3, 110, 126, 0.08);
  flex-wrap: wrap;
}

.templates-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
  min-width: 220px;
}

.header-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.header-title h5 {
  margin: 0;
  font-weight: 700;
  color: var(--primary-color);
  font-size: 22px;
}

.header-subtitle {
  margin: 0;
  font-size: 14px;
  color: #5d6d7b;
  max-width: 340px;
}

.templates-header-left .btn-icon {
  color: var(--primary-color);
  background: rgba(1, 70, 81, 0.08);
  border-radius: 14px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.templates-header-left .btn-icon:hover {
  background: rgba(1, 70, 81, 0.14);
  transform: translateY(-1px);
}

.templates-header-actions {
  display: flex;
  gap: 16px;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.template-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: nowrap;
  flex: 1 1 420px;
  min-width: 280px;
  justify-content: flex-start;
  background: rgba(3, 110, 126, 0.06);
  border-radius: 18px;
  padding: 10px 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 200px;
  max-width: 280px;
  flex: 1 1 260px;
  padding: 10px 12px;
  border-radius: 999px;
  background: white;
  border: 1px solid rgba(3, 110, 126, 0.16);
  box-shadow: 0 10px 32px rgba(3, 110, 126, 0.08);
}

.search-box i {
  color: var(--primary-color);
  font-size: 16px;
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  min-width: 220px;
  font-size: 14px;
  color: var(--text-color);
}

/* Legacy button group kept for fallback, now hidden if dropdown exists */
.template-filter-buttons {
  display: none;
}

.template-filter-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: white;
  border: 1px solid rgba(3, 110, 126, 0.16);
  border-radius: 999px;
  padding: 8px 10px;
  min-width: 160px;
  box-shadow: 0 10px 28px rgba(3, 110, 126, 0.08);
}

.template-filter-dropdown select {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text-color);
  padding: 6px 6px;
  min-width: 150px;
  appearance: none;
  padding-right: 24px;
}

.template-filter-dropdown::after {
  content: '▼';
  font-size: 12px;
  color: rgba(3, 110, 126, 0.8);
  position: absolute;
  right: 10px;
  pointer-events: none;
}

.template-filter-buttons .btn-filter {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--primary-color);
  background: rgba(255,255,255,0.92);
  transition: all 0.2s ease;
  gap: 8px;
  display: inline-flex;
  align-items: center;
}

.template-filter-buttons .btn-filter:hover {
  background: rgba(3, 110, 126, 0.12);
}

.template-filter-buttons .btn-filter.active {
  background: linear-gradient(135deg, #005e6a 0%, #1098a8 100%);
  color: white;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
}

.template-filter-buttons .btn-filter.btn-filter-approved.active {
  background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
}

.template-filter-buttons .btn-filter.btn-filter-pending.active {
  background: linear-gradient(135deg, #facc15 0%, #f59e0b 100%);
}

.template-filter-buttons .btn-filter.btn-filter-rejected.active {
  background: linear-gradient(135deg, #ef4444 0%, #f43f5e 100%);
}

.template-filter-buttons .btn-filter i {
  font-size: 14px;
}

.templates-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  min-width: 200px;
}

.templates-actions .btn {
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: 0 10px 26px rgba(3, 110, 126, 0.1);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: 13px;
}

.templates-actions .btn i {
  margin-right: 8px;
}

.btn-outline-secondary {
  color: var(--primary-color);
  border-color: rgba(3, 110, 126, 0.18);
  background: rgba(255, 255, 255, 0.98);
}

.btn-outline-secondary:hover {
  background: var(--primary-color);
  color: white;
  border-color: transparent;
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #14b8a6);
  border-color: transparent;
  color: white;
}

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #1d4ed8);
  border-color: transparent;
  color: white;
}

.templates-actions .btn i {
  margin-right: 6px;
}

.templates-actions .btn span {
  display: inline-flex;
}

/* Main Content */
.templates-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.templates-content.has-content {
  display: block;
  align-items: auto;
  justify-content: auto;
}

.template-details {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  max-width: 100%;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Banner de Bloqueio 24h */
/* ────────────────────────────────────────────────────────────────────────────────── */

.template-bloqueio-banner {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 20px;
  padding: 20px;
  margin-bottom: 25px;
  background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
  border: 2px solid #ffc107;
  border-radius: 8px;
  border-left: 6px solid #dc3545;
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.15);
  animation: slidein 0.3s ease-out;
}

@keyframes slidein {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.template-bloqueio-icon {
  font-size: 32px;
  color: #dc3545;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.template-bloqueio-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.template-bloqueio-titulo {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 700;
  color: #dc3545;
  line-height: 1.3;
}

.template-bloqueio-mensagem {
  margin: 0 0 10px 0;
  font-size: 14px;
  color: #333;
  line-height: 1.4;
}

.template-bloqueio-tempo {
  margin: 0;
  font-size: 13px;
  color: #333;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 12px;
  border-radius: 4px;
  border-left: 3px solid #ffc107;
}

.template-bloqueio-tempo strong {
  color: #dc3545;
  font-weight: 600;
}

.template-details-header {
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 15px;
  margin-bottom: 25px;
}

.template-details-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-color);
  margin: 0;
  margin-bottom: 8px;
}

.template-details-subtitle {
  font-size: 14px;
  color: #666;
  margin: 0;
}

.template-field {
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 20px;
}

.template-field-label {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.template-field-value {
  font-size: 14px;
  color: #333;
  word-break: break-word;
}

.template-field-value.status {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status.APROVADO {
  background: rgba(39, 174, 96, 0.2);
  color: var(--success-color);
}

.status.RASCUNHO {
  background: rgba(52, 152, 219, 0.2);
  color: var(--info-color);
}

.status.REJEITADO {
  background: rgba(231, 76, 60, 0.2);
  color: var(--danger-color);
}

.status.PAUSADO {
  background: rgba(243, 156, 18, 0.2);
  color: var(--warning-color);
}

.template-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 2px solid var(--border-color);
}

.template-actions .btn {
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.template-actions .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #e9ecef !important;
  border-color: #dee2e6 !important;
  color: #6c757d !important;
  pointer-events: none;
}

.template-actions .btn:disabled::after {
  content: "";
}

.template-actions .btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Stats */
/* ────────────────────────────────────────────────────────────────────────────────── */

.templates-stats {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 15px;
  background: white;
  border-top: 2px solid var(--border-color);
}

.stat-card {
  background: linear-gradient(135deg, var(--primary-color) 0%, #0d3d47 100%);
  color: white;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 12px;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Modal */
/* ────────────────────────────────────────────────────────────────────────────────── */

.modal-content {
  border: 2px solid var(--primary-color);
  border-radius: 8px;
}

.modal-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, #0d3d47 100%);
  color: white;
  border: none;
}

.modal-header .btn-close {
  filter: brightness(0) invert(1);
}

.modal-title {
  font-weight: 700;
  font-size: 18px;
}

.modal-body {
  padding: 25px;
}

.modal-footer {
  background: #f8f9fa;
  border-top: 2px solid var(--border-color);
  display: flex;
  justify-content: space-between;
}

.modal-footer .actions-left {
  display: flex;
  gap: 10px;
}

.modal-footer .actions-right {
  display: flex;
  gap: 10px;
}

.modal-footer .btn {
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 4px;
}

.modal-footer .btn-primary {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.modal-footer .btn-primary:hover {
  background: #0d3d47;
  border-color: #0d3d47;
}

.modal-footer .btn-danger {
  color: var(--danger-color);
  border-color: var(--danger-color);
}

.modal-footer .btn-danger:hover {
  background: var(--danger-color);
  color: white;
}

/* Form fields in modal */
.modal-body .form-group {
  margin-bottom: 20px;
}

.modal-body label {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-body .form-control {
  border: 2px solid var(--border-color);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.modal-body .form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(1, 70, 81, 0.25);
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Send Template Modal Styles */
/* ────────────────────────────────────────────────────────────────────────────────── */

.template-preview-section {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 25px;
}

.template-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.preview-title {
  color: var(--primary-color);
  font-weight: 600;
  margin: 0;
  font-size: 16px;
}

.template-preview-content {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 15px;
  min-height: 80px;
}

.template-message {
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.variable-highlight {
  background: #fff3cd;
  color: #856404;
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 600;
}

/* Variables Section */
.variables-section {
  background: linear-gradient(135deg, #fff8e1 0%, #fff3c4 100%);
  border: 2px solid var(--warning-color);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 25px;
}

.variables-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.variables-title {
  color: var(--primary-color);
  font-weight: 600;
  margin: 0;
  font-size: 16px;
}

.variables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
}

.variable-input-group {
  background: white;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  padding: 15px;
  transition: all 0.2s ease;
}

.variable-input-group:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(1, 70, 81, 0.1);
}

.variable-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 8px;
  font-size: 14px;
}

.variable-brace {
  color: var(--warning-color);
  font-weight: bold;
}

.variable-name {
  background: var(--warning-color);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

.variable-input {
  border: 2px solid var(--border-color);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.variable-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(1, 70, 81, 0.25);
}

/* Contacts Section */
.contacts-section {
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
  border: 2px solid var(--success-color);
  border-radius: 8px;
  padding: 20px;
}

.contacts-header {
  margin-bottom: 20px;
}

.contacts-title {
  color: var(--primary-color);
  font-weight: 600;
  margin: 0;
  font-size: 16px;
}

.contact-search-wrapper {
  margin-bottom: 20px;
}

.contact-search-input {
  border: 2px solid var(--border-color);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
}

.contact-search-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(1, 70, 81, 0.25);
}

.contacts-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-height: 400px;
}

.selected-contacts-section,
.available-contacts-section {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.selected-contacts-header,
.available-contacts-header {
  background: var(--primary-color);
  color: white;
  padding: 12px 15px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.contacts-total {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.selected-contacts-list,
.available-contacts-list {
  max-height: 300px;
  overflow-y: auto;
}

.selected-count {
  background: var(--success-color);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
}

/* Contact Items */
.contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  border-bottom: 1px solid #f0f0f0;
  transition: all 0.2s ease;
  cursor: pointer;
}

.contact-item:hover {
  background: #f8f9fa;
}

.contact-item.selected {
  background: #e8f5e8;
  border-left: 4px solid var(--success-color);
}

.contact-info {
  flex: 1;
}

.contact-name {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 2px;
}

.contact-phone {
  font-size: 12px;
  color: #666;
}

.contact-select-btn {
  transition: all 0.2s ease;
}

.contact-select-btn:hover {
  transform: scale(1.1);
}

/* Selected Contacts */
.selected-contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  border-bottom: 1px solid #f0f0f0;
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
}

.selected-contact-info {
  flex: 1;
}

.selected-contact-name {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 14px;
  margin-bottom: 2px;
}

.selected-contact-phone {
  font-size: 12px;
  color: #666;
}

.remove-contact-btn {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.remove-contact-btn:hover {
  background: var(--danger-color);
  border-color: var(--danger-color);
  color: white;
}

/* Empty States */
.empty-selected,
.empty-contacts {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: #666;
  text-align: center;
}

.empty-selected i,
.empty-contacts i {
  font-size: 48px;
  margin-bottom: 10px;
  opacity: 0.5;
}

.empty-selected span,
.empty-contacts span {
  font-size: 14px;
}

.empty-contacts.error {
  color: var(--danger-color);
}

.empty-contacts.error i {
  color: var(--danger-color);
}

/* Loading States */
.contacts-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: #666;
}

.contacts-loading i {
  font-size: 24px;
  margin-bottom: 10px;
}

.contacts-loading span {
  font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
  .contacts-container {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .variables-grid {
    grid-template-columns: 1fr;
  }

  .template-preview-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .variables-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

.modal-body .form-control:disabled {
  background-color: #e9ecef;
  color: #6c757d;
  cursor: not-allowed;
}

.read-only-field {
  padding: 10px 12px;
  background: #f0f0f0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: #666;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Template List Improvements */
/* ────────────────────────────────────────────────────────────────────────────────── */

.template-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  min-width: 0;
}

.template-item-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 56px;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-item-status-badge i {
  font-size: 10px;
}

.template-item-categoria,
.template-item-idioma,
.template-item-setor {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  margin-right: 6px;
}

.template-item-categoria i,
.template-item-idioma i,
.template-item-setor i {
  font-size: 10px;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Template Details Header Improvements */
/* ────────────────────────────────────────────────────────────────────────────────── */

.template-details-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 10px;
}

.badge-lg {
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-lg i {
  font-size: 16px;
}

.badge-categoria {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  font-size: 13px;
}

.badge-categoria i {
  font-size: 14px;
}

/* ✅ Badge RASCUNHO com cor mais escura */
.template-item-status-badge.status-rascunho {
  background-color: rgb(84, 86, 89) !important;
  color: white !important;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Status Detailed View */
/* ────────────────────────────────────────────────────────────────────────────────── */

.status-detailed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-description {
  font-size: 12px;
  color: #666;
  margin: 0;
  font-style: italic;
  padding-left: 10px;
  border-left: 3px solid var(--border-color);
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Template Dates */
/* ────────────────────────────────────────────────────────────────────────────────── */

.template-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.template-dates div {
  background: #f8f9fa;
  padding: 10px;
  border-radius: 4px;
  border-left: 3px solid var(--secondary-color);
}

.template-dates strong {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary-color);
  margin-bottom: 5px;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Loading & Empty States */
/* ────────────────────────────────────────────────────────────────────────────────── */

.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.spinner-border {
  color: var(--primary-color) !important;
  border-width: 3px;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Responsive */
/* ────────────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 2px solid var(--secondary-color);
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1000;
    height: 100vh;
  }

  .sidebar.show {
    display: flex;
  }

  .templates-header {
    padding: 14px 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .templates-header-left {
    flex: 1 1 100%;
  }

  .templates-header-actions {
    width: 100%;
    flex-direction: column;
    gap: 10px;
    justify-content: stretch;
    align-items: stretch;
  }

  .template-controls {
    width: 100%;
    flex: 1 1 100%;
    gap: 8px;
    padding: 8px 10px;
  }

  .search-box {
    flex: 1 1 auto;
    max-width: none;
    min-width: 0;
    padding: 8px 10px;
    font-size: 13px;
  }

  .search-box i {
    font-size: 14px;
  }

  .search-box input {
    font-size: 13px;
    min-width: 0;
  }

  .template-filter-dropdown {
    flex: 0 1 auto;
    min-width: 130px;
    padding: 6px 8px;
  }

  .template-filter-dropdown select {
    font-size: 13px;
    padding: 5px 5px;
    min-width: 130px;
    padding-right: 22px;
  }

  .template-filter-dropdown::after {
    font-size: 10px;
    right: 8px;
  }

  .templates-actions {
    width: 100%;
    justify-content: space-around;
    gap: 6px;
    min-width: auto;
  }

  .templates-actions .btn {
    flex: 1 1 auto;
    min-width: auto;
    padding: 8px 10px;
    min-height: 40px;
    font-size: 12px;
  }

  .templates-actions .btn i {
    margin-right: 4px;
  }

  .templates-actions .btn span {
    display: none;
  }

  .template-filter-buttons {
    width: 100%;
  }

  .template-field {
    grid-template-columns: 1fr;
  }

  .templates-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .template-details {
    padding: 20px;
  }

  .modal-dialog {
    margin: 10px;
  }
}

@media (max-width: 576px) {
  .templates-header {
    padding: 12px 14px;
    border-radius: 16px;
  }

  .header-title h5 {
    font-size: 18px;
  }

  .templates-header-actions {
    gap: 8px;
  }

  .template-controls {
    gap: 6px;
    padding: 6px 8px;
  }

  .search-box {
    padding: 8px 10px;
    min-width: 0;
    max-width: none;
  }

  .search-box i {
    font-size: 12px;
    flex-shrink: 0;
  }

  .search-box input {
    font-size: 12px;
  }

  .template-filter-dropdown {
    min-width: 120px;
    padding: 6px 8px;
  }

  .template-filter-dropdown select {
    font-size: 12px;
    min-width: 115px;
    padding: 4px 4px;
    padding-right: 20px;
  }

  .template-filter-dropdown::after {
    font-size: 9px;
    right: 6px;
  }

  .templates-actions .btn {
    padding: 6px 8px;
    min-height: 38px;
    font-size: 11px;
  }

  .templates-stats {
    grid-template-columns: 1fr;
  }

  .template-details {
    padding: 15px;
  }

  .template-details-title {
    font-size: 18px;
  }

  .template-field-label {
    font-size: 12px;
  }

  .template-field-value {
    font-size: 13px;
  }
}
/* ────────────────────────────────────────────────────────────────────────────────── */
/* Template Structure Preview */
/* ────────────────────────────────────────────────────────────────────────────────── */

.template-preview {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  border: 2px solid var(--border-color);
}

.template-component {
  background: white;
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 15px;
  border-left: 4px solid var(--primary-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.template-component-header {
  border-left-color: #3498db;
}

.template-component-body {
  border-left-color: #27ae60;
}

.template-component-footer {
  border-left-color: #95a5a6;
}

.template-component-buttons {
  border-left-color: #e74c3c;
}

.component-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 12px;
  font-size: 14px;
}

.component-label i {
  font-size: 18px;
}

.component-label .badge {
  margin-left: auto;
  font-size: 11px;
}

.component-content {
  margin-left: 28px;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Modal Criar Template - Accordion */
/* ────────────────────────────────────────────────────────────────────────────────── */

.create-template-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border-color);
}

.create-template-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-color);
  margin: 0 0 15px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.accordion-flush .accordion-button {
  padding: 12px 15px;
  font-weight: 600;
  color: var(--primary-color);
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  box-shadow: none !important;
}

.accordion-flush .accordion-button:not(.collapsed) {
  color: white;
  background: var(--secondary-color);
  border-bottom-color: var(--secondary-color);
}

.accordion-flush .accordion-button:focus {
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 0.25rem rgba(243, 156, 18, 0.25) !important;
}

.accordion-flush .accordion-body {
  padding: 20px 15px;
  background: #f8f9fa;
}

.accordion-item:first-child .accordion-button {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.accordion-item:last-child {
  border-bottom: 1px solid var(--border-color);
}

/* Botões de seleção de tipo */
.btn-group {
  display: flex;
  flex-wrap: wrap;
}

.btn-group .btn-check {
  display: none;
}

.btn-group .btn-check:checked + .btn,
.btn-group .btn:has(.btn-check:checked) {
  background: var(--secondary-color);
  color: white;
  border-color: var(--secondary-color);
  font-weight: 600;
}

/* Container de botões dinâmicos */
.buttons-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.button-row {
  background: linear-gradient(135deg, #f9f9f9 0%, #f0f0f0 100%);
  border: 2px solid var(--border-color);
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.button-row:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(1, 70, 81, 0.12);
  background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
}

.button-row .row {
  margin: 0;
}

.button-row .form-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--primary-color);
}

.button-row .form-select,
.button-row .form-control {
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 13px;
}

.button-row .form-select:focus,
.button-row .form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(1, 70, 81, 0.1);
}

.button-row .btn-danger {
  margin-top: 12px;
}

.button-row small {
  font-size: 12px;
}

/* Container de amostras */
.amostras-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.amostras-container .form-group {
  margin-bottom: 0;
}

/* Editor Samples (exemplos de variáveis) */
.editor-samples {
  background: #f0f7ff;
  border: 2px solid #cce5ff;
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
}

.editor-samples strong {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-color);
  margin-bottom: 10px;
  font-size: 14px;
}

.editor-samples .form-group {
  margin-bottom: 10px;
}

.editor-samples .form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 6px;
}

.editor-samples .editor-sample {
  background: white;
  border: 1px solid #cce5ff;
  font-size: 13px;
}

.editor-samples .editor-sample:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(1, 70, 81, 0.1);
}

.modal-xl {
  max-width: 900px;
}

.modal-body {
  max-height: 70vh;
  overflow-y: auto;
}

.form-label .text-danger {
  margin-left: 2px;
}

.component-text {
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  word-break: break-word;
}

.component-text-small {
  font-size: 12px;
  line-height: 1.5;
  color: #666;
  font-style: italic;
}

.component-media {
  font-size: 13px;
  color: #666;
  padding: 10px;
  background: #e9ecef;
  border-radius: 4px;
  border-left: 3px solid var(--info-color);
}

.template-variable {
  background: rgba(52, 152, 219, 0.2);
  color: #2980b9;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
  font-family: monospace;
  font-size: 12px;
}

.component-variables {
  margin-top: 12px;
  padding: 10px;
  background: rgba(243, 156, 18, 0.1);
  border-radius: 4px;
  border-left: 3px solid var(--warning-color);
}

.component-variables strong {
  font-size: 12px;
  color: var(--primary-color);
  display: block;
  margin-bottom: 8px;
}

.variables-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.variables-list .badge {
  font-size: 11px;
}

/* Buttons Component */
.buttons-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.button-item {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 12px;
  transition: all 0.2s ease;
}

.button-item:hover {
  background: #ecf0f1;
  border-color: var(--primary-color);
}

.button-header {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.button-header .badge {
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.button-text {
  font-weight: 600;
  color: #333;
  font-size: 14px;
  margin-bottom: 6px;
}

.button-detail {
  font-size: 12px;
  color: #666;
  padding: 6px 8px;
  background: white;
  border-radius: 3px;
  border-left: 2px solid var(--secondary-color);
  margin-top: 6px;
  word-break: break-all;
}

.button-detail strong {
  color: var(--primary-color);
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Modal Tabs */
/* ────────────────────────────────────────────────────────────────────────────────── */

.modal-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 10px;
}

.modal-tab-btn {
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-tab-btn:hover {
  color: var(--primary-color);
}

.modal-tab-btn-active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.modal-tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.modal-tab-content-active {
  display: block;
}

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

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Template Editor */
/* ────────────────────────────────────────────────────────────────────────────────── */

.template-editor {
  margin-top: 10px;
}

.editor-section {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
  border-left: 4px solid var(--primary-color);
}

.editor-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 12px;
  font-size: 14px;
}

.editor-section-title i {
  font-size: 18px;
}

.editor-section-content {
  background: white;
  padding: 12px;
  border-radius: 4px;
}

.editor-field {
  margin-bottom: 12px;
}

.editor-field:last-child {
  margin-bottom: 0;
}

/* Editor Variables */
.editor-variables {
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: 6px;
  padding: 12px;
  margin-top: 10px;
}

.editor-variables strong {
  display: block;
  color: #856404;
  font-size: 13px;
  margin-bottom: 8px;
}

.editor-variables .variables-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-field label {
  display: block;
  font-weight: 600;
  color: var(--primary-color);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.editor-field input,
.editor-field textarea,
.editor-field select {
  font-size: 13px;
}

.editor-field textarea {
  font-family: 'Courier New', monospace;
  resize: vertical;
}

.editor-variables {
  margin-top: 12px;
  padding: 10px;
  background: rgba(243, 156, 18, 0.1);
  border-radius: 4px;
  border-left: 3px solid var(--warning-color);
}

.editor-variables strong {
  font-size: 12px;
  color: var(--primary-color);
  display: block;
  margin-bottom: 8px;
}

.variables-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Editor Buttons */
.editor-buttons-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.editor-button-item {
  background: #f9f9f9;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  transition: all 0.3s ease;
}

.editor-button-item:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(1, 70, 81, 0.15);
  background: white;
}

.editor-button-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-color);
  gap: 8px;
}

.editor-button-header .badge {
  font-weight: 600;
  padding: 6px 10px;
  font-size: 12px;
}

.editor-button-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.editor-button-extra {
  grid-column: 1 / -1;
}

.editor-button-extra-label {
  display: block;
  font-weight: 600;
  color: var(--primary-color);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.btn-remove-button {
  padding: 4px 8px !important;
  font-size: 12px !important;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Template Type Choice Modal Styles */
/* ────────────────────────────────────────────────────────────────────────────────── */

.choice-card {
  transition: all 0.3s ease !important;
}

.choice-card:hover {
  transform: translateY(-4px) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
  border-color: var(--primary-color) !important;
}

.choice-card:nth-child(2):hover {
  border-color: #e74c3c !important;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Template Type Badge */
/* ────────────────────────────────────────────────────────────────────────────────── */

.template-type-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.template-type-badge.regular {
  background: #d1ecf1;
  color: #0c5460;
}

.template-type-badge.catalogo {
  background: #f8d7da;
  color: #721c24;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Carousel Modal Styles */
/* ────────────────────────────────────────────────────────────────────────────────── */

.products-list {
  max-height: 400px;
  overflow-y: auto;
}

.product-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.product-item:hover {
  background-color: #f8f9fa;
  border-color: var(--primary-color);
}

.product-item.selected {
  background-color: #e8f4f8;
  border-color: var(--primary-color);
}

.product-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.product-thumbnail {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  margin-right: 12px;
  background-color: #f0f0f0;
}

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

.product-name {
  font-weight: 600;
  color: var(--dark-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.product-price {
  font-size: 13px;
  color: var(--success-color);
  font-weight: 500;
  margin: 4px 0 0 0;
}

.alert-sm {
  padding: 0.5rem 0.75rem;
  font-size: 13px;
  margin: 0;
}

/* ────────────────────────────────────────────────────────────────────────────────── */
/* Choice Cards - Template Type Selection */
/* ────────────────────────────────────────────────────────────────────────────────── */

.choice-card {
  transition: all 0.3s ease !important;
  position: relative;
  overflow: hidden;
}

.choice-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.5);
  transition: left 0.3s ease;
  pointer-events: none;
}

.choice-card:hover {
  transform: translateY(-4px) !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12) !important;
}

.choice-card:hover::before {
  left: 100%;
}

.choice-card:hover button {
  transform: translateX(4px);
}

/* Choice card variants com cores específicas */

.choice-card[data-type="regular"]:hover {
  border-color: #2196F3 !important;
}

.choice-card[data-type="catalog"]:hover {
  border-color: #e74c3c !important;
}

.choice-card[data-type="carousel"]:hover {
  border-color: #9C27B0 !important;
}

.choice-card button {
  transition: all 0.3s ease;
}

/* Template Type Selection Cards */

.card-type {
  border: 2px solid #ddd;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #fff;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.card-type:hover {
  border-color: #014651;
  box-shadow: 0 4px 12px rgba(1, 70, 81, 0.15);
  transform: translateY(-4px);
}

.card-type.active {
  border-color: #014651;
  background: #f0f7f8;
}

.card-type .card-body {
  cursor: pointer;
}
