/* ==========================================================================
   Analisador Termográfico Web
   Tema visual inicial para uma interface técnica de análise termográfica.
   ========================================================================== */

/* Reset leve para reduzir diferenças entre navegadores. */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background: #0b0f14;
  color: #d8e1ea;
  font-family: Arial, Helvetica, sans-serif;
}

.copy-protection-enabled body {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.copy-protection-enabled input,
.copy-protection-enabled select,
.copy-protection-enabled textarea {
  -webkit-user-select: text;
  user-select: text;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

/* Estrutura principal: barra superior fixa e workspace ocupando o restante. */
.app-shell {
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(31, 44, 60, 0.52), rgba(11, 15, 20, 0.2) 260px),
    #0b0f14;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 20px;
  border-bottom: 1px solid #263241;
  background: #111821;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #40536b;
  border-radius: 8px;
  background: linear-gradient(135deg, #f46b45, #1f8ec9 68%, #152231);
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-area h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  color: #f4f7fa;
}

.brand-area p {
  margin: 3px 0 0;
  color: #8fa0b2;
  font-size: 12px;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #34475c;
  border-radius: 6px;
  background: #182231;
  color: #dce8f4;
  cursor: pointer;
  user-select: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.action-button:hover {
  border-color: #4f6b88;
  background: #202d3f;
}

.action-button.primary {
  border-color: #1f8ec9;
  background: #116ea1;
  color: #ffffff;
}

.action-button.primary:hover {
  background: #1681ba;
}

/* Grade desktop com duas laterais e um centro flexível. */
.workspace {
  display: grid;
  grid-template-columns: 220px minmax(520px, 1fr) 300px;
  gap: 1px;
  min-height: 0;
  overflow: hidden;
  background: #263241;
}

.sidebar,
.viewer-area {
  min-height: 0;
  background: #0f151d;
}

.sidebar {
  padding: 16px;
  overflow: auto;
}

.left-panel {
  border-right: 1px solid #263241;
}

.right-panel {
  border-left: 1px solid #263241;
}

.panel-section + .panel-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #263241;
}

.panel-section h2 {
  margin: 0 0 12px;
  color: #f2f6fa;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Ferramentas da barra esquerda. */
.tool-list {
  display: grid;
  gap: 8px;
}

.tool-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid #2b3949;
  border-radius: 6px;
  background: #151e29;
  color: #c8d5e2;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.tool-button:hover,
.tool-button.active {
  border-color: #1f8ec9;
  background: #172d3d;
  color: #ffffff;
}

.tool-button.is-disabled {
  border-color: #2b3949;
  background: #101720;
  color: #67788a;
  cursor: not-allowed;
  opacity: 0.62;
}

.tool-button.is-disabled .tool-icon {
  color: #748393;
}

.tool-button.is-disabled:hover,
.tool-button.is-disabled.active {
  border-color: #2b3949;
  background: #101720;
  color: #67788a;
}

.tool-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: #77cef2;
  font-weight: 700;
}

.compact-info p {
  margin: 0 0 8px;
  color: #96a8ba;
  font-size: 13px;
}

.compact-info strong {
  color: #dce8f4;
}

/* Área central de visualização. */
.viewer-area {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  padding: 16px;
  overflow: hidden;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px 14px;
}

.mode-badge,
.canvas-mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #334457;
  border-radius: 999px;
  background: #141d28;
  color: #dce8f4;
  font-size: 12px;
  white-space: nowrap;
}

.mode-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ffcf70;
  box-shadow: 0 0 0 3px rgba(255, 207, 112, 0.12);
}

.mode-badge.is-radiometric,
.canvas-mode-chip.is-radiometric {
  border-color: rgba(105, 194, 143, 0.55);
}

.mode-badge.is-radiometric .mode-dot,
.canvas-mode-chip.is-radiometric .mode-dot {
  background: #69c28f;
  box-shadow: 0 0 0 3px rgba(105, 194, 143, 0.14);
}

.mode-badge.is-visual,
.canvas-mode-chip.is-visual {
  border-color: rgba(255, 207, 112, 0.55);
}

.mode-badge.is-error,
.canvas-mode-chip.is-error {
  border-color: rgba(217, 95, 95, 0.6);
}

.mode-badge.is-error .mode-dot,
.canvas-mode-chip.is-error .mode-dot {
  background: #d95f5f;
  box-shadow: 0 0 0 3px rgba(217, 95, 95, 0.16);
}

.app-status {
  display: grid;
  gap: 3px;
  min-height: 42px;
  margin: 0 0 12px;
  padding: 9px 12px;
  border: 1px solid #334457;
  border-left-width: 4px;
  border-radius: 6px;
  background: #111923;
  color: #dce8f4;
}

.app-status strong {
  font-size: 13px;
  line-height: 1.25;
}

.app-status span {
  color: #9eb0c0;
  font-size: 12px;
  line-height: 1.35;
}

.app-status.info {
  border-left-color: #1f8ec9;
}

.app-status.success {
  border-left-color: #69c28f;
}

