/*
 * ============================================================================
 * CSS Geral da Aplicação - PageBuilder (V4.30)
 * Responsividade e Reorganização
 * ============================================================================
 */

/* ========================================================================
   1. VARIÁVEIS CSS
   ======================================================================== */
:root {
  /* Cores Principais */
  --primary-color: #2e7d77;
  --primary-hover: #246a64;
  --secondary-color: #6c757d;
  --accent-color: #55c07b;

  /* Backgrounds */
  --background-page: #e0e0e0;
  --background-container: #f5f5f5;
  --background-section: #ffffff;
  --background-field: #ffffff;
  --background-chat: #e5ddd5;
  --background-bubble-user: #ffffff;
  --background-bubble-bot: #dcf8c6;
  --background-bubble-tool: #fef3c7;

  /* Textos */
  --text-weight-color: #000;
  --text-color: #333;
  --text-muted: #666;

  /* Cores de Status */
  --border-color: #ddd;
  --error-color: #dc3545;
  --success-color: #28a745;
  --warning-color: #ffc107;

  /* Border Radius */
  --border-radius-base: 8px;
  --border-radius-small: 4px;
  --border-radius-bubble: 18px;

  /* Sombras e Transições */
  --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.1);
  --transition-base: all 0.2s ease-in-out;

  /* Tipografia Fluida */
  --fs-min: 15px;
  --fs-max: 18px;
  --fs-fluid-factor: 1.6vw;
  --type-base: clamp(var(--fs-min), calc(12px + var(--fs-fluid-factor)), var(--fs-max));
}

/* ========================================================================
   2. RESET E BASE
   ======================================================================== */
html {
  font-size: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Open Sans', sans-serif;
  font-size: var(--type-base);
  line-height: 1.55;
  color: var(--text-color);
  background-color: var(--background-page);
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  min-height: 100vh;
}

.container {
  width: 100%;
  background: var(--background-container);
  padding: 20px;
  margin: 0;
  box-shadow: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* ========================================================================
   3. LAYOUTS
   ======================================================================== */
.layout-fixedHeaderFooter {
  height: 100vh;
  overflow: hidden;
}

.layout-fixedHeaderFooter .container {
  padding: 0;
}

.layout-fixedHeaderFooter .page-header {
  flex-shrink: 0;
}

.layout-fixedHeaderFooter .page-content {
  flex-grow: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}

.layout-fixedHeaderFooter .page-navigation {
  flex-shrink: 0;
  padding: 15px 20px;
}

/* ========================================================================
   4. TIPOGRAFIA
   ======================================================================== */
h1,
.page-header h1 {
  font-size: clamp(1.3rem, 5vw, 2.4rem);
}

.page-header h1 {
  color: white;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: clamp(1.2rem, 3.8vw, 1.8rem);
}

h3,
.form-section-header h3 {
  font-size: clamp(1.15rem, 3.2vw, 1.6rem);
}

.page-header .page-subtitle {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.9);
}

/* ========================================================================
   5. CABEÇALHO DA PÁGINA
   ======================================================================== */
.page-header {
  text-align: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--primary-color);
  color: white;
  border-radius: var(--border-radius-base) var(--border-radius-base) 0 0;
  box-shadow: var(--shadow-light);
}

/* Indicador LED no cabeçalho */
#header-led-indicator {
  position: relative;
  top: -2px;
  left: 50%;
  transform: translate(-50%, -100%);
  width: 60px;
  height: 14px;
  border-radius: 0 0 4px 4px;
  background-color: #0000001c;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: background-color 0.3s ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5em;
  color: white;
  font-weight: bold;
  letter-spacing: 0.5px;
  z-index: 100;
  opacity: 0.9;
}

#header-led-indicator.led-red {
  background-color: var(--error-color);
}

#header-led-indicator.led-yellow {
  background-color: var(--warning-color);
}

#header-led-indicator.led-green {
  background-color: var(--success-color);
}

#header-led-indicator.led-green-flash {
  animation: led-green-pulse 1s ease-out 3;
}

@keyframes led-green-pulse {
  0% { background-color: var(--success-color); opacity: 1; }
  50% { background-color: #38c172; opacity: 0.7; }
  100% { background-color: var(--success-color); opacity: 1; }
}

/* ========================================================================
   6. BOTÕES
   ======================================================================== */
.btn {
  display: inline-block;
  font-weight: 500;
  color: #fff;
  text-align: center;
  vertical-align: middle;
  user-select: none;
  background-color: var(--primary-color);
  border: 1px solid var(--primary-color);
  padding: 10px 20px;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: var(--border-radius-small);
  transition: var(--transition-base);
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background-color: var(--secondary-color);
  border-color: var(--secondary-color);
}

.btn-secondary:hover {
  background-color: #5a6268;
  border-color: #5a6268;
}

.btn-outline {
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.btn-outline:hover {
  background: var(--primary-color);
  color: white;
}

.btn-success {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}

.btn-success:hover {
  background-color: #48a66d;
  border-color: #48a66d;
}

.form-actions {
  margin: 6px;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* ========================================================================
   7. MENSAGENS DE STATUS E NOTIFICAÇÕES
   ======================================================================== */
.status-message {
  padding: 15px;
  margin-bottom: 20px;
  border-radius: var(--border-radius-base);
  text-align: center;
  font-weight: bold;
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  width: auto;
  max-width: 300px;
  box-shadow: var(--shadow-medium);
  transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
  opacity: 0;
  visibility: hidden;
  font-size: 1rem;
}

.status-message.success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.status-message.error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.status-message.info {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.unsaved-changes-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--warning-color);
  color: #664d03;
  padding: 8px 15px;
  border-radius: var(--border-radius-small);
  font-size: 0.85rem;
  border: 1px solid #ffda6a;
  z-index: 1001;
  font-weight: 600;
  animation: pulse 2s infinite;
  box-shadow: var(--shadow-light);
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.02); }
  100% { opacity: 1; transform: scale(1); }
}

