.sh-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.sh-modal-overlay.hidden {
  display: none;
}

.sh-modal {
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: background-color 0.2s ease;
}

.sh-modal-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sh-modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.sh-modal-close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
}

.sh-modal-body {
  padding: 1.5rem 1.75rem 1.25rem;
}

.sh-modal .form-group {
  margin-bottom: 1rem;
}

.sh-modal label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.sh-modal input,
.sh-modal textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  font: inherit;
  background: var(--surface);
  color: var(--text);
  transition: all 0.2s ease;
}

.sh-modal input::placeholder,
.sh-modal textarea::placeholder {
  color: var(--text-muted);
}

.sh-modal input:focus,
.sh-modal textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.sh-modal-footer {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sh-modal-footer .actions {
  display: flex;
  gap: 0.5rem;
}

.btn-secondary {
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn-primary {
  padding: 0.55rem 1.3rem;
  border-radius: 999px;
  border: none;
  background: var(--primary);
  color: #ffffff;
  font: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--primary-2);
}

.form-message {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-message.error {
  color: #dc2626;
}

.form-message.success {
  color: #16a34a;
}


.subject-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.subject-pill {
  border-radius: 999px;
  border: 1px solid var(--border);        
  background: var(--surface);              
  color: var(--primary);                    
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    transform 0.05s ease;
}

.subject-pill:hover {
  transform: translateY(-1px);
  border-color: var(--primary-2);
  background: var(--surface-2);
}

.subject-pill.active {
  background: var(--primary);                
  border-color: var(--primary);
  color: #ffffff;                    
}


.tags-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.8rem;
}

.tag-chip button {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
}

#tagInput {
  flex: 1;
  min-width: 120px;
  border: none;
  outline: none;
  font: inherit;
  padding: 0.25rem 0.35rem;
  background: transparent;
  color: var(--text);
}

#tagInput::placeholder {
  color: var(--text-muted);
}

.tags-hint {
  font-size: 0.78rem;
  color: #9ca3af;
  display: block;
  margin-top: 0.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1.2fr);
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}

.form-main {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.form-side {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.upload-card {
  border-radius: 14px;
  border: 1px dashed var(--border);
  background: var(--surface-2);
  padding: 1rem 1.1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.upload-icon {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.1rem;
}

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

.upload-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-subtitle span {
  color: var(--primary);
  cursor: pointer;
}

#attachments {
  margin-top: 0.4rem;
  font-size: 0.8rem;
}

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

.upload-list {
  margin-top: 0.4rem;
  width: 100%;
  text-align: left;
  list-style: none;
  padding: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.upload-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
}

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

.upload-input {
  display: none;
}

.upload-btn {
  margin-top: 0.3rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #ffffff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-btn:hover {
  background: var(--primary-2);
  border-color: var(--primary-2);
}

/* Previews */
.upload-previews {
  margin-top: 0.6rem;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-start;
}

.preview-item {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  color: #f9fafb;
  font-size: 0.65rem;
}

.preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.85);
  color: #f9fafb;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
}

/* ===============================
   MODAL OVERLAY (REUTILIZÁVEL)
================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
  animation: fadeInOverlay 0.2s ease-out;
  padding: 20px;
}

.modal-overlay.hidden {
  display: none;
}

@keyframes fadeInOverlay {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInModal {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease;
  animation: slideInModal 0.3s ease-out;
  margin: auto;
}

.modal-card-large {
  max-width: 600px;
}

/* Melhorias para modais maiores (edit, report, role) */
#editModal .modal-card,
#reportModal .modal-card,
#roleModal .modal-card {
  max-width: 500px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Tema escuro - ajustes adicionais para modal de confirmação */
[data-theme="dark"] .modal-card-confirm {
  background: var(--surface);
}

[data-theme="dark"] .modal-card-confirm .modal-title {
  color: var(--text);
}

[data-theme="dark"] .modal-card-confirm .modal-message {
  color: var(--text-muted);
}

.modal-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.modal-message {
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
  margin: 0 0 24px 0;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.modal-actions .btn-outline {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-actions .btn-outline:hover {
  background: var(--surface-2);
  border-color: var(--primary);
  color: var(--primary);
}

.modal-actions .btn-primary {
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-actions .btn-primary:hover {
  background: var(--primary-2);
}

.modal-actions .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.modal-actions .btn-primary.delete {
  background: #dc2626;
}

.modal-actions .btn-primary.delete:hover {
  background: #b91c1c;
}

.modal-actions .btn-primary.delete:disabled {
  background: #dc2626;
}

.btn-text {
  display: inline-block;
}

/* Form groups dentro do modal */
.modal-body .form-group {
  margin-bottom: 20px;
}

.modal-body .form-group:last-of-type {
  margin-bottom: 0;
}

/* Checkbox Label */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
}

.checkbox-label span {
  font-size: 14px;
  color: var(--text);
}

.modal-body label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.modal-body input,
.modal-body textarea,
.modal-body select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: all 0.2s ease;
}

.modal-body select {
  cursor: pointer;
}

.modal-body select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.modal-body input::placeholder,
.modal-body textarea::placeholder {
  color: var(--text-muted);
}

.modal-body input:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

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

.modal-body .char-count {
  display: block;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* MODAL DE CONFIRMAÇÃO MELHORADO */
.modal-card-confirm {
  max-width: 420px;
  text-align: center;
  padding: 32px 24px 24px;
}

.modal-confirm-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #dc2626;
}

[data-theme="dark"] .modal-confirm-icon {
  background: rgba(220, 38, 38, 0.25);
  color: #f87171;
}

.modal-card-confirm .modal-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.modal-card-confirm .modal-message {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-card-confirm .modal-actions {
  justify-content: center;
  margin-top: 0;
}

/* Melhorias adicionais para centralização e responsividade */
@media (max-width: 640px) {
  .modal-overlay {
    padding: 16px;
  }
  
  .modal-card {
    width: 100%;
    max-width: 100%;
    border-radius: 12px;
    max-height: 95vh;
  }
  
  .modal-card-confirm {
    padding: 24px 20px 20px;
  }
  
  .modal-header {
    padding: 16px 20px;
  }
  
  .modal-body {
    padding: 20px;
  }
}

/* Garantir que o modal esteja sempre centralizado */
.modal-overlay:not(.hidden) {
  display: flex !important;
}