* {
  box-sizing: border-box;
}

[x-cloak] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

:root {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.87);
  background-color: #07284b;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  font-weight: 500;
  color: #41905f;
  text-decoration: none;
}

a:hover {
  color: #535bf2;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background-color: #562375;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 80px;
  padding: 0 16px;
  box-shadow: 0 1px 20px rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 0;
  z-index: 10;
}

header img {
  height: 40px;
  width: auto;
}

header h3 {
  margin: 0;
  padding-right: 8px;
}

header input[type="search"] {
  padding: 8px;
  border-radius: 8px;
  border: none;
  width: min(320px, 60vw);
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
  width: calc(100vw - 32px);
}

main > div:first-of-type {
  text-align: center;
}

#main-flow {
  display: flex;
  width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

article {
  width: 100%;
  flex-shrink: 0;
  padding: 0 0 24px;
}

h2 {
  background-color: #562375;
  padding: 8px 20px;
  line-height: 2rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 5px;
}

main > p {
  text-align: center;
}

.background-fill {
  font-size: 4rem;
  font-weight: bold;
  background: linear-gradient(
      340deg,
      rgb(234, 26, 75) 1%,
      rgb(217 26 234) 50%,
      rgb(255, 234, 0) 99%
    ) text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-fill-color: transparent;
}

button {
  border-radius: 8px;
  background-color: #41905f;
  border: none;
  padding: 8px 12px;
  color: inherit;
  font-size: 1rem;
}

button:hover {
  opacity: 0.8;
  cursor: pointer;
}

.tab-switch {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin: 32px auto;
  padding: 8px;
  position: relative;
  border-radius: 12px;
  background: linear-gradient(
    0deg,
    hsl(0deg 0% 18%) 0%,
    hsl(0deg 0% 16%) 59%,
    hsl(0deg 0% 14%) 100%
  );
  border: 1px solid rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
  gap: 8px;
}

.tab-indicator {
  position: absolute;
  top: 8px;
  left: 8px;
  height: calc(100% - 16px);
  border-radius: 6px;
  background: linear-gradient(
    0deg,
    hsl(278deg 55% 30%) 0%,
    hsl(278deg 25% 65%) 12%,
    hsl(0deg 0% 92%) 59%,
    hsl(0deg 0% 100%) 100%
  );
  border: 1px solid #ccc;
  transition: transform 0.5s ease-out, width 0.5s ease-out;
  z-index: 0;
}

.tab-switch button {
  background: none;
  border: none;
  padding: 6px 16px;
  color: #fff;
  font-size: 1rem;
  position: relative;
  z-index: 1;
  transition: color 0.5s ease-out;
}

.tab-switch button.active {
  color: #000;
}

ul.protocol-list {
  padding: 0;
}

.protocol-item {
  list-style: none;
  font-size: 0.8rem;
  margin-bottom: 16px;
}

.protocol-item > div {
  display: flex;
  align-items: center;
}

.protocol-item pre {
  background-color: rgba(255, 255, 255, 0.1);
  overflow-x: auto;
  cursor: copy;
  padding: 8px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 94%;
}

.protocol-item pre:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.protocol-item h4 {
  margin: 0 0 8px;
}

.protocol-item .item-body {
  margin-left: 10px;
  width: 100%;
}

.protocol-item button.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 0;
}

.protocol-item button.icon-button img {
  width: 20px;
  height: auto;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #333;
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  z-index: 1000;
}

.ai-disabled-message {
  background: #f0f0f0;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  margin: 1rem 0;
  border: 1px solid #ddd;
}

.ai-controls {
  text-align: center;
  margin-bottom: 1rem;
}

.reset-btn {
  background: #dc3545 !important;
  color: white !important;
}

.ai-section {
  margin: 2rem 0;
  padding: 1.5rem;
  border: 2px solid red;
  border-radius: 8px;
  background: #fff;
  color: #000;
}