/* ========================================================================
   8. SEÇÕES E GRID DO FORMULÁRIO
   ======================================================================== */
.form-section {
  background-color: var(--background-section);
  border-radius: var(--border-radius-base);
  margin-bottom: 25px;
  padding: 20px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-light);
}

.form-section-header {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-section-header h3 {
  font-size: 1.6rem;
  color: var(--primary-color);
  margin: 0;
}

.page-grid,
.section-grid {
  display: grid;
  gap: 20px;
  align-items: stretch;
}

.page-grid-cols-2,
.section-grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.page-grid-cols-3,
.section-grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.page-grid-cols-4,
.section-grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* ========================================================================
   9. CAMPOS DE FORMULÁRIO - ESTRUTURA BASE
   ======================================================================== */
.form-field {
  margin-bottom: 15px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  height: 100%;
}

.form-field label {
  margin-bottom: 0;
  display: block;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: 5px;
}

.form-field-label {
  font-size: 1em;
  font-weight: 700;
  color: var(--text-weight-color);
}

.required-indicator {
  color: var(--error-color);
  font-size: 0.9rem;
  display: contents;
}

.form-field-sublabel {
  display: block;
  margin-top: 5px;
  margin-bottom: 10px;
  color: #6c757d;
  font-size: 1rem;
  line-height: 1.4;
}

.form-field-sublabel strong {
  color: #495057;
  font-weight: 600;
}

.form-field-sublabel em {
  font-style: italic;
}

.form-field-sublabel code {
  background-color: #f8f9fa;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.8rem;
  color: #e83e8c;
}

.form-field-sublabel ul,
.form-field-sublabel ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.form-field-sublabel li {
  margin-bottom: 0.25rem;
}

.form-field-sublabel blockquote {
  border-left: 3px solid #007bff;
  padding-left: 0.75rem;
  margin: 0.5rem 0;
  font-style: italic;
  background-color: #f8f9fa;
  padding: 0.5rem 0.75rem;
  border-radius: 3px;
}

/* Alinhamento em grid */
.section-grid .form-field {
  height: 100%;
}

.section-grid .form-field:not(.toggle-switch):not(.radio-group-wrapper):not(.field-display-only) > label.form-field-label {
  margin-bottom: auto;
}

/* ========================================================================
   10. INPUTS - ESTILOS BASE
   ======================================================================== */
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field input[type="url"],
.form-field input[type="password"],
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-small);
  font-size: 1rem;
  color: var(--text-color);
  background-color: var(--background-field);
  transition: var(--transition-base);
}

.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="datetime-local"],
.form-field input[type="color"] {
  width: auto;
  max-width: 200px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-small);
  font-size: 1rem;
  color: var(--text-color);
  background-color: var(--background-field);
  transition: var(--transition-base);
}

.section-grid .form-field input[type="color"] {
  width: 100px;
  max-width: none;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-color: var(--accent-color);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(85, 192, 123, 0.25);
}

/* Scrollbar customizada para textarea */
.form-field textarea::-webkit-scrollbar {
  width: 8px;
}

.form-field textarea::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: var(--border-radius-small);
}

.form-field textarea::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: var(--border-radius-small);
}

.form-field textarea::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* ========================================================================
   11. VALIDAÇÃO E FEEDBACK DE CAMPOS
   ======================================================================== */
.field-error {
  color: var(--error-color);
  font-size: 0.9rem;
  margin-top: 5px;
  display: block;
  background-color: #f8d7da;
  border-radius: var(--border-radius-small);
  padding: 5px 10px;
}

.form-field.field-invalid input,
.form-field.field-invalid textarea,
.form-field.field-invalid select {
  border-color: var(--error-color);
}

.field-help-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 5px;
  display: block;
}

/* Estados de loading e erro para disponibilidade */
.field-loading {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8em;
  color: #666;
  margin-top: 5px;
}

.field-loading .fa-spinner {
  animation: spin 1s linear infinite;
}

input[type="date"].unavailable,
input[type="datetime-local"].unavailable {
  border-color: #dc3545;
  background-color: #f8d7da;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Feedback visual para campos alterados */
.form-field.field-changed input:not([type="checkbox"]):not([type="radio"]),
.form-field.field-changed textarea,
.form-field.field-changed select,
.form-field.field-changed .CodeMirror {
  border-color: var(--warning-color) !important;
  box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.25) !important;
  transition: all 0.2s ease-in-out;
}

.form-field.field-changed .checkbox-label,
.form-field.field-changed .radio-label {
  background-color: rgba(255, 193, 7, 0.1);
  border-radius: var(--border-radius-small);
  padding: 2px 5px;
  transition: all 0.2s ease-in-out;
}

/* Feedback para campos recém-atualizados */
.form-field.field-just-updated input:not([type="checkbox"]):not([type="radio"]),
.form-field.field-just-updated textarea,
.form-field.field-just-updated select,
.form-field.field-just-updated .CodeMirror {
  border-color: var(--success-color) !important;
  box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.25) !important;
  transition: all 0.2s ease-in-out;
  animation: field-highlight-pulse 1s ease-out;
}

.form-field.field-just-updated .CodeMirror-scroll,
.form-field.field-just-updated .checkbox-label,
.form-field.field-just-updated .radio-label {
  animation: field-highlight-pulse 1s ease-out;
}