.app-status.warning {
  border-left-color: #ffcf70;
}

.app-status.error {
  border-left-color: #d95f5f;
}

.app-status.loading {
  border-left-color: #77cef2;
}

.viewer-title,
.viewer-subtitle {
  display: block;
}

.viewer-title {
  color: #f2f6fa;
  font-size: 15px;
  font-weight: 700;
}

.viewer-subtitle {
  margin-top: 3px;
  color: #8496a8;
  font-size: 12px;
}

.viewer-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.viewer-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #334457;
  border-radius: 6px;
  background: #141d28;
  color: #dce8f4;
  font-size: 12px;
  transition: background 160ms ease, border-color 160ms ease;
}

.viewer-button:hover {
  border-color: #1f8ec9;
  background: #172d3d;
}

.icon-button {
  width: 34px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.viewer-readout {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #334457;
  border-radius: 6px;
  background: #141d28;
  color: #93a7bb;
  font-size: 12px;
}

.viewer-readout strong {
  color: #ffcf70;
  font-size: 14px;
}

.canvas-frame {
  position: relative;
  display: grid;
  place-items: start center;
  min-height: 0;
  border: 1px solid #334457;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(31, 142, 201, 0.18), transparent 42%),
    #090d12;
  background-size: 28px 28px, 28px 28px, auto, auto;
  overflow: hidden;
}

.canvas-mode-chip {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  background: rgba(20, 29, 40, 0.92);
  pointer-events: none;
}

#thermalCanvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 3 / 2;
  border: 1px solid #1f2b37;
  background: #05070a;
  cursor: crosshair;
  touch-action: none;
}

#thermalCanvas.is-pan-ready {
  cursor: grab;
}

#thermalCanvas.is-panning {
  cursor: grabbing;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 20px;
  color: #8fa0b2;
  pointer-events: none;
  text-align: center;
}

.empty-state.is-hidden {
  display: none;
}

.empty-state-icon {
  color: #1f8ec9;
  font-size: 42px;
  line-height: 1;
}

.empty-state p {
  margin: 0;
  color: #d4dde7;
  font-size: 16px;
  font-weight: 700;
}

.empty-state small {
  color: #8fa0b2;
}

/* Formulário da barra direita. */
.properties-form {
  display: grid;
  gap: 12px;
}

.image-info,
.annotation-info,
.diagnostics-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #304154;
  border-radius: 6px;
  background: #111923;
}

.diagnostics-panel h3 {
  margin: 0 0 2px;
  color: #f2f6fa;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.diagnostics-grid {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.diagnostics-grid span,
.technical-details span {
  color: #8fa0b2;
  font-size: 12px;
}

.diagnostics-grid strong,
.technical-details strong {
  min-width: 0;
  color: #e2edf7;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.details-toggle {
  justify-self: start;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #334457;
  border-radius: 6px;
  background: #141d28;
  color: #dce8f4;
  font-size: 12px;
}

.details-toggle:hover {
  border-color: #1f8ec9;
  background: #172d3d;
}

.technical-details {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #263241;
}

.technical-details[hidden] {
  display: none;
}

.info-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  min-height: 22px;
}

.info-row.full-row {
  grid-template-columns: 1fr;
  gap: 4px;
}

.info-row span {
  color: #8fa0b2;
  font-size: 12px;
}

.info-row strong {
  min-width: 0;
  color: #e2edf7;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.field-group {
  display: grid;
  gap: 6px;
}

.field-group span {
  color: #a7b6c5;
  font-size: 12px;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid #304154;
  border-radius: 6px;
  outline: none;
  background: #111923;
  color: #e2edf7;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: #1f8ec9;
  box-shadow: 0 0 0 3px rgba(31, 142, 201, 0.16);
}

.notes-field {
  min-height: 112px;
  padding: 10px;
  resize: vertical;
  line-height: 1.45;
}

.field-group input.is-invalid {
  border-color: #d95f5f;
  box-shadow: 0 0 0 3px rgba(217, 95, 95, 0.14);
}

.validation-message {
  display: none;
  color: #f0a0a0;
  font-size: 11px;
  line-height: 1.35;
}

.validation-message.is-visible {
  display: block;
}

.palette-warning,
.technical-warning,
.estimate-warning {
  margin: -2px 0 2px;
  padding: 9px 10px;
  border-left: 3px solid #ffcf70;
  border-radius: 4px;
  background: rgba(255, 207, 112, 0.08);
  color: #aebdca;
  font-size: 12px;
  line-height: 1.35;
}

.technical-warning {
  border-left-color: #1f8ec9;
  background: rgba(31, 142, 201, 0.08);
}

.estimate-warning {
  border-left-color: #f46b45;
  background: rgba(244, 107, 69, 0.08);
}

/* Ajuste para telas desktop menores, mantendo a aplicação utilizável. */
@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 190px minmax(420px, 1fr) 260px;
  }

  .top-bar {
    align-items: flex-start;
    height: auto;
  }

  .app-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 170px minmax(360px, 1fr) 240px;
  }

  .sidebar {
    padding: 12px;
  }
}