.ai-section p {
  color: #666;
  margin-bottom: 1rem;
}

.recording-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.recording-controls label {
  font-weight: bold;
}

.recording-controls select {
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  min-width: 200px;
}
.recording-controls select.permission-granted {
  /* Comentário: destaque visual confirma que a permissão foi concedida para o microfone escolhido. */
  border-color: #28a745;
  box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.25);
  background: #f4fff7;
}
.permission-btn {
  /* Comentário: botão separado para gerenciar a solicitação de permissão de microfone. */
  background: #007bff !important;
  color: #fff !important;
}
.permission-btn:disabled {
  /* Comentário: indica estado de sucesso ou loading ao impedir cliques adicionais. */
  background: #5a9df5 !important;
  opacity: 0.7;
  cursor: not-allowed;
}
.input-warning {
  /* Comentário: estilo dedicado para destacar mensagens relacionadas aos dispositivos de áudio. */
  margin: 0;
  color: #b3541e;
  font-size: 0.9rem;
  width: 100%;
}

.record-btn {
  background: #dc3545 !important;
  color: white !important;
}

.record-btn:disabled {
  background: #ccc !important;
}

.stop-btn {
  background: #ffc107 !important;
  color: black !important;
}

.transcribe-btn {
  background: #17a2b8 !important;
}

.process-btn {
  background: #28a745 !important;
}

.ai-section button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.3s;
}

.ai-section button:hover:not(:disabled) {
  opacity: 0.9;
}

.ai-section button:disabled {
  background: #ccc !important;
  cursor: not-allowed;
}

.audio-preview {
  margin-top: 1rem;
  padding: 1rem;
  background: white;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.loading {
  color: #007bff;
  font-style: italic;
  margin: 0.5rem 0;
}

.ai-section textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.4;
  resize: vertical;
}

.ai-section textarea:disabled {
  background: #f5f5f5;
}

.soap-result {
  margin-top: 1rem;
}

.soap-result h3 {
  color: #562375;
  margin-bottom: 0.5rem;
}

.copy-btn {
  background: #6c757d !important;
  margin-bottom: 0.5rem;
}

.soap-output {
  background: white;
  padding: 1rem;
  border-radius: 4px;
  border: 1px solid #ddd;
  white-space: pre-wrap;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
  max-height: 400px;
  overflow-y: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-dialog {
  position: relative;
  background-color: #0d3a66;
  border-radius: 12px;
  max-width: 900px;
  width: min(90vw, 900px);
  max-height: 90vh;
  padding: 16px;
  display: flex;
  flex-direction: column;
  z-index: 60;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-dialog header {
  position: static;
  background: transparent;
  box-shadow: none;
  justify-content: flex-end;
  gap: 8px;
  width: auto;
}

.modal-dialog header button {
  background-color: #41905f;
}

.modal-body {
  overflow-y: auto;
  padding: 0 4px;
  display: grid;
  gap: 16px;
}

.modal-body iframe,
.modal-body object,
.modal-body embed,
.modal-body img {
  width: 100%;
  border-radius: 8px;
}

.modal-body img + img {
  margin-top: 16px;
}

.modal-body form {
  display: grid;
  gap: 12px;
}

.modal-body form div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.modal-body form label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.modal-body pre {
  background-color: rgba(0, 0, 0, 0.35);
  padding: 12px;
  border-radius: 8px;
  white-space: pre-wrap;
}

footer {
  background-color: #562375;
  text-align: center;
  min-height: 180px;
  padding: 32px 16px;
  margin-top: 32px;
  width: 100vw;
}

footer img {
  height: 64px;
  width: auto;
}

@media (max-width: 600px) {
  header {
    height: 60px;
    padding: 8px 16px;
  }

  header h3 {
    font-size: 16px;
    line-height: 16px;
  }

  .protocol-item {
    width: calc(100vw - 32px);
  }

  .protocol-item .item-body {
    width: 85%;
  }
}