.form-field.field-just-updated .checkbox-label,
.form-field.field-just-updated .radio-label {
  background-color: rgba(40, 167, 69, 0.2);
  border-radius: var(--border-radius-small);
  padding: 2px 5px;
}

@keyframes field-highlight-pulse {
  0% { background-color: rgba(40, 167, 69, 0.1); }
  50% { background-color: rgba(40, 167, 69, 0.3); }
  100% { background-color: transparent; }
}

/* Prioridade: Erros sobrepõem feedback de mudança */
.form-field.field-invalid.field-changed input:not([type="checkbox"]):not([type="radio"]),
.form-field.field-invalid.field-changed textarea,
.form-field.field-invalid.field-changed select,
.form-field.field-invalid.field-changed .CodeMirror {
  border-color: var(--error-color) !important;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25) !important;
}

/* Destaque ao navegar para campo */
.field-highlight {
  animation: field-navigate-highlight 2s ease-out;
}

@keyframes field-navigate-highlight {
  0% { background-color: rgba(0, 123, 255, 0.2); }
  50% { background-color: rgba(0, 123, 255, 0.1); }
  100% { background-color: transparent; }
}

/* ========================================================================
   12. CAMPOS ESPECIAIS - HTML DISPLAY
   ======================================================================== */
.form-field.field-display-only {
  padding: 10px 0;
  margin-bottom: 0;
}

.form-field.field-display-only .html-display-content {
  background-color: var(--background-container);
  border: 1px solid var(--border-color);
  padding: 15px;
  border-radius: var(--border-radius-small);
  margin-top: 10px;
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-x: auto;
}

.form-field.field-display-only .html-display-content p {
  margin-bottom: 10px;
}

.form-field.field-display-only .html-display-content h1,
.form-field.field-display-only .html-display-content h2,
.form-field.field-display-only .html-display-content h3 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.form-field.field-display-only .html-display-content strong {
  font-weight: bold;
}

.form-field.field-display-only .html-display-content u {
  text-decoration: underline;
}

.form-field.field-display-only .html-display-content a {
  color: var(--primary-color);
  text-decoration: none;
}

.form-field.field-display-only .html-display-content a:hover {
  text-decoration: underline;
}

.form-field.field-display-only .html-display-content ul,
.form-field.field-display-only .html-display-content ol {
  margin-left: 20px;
  margin-bottom: 10px;
}

.form-field.field-display-only .html-display-content li {
  margin-bottom: 5px;
}

.form-field.field-display-only .html-display-content code {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  background-color: #eee;
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

.form-field.field-display-only .html-display-content blockquote {
  border-left: 4px solid var(--border-color);
  padding-left: 1rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 1rem 0;
}

/* ========================================================================
   13. CHECKBOX E TOGGLE SWITCH
   ======================================================================== */
   
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none; /* For Safari/Chrome */
  width: 14px;
  height: 14px;
  border: 2px solid grey; /* Border for the unchecked state */
  border-radius: 3px;
  display: inline-block;
  position: relative; /* For positioning the checkmark */
  padding: 2px;
}

input[type="checkbox"]:checked {
  background-color: var(--success-color); /* Background color when checked */
  border-color: var(--success-color); /* Border color when checked */
}

input[type="checkbox"]:checked::before {
  content: '✓'; /* Custom checkmark character */
  color: white; /* Color of the checkmark */
  font-size: 10px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.checkbox-group-wrapper .checkbox-label:has(input[type="checkbox"]:checked), 
.form-readonly-mode .radio-group-wrapper .radio-label:has(input[type="radio"]:checked) {
    font-weight: 500 !important;
}

.checkbox-group-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 5px;
}

.toggle-switch .checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: normal;
  position: relative;
  color: var(--text-color);
  gap: 10px;
}

.toggle-switch .checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch .toggle-display-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.toggle-switch .slider {
  position: relative;
  width: 40px;
  height: 20px;
  background-color: var(--secondary-color);
  border-radius: 20px;
  transition: background-color 0.3s;
}

.toggle-switch .slider:before {
  content: "";
  position: absolute;
  left: 2px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.3s;
}

.toggle-switch .toggle-label-off,
.toggle-switch .toggle-label-on {
  font-size: 1em;
  font-weight: bold;
  color: var(--text-color);
  transition: opacity 0.3s ease-in-out;
  white-space: nowrap;
}

.toggle-switch input[type="checkbox"] + .toggle-display-container .toggle-label-off {
  opacity: 1;
}

.toggle-switch input[type="checkbox"] + .toggle-display-container .toggle-label-on {
  opacity: 0.5;
}

.toggle-switch input:checked + .toggle-display-container .slider {
  background-color: var(--accent-color) !important;
}

.toggle-switch input:checked + .toggle-display-container .slider:before {
  transform: translateX(20px);
}

.toggle-switch input:checked + .toggle-display-container .toggle-label-off {
  opacity: 0.5;
}

.toggle-switch input:checked + .toggle-display-container .toggle-label-on {
  opacity: 1;
  color: var(--text-color) !important;
}

/* Estado desabilitado */
.toggle-switch input:disabled + .toggle-display-container {
  /*opacity: 0.6;*/
  cursor: not-allowed;
}

.toggle-switch input:disabled + .toggle-display-container .slider {
  background-color: #ccc;
}

.toggle-switch input:disabled + .toggle-display-container .slider:before {
  background-color: #f5f5f5 !important;
}

.toggle-switch input:disabled + .toggle-display-container .toggle-label-off,
.toggle-switch input:disabled + .toggle-display-container .toggle-label-on {
  color: #999;
}

/* ========================================================================
   14. RADIO BUTTONS
   ======================================================================== */
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none; /* Compatibilidade Safari/Chrome */
  width: 14px;
  height: 14px;
  border: 2px solid grey; /* Borda no estado normal */
  border-radius: 50%; /* Torna o botão circular */
  display: inline-block;
  position: relative;
  cursor: pointer;
}

input[type="radio"]:checked {
  border-color: var(--success-color); /* Cor da borda quando ativo */
  background-color: white; /* Fundo branco para destacar o círculo interno */
}

input[type="radio"]:checked::before {
  content: '';
  width: 8px;
  height: 8px;
  background-color: var(--success-color); /* Cor do "pontinho" central */
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.radio-group-wrapper {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 15px;
  margin-top: 5px;
}

.radio-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: normal;
  color: var(--text-color);
  font-size: 1em;
  word-spacing: -1px;
}

.radio-label input[type="radio"] {
  margin-right: 1px;
}

/* ========================================================================
   15. HELP ICON E POPOVER
   ======================================================================== */
.help-icon {
  margin-left: 8px;
  color: var(--primary-color);
  cursor: pointer;
  font-size: 0.9em;
  vertical-align: middle;
  opacity: 0.7;
  transition: opacity 0.2s ease-in-out;
}

.help-icon:hover {
  opacity: 1;
  color: var(--accent-color);
}

.help-popover {
  position: absolute;
  background-color: var(--background-section);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-small);
  padding: 10px;
  box-shadow: var(--shadow-medium);
  z-index: 1000;
  max-width: 300px;
  line-height: 1.4;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
  top: calc(100% + 5px);
  left: 0;
}

.help-popover.show {
  visibility: visible;
  opacity: 1;
}

.help-popover p:last-child {
  margin-bottom: 0;
}

/* ========================================================================
   16. COMPONENTES CUSTOMIZADOS
   ======================================================================== */
.component-field-content {
  transition: all 0.3s ease-in-out;
}

.component-field-content[style*="display: none"] {
  opacity: 0;
  visibility: hidden;
}

.hidden-input {
  display: none;
}

/* ========================================================================
   17. EDITOR MARKDOWN (EasyMDE)
   ======================================================================== */
.editor-toolbar {
  border: 1px solid var(--border-color) !important;
  border-bottom: none !important;
  border-radius: var(--border-radius-small) var(--border-radius-small) 0 0 !important;
  background-color: #f8f9fa !important;
}

.editor-toolbar a.active,
.editor-toolbar a:hover {
  background-color: var(--accent-color) !important;
  color: #fff !important;
}

.editor-toolbar button {
  width: 30px !important;
  height: 30px !important;
  padding: 0 !important;
  margin: 0 2px !important;
}

.CodeMirror {
  border: 1px solid var(--border-color) !important;
  border-radius: var(--border-radius-small) !important;
  font-size: 1rem !important;
  line-height: 1.5 !important;
  color: var(--text-color) !important;
  background-color: white !important;
  min-height: 120px !important;
  height: auto !important;
  max-height: none !important;
}

.CodeMirror-scroll {
  min-height: 120px !important;
  max-height: calc(75vh) !important;
  padding: 0.75rem !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

.CodeMirror:focus-within {
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 2px rgba(18, 140, 126, 0.1), 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

/* Fullscreen mode */
.CodeMirror-fullscreen {
  z-index: 9999;
  border-radius: 0 !important;
  height: 100vh !important;
  max-height: unset !important;
}

.editor-toolbar.fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  z-index: 9999;
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
}

.editor-statusbar.fullscreen {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  z-index: 9999;
}

/* Campos full-height */
.form-field.full-height .CodeMirror {
  min-height: 120px !important;
  max-height: none !important;
}

.form-field.full-height .CodeMirror-scroll {
  min-height: 120px !important;
  max-height: none !important;
}

/* Preview do markdown */
.editor-preview {
  background: white !important;
  font-family: inherit !important;
  padding: 16px !important;
}

.editor-preview h1,
.editor-preview h2,
.editor-preview h3,
.editor-preview h4,
.editor-preview h5,
.editor-preview h6 {
  color: var(--primary-color) !important;
  margin-top: 1em;
  margin-bottom: 0.5em;
}

.editor-preview p {
  margin-bottom: 1em;
}

.editor-preview ul {
  list-style-type: disc;
  margin-left: 25px;
  margin-bottom: 10px;
}

.editor-preview ol {
  list-style-type: decimal;
  margin-left: 25px;
  margin-bottom: 10px;
}

.editor-preview li {
  margin-bottom: 5px;
}

.editor-preview blockquote {
  border-left: 4px solid var(--primary-color) !important;
  background: #f8f9fa !important;
  padding-left: 1rem;
  margin: 1rem 0;
}

.editor-preview code {
  background: #f8f9fa !important;
  color: #e83e8c !important;
}

.editor-preview pre {
  background: #f8f9fa !important;
  border: 1px solid var(--border-color) !important;
}

.editor-statusbar {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  font-size: 0.85em;
  color: var(--text-muted);
  background-color: #f8f9fa;
  border: 1px solid var(--border-color) !important;
  border-top: none !important;
  border-radius: 0 0 var(--border-radius-small) var(--border-radius-small) !important;
  line-height: 1.2;
}

.editor-statusbar .markdown-help {
  order: -1;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.editor-statusbar .editor-statusbar-item:first-of-type {
  margin-left: auto;
}

/* ========================================================================
   18. HISTÓRICO DE CHAT
   ======================================================================== */
.chat-history-wrapper {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-base);
  max-height: 400px;
  overflow-y: auto;
  background-color: var(--background-section);
}

.chat-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  height: 300px;
  overflow-y: auto;
  border: 1px solid #ccc;
  overflow-x: hidden;
  border-radius: 10px;
  background: var(--background-chat);
}

.chat-box.show {
  display: flex;
}

.date-separator {
  text-align: center;
  margin: 15px 0 10px 0;
  font-size: 12px;
  color: var(--text-muted);
  position: relative;
  background: rgba(255, 255, 255, 0.8);
  padding: 4px 12px;
  border-radius: 12px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.from-tool {
  background-color: var(--background-bubble-tool);
  border-radius: var(--border-radius-bubble);
  padding: 2px 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  word-break: break-word;
  font-size: 14px;
  width: fit-content;
  margin: 0 auto;
  max-width: 90%;
  overflow-wrap: break-word;
  box-shadow: none;
}

.from-tool.expanded {
  padding: 2px 12px 7px 12px;
}

.from-tool .tool-icon {
  font-size: 22px;
}

.from-tool .tool-details {
  display: none;
  text-align: center;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-color);
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}

.from-tool.expanded .tool-details {
  display: block;
}

.bubble-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  position: relative;
  width: 100%;
}

.bubble-left {
  flex-direction: row;
  justify-content: flex-start;
}

.bubble-right {
  justify-content: flex-end;
  margin-left: auto;
  margin-right: 2px;
}

.bubble-wrapper .avatar {
  width: 26px;
  height: 26px;
  min-width: 26px;
  font-size: 20px;
  border-radius: 50%;
  background-color: transparent;
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: default;
  flex-shrink: 0;
  margin-bottom: 0;
}

.bubble-left .avatar {
  margin-right: 8px;
}

.bubble-right .avatar {
  order: 2;
  margin-left: 8px;
}

.message {
  max-width: 75%;
  padding: 10px 14px 20px;
  border-radius: var(--border-radius-bubble);
  line-height: 1.4;
  word-wrap: break-word;
  box-shadow: none;
  position: relative;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  hyphens: auto;
}

.from-user {
  background-color: var(--background-bubble-user);
  color: var(--text-color);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: var(--border-radius-bubble);
}

.from-bot {
  background-color: var(--background-bubble-bot);
  color: var(--text-color);
  border-bottom-right-radius: 0;
  border-bottom-left-radius: var(--border-radius-bubble);
}

.message .latency {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
  position: absolute;
  bottom: 2px;
  white-space: nowrap;
  text-align: unset;
  display: block;
}

.bubble-left .latency {
  left: 15px;
}

.bubble-right .latency {
  right: 15px;
}

.message li {
  margin-left: 30px;
}

/* ========================================================================
   19. LISTA DE USUÁRIOS
   ======================================================================== */
.user-list-wrapper {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-base);
  background-color: white;
  padding: 15px 0;
  max-height: 300px;
  overflow-y: auto;
}

.user-list-wrapper h3 {
  padding: 0 15px 10px;
  margin-top: 0;
  margin-bottom: 0;
  border-bottom: 1px solid #eee;
  font-size: 1.1em;
  color: var(--primary-color);
}

.user-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.user-list-item {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  border-bottom: 1px solid #f8f9fa;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.user-list-item:hover {
  background-color: #f0f0f0;
}

.user-list-item:last-child {
  border-bottom: none;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--secondary-color);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  color: #fff;
  margin-right: 10px;
  font-size: 1rem;
  text-transform: uppercase;
}

.user-name {
  font-weight: bold;
  color: var(--text-color);
  flex-grow: 1;
}

.user-status {
  font-size: 0.8em;
  color: var(--text-muted);
  margin-left: auto;
  padding-left: 10px;
}

.user-status.online::before {
  content: "•";
  color: var(--success-color);
  margin-right: 4px;
  font-size: 1.2em;
  line-height: 1;
  vertical-align: middle;
}

.user-status.offline::before {
  content: "•";
  color: var(--error-color);
  margin-right: 4px;
  font-size: 1.2em;
  line-height: 1;
  vertical-align: middle;
}

.user-list-empty-state {
  padding: 15px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

/* ========================================================================
   20. MODAL
   ======================================================================== */
.app-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 20px;
  box-sizing: border-box;
}

.app-modal.show {
  opacity: 1;
  visibility: visible;
}

.app-modal-content {
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  width: 100%;
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s ease;
  overflow: hidden;
}

.app-modal.show .app-modal-content {
  transform: scale(1);
}

.app-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 15px 20px;
  border-bottom: 1px solid #e9ecef;
  background-color: #f8f9fa;
  flex-shrink: 0;
}

.app-modal-header h3 {
  margin: 0;
  color: #495057;
  font-size: 1.25rem;
  font-weight: 600;
}

.app-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #6c757d;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.app-modal-close:hover {
  background-color: #e9ecef;
  color: #495057;
}

.app-modal-close:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

.app-modal-body {
  padding: 0 20px 20px 20px;
  overflow-y: auto;
  flex: 1;
  line-height: 1.6;
  overflow-x: auto;
}

/* Estilos para conteúdo Markdown no modal */
.app-modal-body h1,
.app-modal-body h2,
.app-modal-body h3,
.app-modal-body h4,
.app-modal-body h5,
.app-modal-body h6 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: #495057;
}

.app-modal-body h1 { font-size: 1.5rem; }
.app-modal-body h2 { font-size: 1.3rem; }
.app-modal-body h3 { font-size: 1.1rem; }

.app-modal-body p {
  margin-bottom: 1rem;
  color: #6c757d;
}

.app-modal-body ul,
.app-modal-body ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.app-modal-body li {
  margin-bottom: 0.5rem;
  color: #6c757d;
}

.app-modal-body code {
  background-color: #f8f9fa;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: #e83e8c;
}

.app-modal-body pre {
  background-color: #f8f9fa;
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.app-modal-body pre code {
  background: none;
  padding: 0;
  color: #495057;
}

.app-modal-body blockquote {
  border-left: 4px solid #007bff;
  padding-left: 1rem;
  margin: 1rem 0;
  font-style: italic;
  color: #6c757d;
  background-color: #f8f9fa;
  padding: 1rem;
  border-radius: 4px;
}

.app-modal-body strong {
  color: #495057;
  font-weight: 600;
}

.app-modal-body em {
  color: #6c757d;
}

.app-modal-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.app-modal-body table th,
.app-modal-body table td {
  border: 1px solid #dee2e6;
  padding: 8px 12px;
  text-align: left;
}

.app-modal-body table th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #495057;
}

/* Modal de detalhes do LED */
.led-details-modal-content {
  max-height: 400px;
  overflow-y: auto;
}

.led-details-modal-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.led-details-modal-content li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.led-details-modal-content li:last-child {
  border-bottom: none;
}

.led-details-modal-content li:hover {
  background-color: #f8f9fa;
}

.led-details-modal-content li i {
  margin-right: 8px;
}

.led-details-modal-content li .field-label {
  flex-grow: 1;
  font-weight: 500;
}

.led-details-modal-content li .field-status {
  font-size: 0.8em;
  color: var(--text-muted);
}

.led-details-modal-content li.error-item .field-label {
  color: var(--error-color);
}

.led-details-modal-content li.changed-item .field-label {
  color: var(--warning-color);
}

/* ========================================================================
   21. NAVEGAÇÃO DE PÁGINAS
   ======================================================================== */
.page-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 25px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

/* ========================================================================
   22. FLATPICKR (DATE PICKER)
   ======================================================================== */
.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1) {
  box-shadow: -2px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;
}

.flatpickr-calendar.arrowTop:after {
  border-bottom-color: var(--accent-color);
}

.flatpickr-calendar.arrowBottom:after {
  border-top-color: var(--accent-color);
}

.flatpickr-months .flatpickr-month {
  background: var(--accent-color);
  color: #fff;
  fill: #fff;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  color: #fff;
  fill: #fff;
}

.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
  color: #bbb;
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
  fill: #f64747;
}

.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-current-month .numInputWrapper span.arrowUp:after {
  border-bottom-color: #fff;
}

.flatpickr-current-month .numInputWrapper span.arrowDown:after {
  border-top-color: #fff;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: var(--accent-color);
}

.flatpickr-current-month .flatpickr-monthDropdown-months:focus,
.flatpickr-current-month .flatpickr-monthDropdown-months:active {
  outline: none;
}

.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month {
  background-color: var(--accent-color);
}

.flatpickr-weekdays {
  background: var(--accent-color);
}

span.flatpickr-weekday {
  background: var(--accent-color);
}

.flatpickr-day {
  color: #484848;
}

.flatpickr-day.inRange,
.flatpickr-day.prevMonthDay.inRange,
.flatpickr-day.nextMonthDay.inRange,
.flatpickr-day.today.inRange,
.flatpickr-day.prevMonthDay.today.inRange,
.flatpickr-day.nextMonthDay.today.inRange,
.flatpickr-day:hover,
.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover,
.flatpickr-day:focus,
.flatpickr-day.prevMonthDay:focus,
.flatpickr-day.nextMonthDay:focus {
  background: #e2e2e2;
  border-color: #e2e2e2;
}

.flatpickr-day.today {
  border-color: #bbb;
}

.flatpickr-day.today:focus {
  border-color: #bbb;
  background: #bbb;
  color: #fff;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.inRange,
.flatpickr-day.startRange.inRange,
.flatpickr-day.endRange.inRange,
.flatpickr-day.selected:focus,
.flatpickr-day.startRange:focus,
.flatpickr-day.endRange:focus,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover,
.flatpickr-day.selected.prevMonthDay,
.flatpickr-day.startRange.prevMonthDay,
.flatpickr-day.endRange.prevMonthDay,
.flatpickr-day.selected.nextMonthDay,
.flatpickr-day.startRange.nextMonthDay,
.flatpickr-day.endRange.nextMonthDay {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

.flatpickr-day.selected.startRange + .endRange:not(:nth-child(7n+1)),
.flatpickr-day.startRange.startRange + .endRange:not(:nth-child(7n+1)),
.flatpickr-day.endRange.startRange + .endRange:not(:nth-child(7n+1)) {
  box-shadow: -10px 0 0 var(--accent-color);
}

.flatpickr-day.inRange {
  border-radius: 0;
  box-shadow: -5px 0 0 #e2e2e2, 5px 0 0 #e2e2e2;
}

.flatpickr-day.week.selected {
  box-shadow: -5px 0 0 var(--accent-color), 5px 0 0 var(--accent-color);
}

.flatpickr-innerContainer {
  background: #fff;
}

.flatpickr-time {
  background: #fff;
}

.flatpickr-time .numInputWrapper span.arrowUp:after {
  border-bottom-color: #484848;
}

.flatpickr-time .numInputWrapper span.arrowDown:after {
  border-top-color: #484848;
}

.flatpickr-time input {
  color: #484848;
}

.flatpickr-time .flatpickr-time-separator,
.flatpickr-time .flatpickr-am-pm {
  color: #484848;
}

.flatpickr-time input:hover,
.flatpickr-time .flatpickr-am-pm:hover,
.flatpickr-time input:focus,
.flatpickr-time .flatpickr-am-pm:focus {
  background: #eaeaea;
}

/* ========================================================================
   23. MODO SOMENTE LEITURA
   ======================================================================== */
.form-readonly-mode {
  pointer-events: auto;
  user-select: text;
}

/* Exceção: Permite interação com botões de navegação */
.form-readonly-mode #prevPageBtn,
.form-readonly-mode #nextPageBtn,
.form-readonly-mode .page-navigation {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: pointer !important;
}

/* Campos de texto, textarea, select - Cor do texto normal, sem transparência */
/* Aplica-se a inputs (exceto checkbox/radio/color), textareas e selects */
.form-readonly-mode input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
.form-readonly-mode textarea,
.form-readonly-mode select {
  background-color: #f8f9fa !important; /* Fundo levemente acinzentado para indicar não editável */
  border-color: #e9ecef !important;     /* Borda clara */
  color: var(--text-color) !important;   /* Cor do texto principal do tema */
  opacity: 1 !important;                 /* Sem transparência */
  cursor: default !important;            /* Cursor padrão */
}

.form-readonly-mode input,
.form-readonly-mode textarea,
.form-readonly-mode select {
  /*background-color: #f8f9fa !important;*/
  /*border-color: #e9ecef !important;*/
  /*color: #6c757d !important;*/
  cursor: default !important;
}

/* Botões customizados (não navegação) ficam desabilitados */
.form-readonly-mode button[data-action-type]:not([id="prevPageBtn"]):not([id="nextPageBtn"]) {
  opacity: 0.5; /* Transparência para botões desabilitados */
  cursor: not-allowed !important; /* Cursor de "proibido" */
  pointer-events: none !important; /* Desabilita interações */
}

/* Labels dos campos em modo read-only */
.form-readonly-mode .form-field-label {
  color: var(--text-color) !important; /* Cor do texto principal do tema */
  opacity: 1 !important;                 /* Sem transparência */
}

/* Input type color (ajuste específico: mantém fundo transparente para ver o seletor) */
.form-readonly-mode input[type="color"] {
    background-color: transparent !important; /* Fundo transparente para o input de cor */
    border: 1px solid var(--border-color) !important; /* Borda padrão */
    opacity: 1 !important; /* Sem transparência */
}

/* Garante que o texto em inputs/textareas ainda seja selecionável */
.form-readonly-mode input,
.form-readonly-mode textarea {
  user-select: text;
  pointer-events: auto;
  cursor: text !important;
}

/* Remove foco e sombra de foco para inputs/textareas */
.form-readonly-mode input:focus,
.form-readonly-mode textarea:focus {
  outline: none;
  box-shadow: none;
}

.form-readonly-mode .page-navigation {
  border: 2px solid #007bff;
  border-radius: 8px;
  padding: 10px;
  background-color: #f8f9fa;
}

.form-readonly-mode .page-navigation button {
  background-color: #007bff !important;
  color: white !important;
  border-color: #007bff !important;
}

.form-readonly-mode .page-navigation button:hover {
  background-color: #0056b3 !important;
  border-color: #0056b3 !important;
}

/* 🎯 Ajuste: Checkbox, Radio Buttons e Toggle - Destaque para opções selecionadas */

/* Estilo padrão para TODAS as labels de checkbox/radio em modo read-only */
/* As opções NÃO selecionadas terão estas características */
.form-readonly-mode .checkbox-group-wrapper .checkbox-label,
.form-readonly-mode .radio-group-wrapper .radio-label {
    opacity: 0.3;                 /* Transparência sutil */
    color: var(--text-muted);     /* Cor de texto mutada */
    font-weight: normal;          /* Peso de fonte normal */
    pointer-events: none;         /* Desabilita interações */
    cursor: default;              /* Cursor padrão */
}

/* Garante que o INPUT visual (box/círculo) do checkbox/radio em si não fique transparente */
.form-readonly-mode .checkbox-group-wrapper .checkbox-label input[type="checkbox"],
.form-readonly-mode .radio-group-wrapper .radio-label input[type="radio"] {
    opacity: 1 !important; /* Sem opacidade para o input visual */
    pointer-events: none;  /* Desabilita interações */
}

/* Estilo para LABELS de opções SELECIONADAS */
/* O seletor `:has()` é usado para aplicar estilos à label que contém um input :checked */
.form-readonly-mode .checkbox-group-wrapper .checkbox-label:has(input[type="checkbox"]:checked),
.form-readonly-mode .radio-group-wrapper .radio-label:has(input[type="radio"]:checked) {
    opacity: 1 !important;                 /* Sem transparência */
    color: var(--text-color) !important;   /* Cor do texto principal do tema */
    font-weight: 500 !important;          /* Semi Negrito para destaque */
}

/* --- TRATAMENTO ESPECÍFICO PARA TOGGLE SWITCH EM MODO READ-ONLY --- */
/* Estes estilos sobrescrevem as regras gerais de .checkbox-label para o toggle switch */

/* Slider do toggle-switch quando está LIGADO (checked) */
.form-readonly-mode .toggle-switch input[type="checkbox"]:checked + .toggle-display-container .slider {
    background-color: var(--accent-color) !important; /* Cor de destaque (verde) */
    opacity: 1 !important; /* Sem opacidade */
}

/* Slider do toggle-switch quando está DESLIGADO (not checked) */
.form-readonly-mode .toggle-switch input[type="checkbox"]:not(:checked) + .toggle-display-container .slider {
    background-color: var(--secondary-color) !important; /* Cor secundária ou padrão (cinza) */
    opacity: 0.6 !important; /* Com opacidade sutil */
}

/* Texto 'OFF' quando o toggle está LIGADO (e portanto, a opção OFF não está ativa) */
.form-readonly-mode .toggle-switch input[type="checkbox"]:checked + .toggle-display-container .toggle-label-off {
    opacity: 0.3 !important;             /* Transparência sutil */
    color: var(--text-muted) !important; /* Cor mutada */
    font-weight: normal !important;      /* Peso normal */
}

/* Texto 'ON' quando o toggle está LIGADO (e portanto, a opção ON está ativa) */
.form-readonly-mode .toggle-switch input[type="checkbox"]:checked + .toggle-display-container .toggle-label-on {
    opacity: 1 !important;                   /* Sem transparência */
    color: var(--text-color) !important;     /* Cor do texto principal */
    font-weight: bold !important;            /* Negrito */
}

/* Texto 'ON' quando o toggle está DESLIGADO (e portanto, a opção ON não está ativa) */
.form-readonly-mode .toggle-switch input[type="checkbox"]:not(:checked) + .toggle-display-container .toggle-label-on {
    opacity: 0.3 !important;             /* Transparência sutil */
    color: var(--text-muted) !important; /* Cor mutada */
    font-weight: normal !important;      /* Peso normal */
}

/* Texto 'OFF' quando o toggle está DESLIGADO (e portanto, a opção OFF está ativa) */
.form-readonly-mode .toggle-switch input[type="checkbox"]:not(:checked) + .toggle-display-container .toggle-label-off {
    opacity: 1 !important;                   /* Sem transparência */
    color: var(--text-color) !important;     /* Cor do texto principal */
    font-weight: bold !important;            /* Negrito */
}

.form-readonly-mode #header-led-indicator {
	display:none !important;
}

/* ========================================================================
   24. MEDIA QUERIES - RESPONSIVIDADE
   ======================================================================== */

/* Desktop (769px+) */
@media (min-width: 769px) {
  body {
    padding: 0;
    font-size: var(--fs-max);
  }

  .container {
    max-width: 900px;
    margin: 0 auto;
    min-height: calc(100vh - 40px);
    border-radius: var(--border-radius-base);
    box-shadow: var(--shadow-medium);
    padding: 30px;
  }

  .layout-fixedHeaderFooter .container {
    margin: 20px auto;
    min-height: calc(100vh - 85px);
  }

  .layout-fixedHeaderFooter .page-header {
    padding: 15px;
  }

  .layout-fixedHeaderFooter .page-content {
    padding: 15px;
  }

  .layout-fixedHeaderFooter .page-navigation {
    padding: 15px;
  }

  .page-header {
    margin: 0;
  }

  .page-header h1 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
  }

  .form-field-sublabel {
    font-size: 0.9rem;
  }

  .CodeMirror {
    font-size: 1rem !important;
    border-radius: var(--border-radius-base) !important;
  }

  .editor-toolbar {
    border-radius: var(--border-radius-base) var(--border-radius-base) 0 0 !important;
  }
}

/* Tablet (max-width: 1024px) */
@media (max-width: 1024px) {
  .container {
    padding: 20px 15px;
  }

  .layout-fixedHeaderFooter .container {
    height: calc(100vh - 60px);
  }

  .layout-fixedHeaderFooter {
    padding-bottom: 60px;
  }
}

/* Large Desktop (1200px+) */
@media (min-width: 1200px) {
  .container {
    max-width: 1100px;
    padding: 40px;
  }
}

/* Mobile (max-width: 769px) */
@media (max-width: 769px) {
  .help-popover {
    max-width: 90vw;
    left: 50%;
    transform: translateX(-50%);
    top: auto;
    bottom: 20px;
  }

  /* Colapsar grid para uma única coluna */
  .page-grid,
  .section-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .section-grid .form-field input:not([type="checkbox"]):not([type="radio"]),
  .section-grid .form-field select,
  .section-grid .form-field textarea {
    width: 100%;
  }

  /* Inputs específicos em 100% no mobile */
  .form-field input[type="number"],
  .form-field input[type="date"],
  .form-field input[type="datetime-local"] {
    width: 100% !important;
    max-width: none;
  }

  /* Modal responsivo */
  .app-modal {
    padding: 10px;
  }

  .app-modal-content {
    max-height: 90vh !important;
    max-width: 100% !important;
  }

  .app-modal-header,
  .app-modal-body {
    padding: 15px;
  }

  .app-modal-header h3 {
    font-size: 1.1rem;
  }

  /* Editor markdown menor */
  .editor-toolbar {
    padding: 5px !important;
  }

  .editor-toolbar button {
    width: 24px !important;
    height: 24px !important;
    padding: 0 !important;
    margin: 1px !important;
  }

  .CodeMirror {
    font-size: 0.9rem !important;
  }
}

/* Small Mobile (max-width: 700px) */
@media (max-width: 700px) {
  .radio-group-wrapper,
  .checkbox-group-wrapper {
    grid-template-columns: repeat(1, 1fr) !important;
    gap: 0 !important;
  }
}

/* Extra Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
  body {
    font-size: clamp(15px, calc(12px + 2.2vw), 17px);
  }

  .page-header {
    padding: 12px;
    border-radius: 0;
  }

  .form-section {
    padding: 15px;
  }

  .form-actions {
    gap: 8px;
  }

  #header-led-indicator {
    top: 9px;
    margin-bottom: 2px;
    width: 38px;
    height: 8px;
    font-size: 0.25em;
  }
}


.field-highlight { outline: 2px solid rgba(220,53,69,.55); transition: outline 0.2s ease-in-out; }
