/**
 * @fileoverview Folha de estilos CamControl
 * @version 9.0
 */

:root {
  /* Paleta de Cores */
  --bg-page: #d6d6d6;
  --bg-panel: #f4f4f4;
  --bg-header: #333;
  --bg-joypad: #e8e8e8;

  --color-primary: #007bff;
  --color-primary-hover: #0056b3;
  --color-success: #28a745;
  --color-danger: #dc3545;
  --color-warning: #ffc107;
  --color-info: #17a2b8;
  --color-text: #333;
  --color-muted: #777;

  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-page);
  color: var(--color-text);
  margin: 0;
  padding: 0;
}

/* --- HEADER --- */
.main-header {
  background: var(--bg-header);
  color: white;
  padding: 10px 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.header-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* Links de Admin e Botões do Header */
#admin-links,
#super-admin-links {
  display: none;
  gap: 10px;
}

.header-btn,
.logout-button {
  text-decoration: none;
  padding: 8px 15px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  color: white;
}

.header-btn {
  background-color: var(--color-primary);
}

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

.logout-button {
  background-color: var(--color-danger);
}

#device-select {
  padding: 5px;
  border-radius: 4px;
}

#adjustModeBtn {
  background-color: var(--color-muted);
}

/* --- LAYOUT GERAL --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}

.keypad-container,
.admin-card {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  box-sizing: border-box;
}

.keypad-container {
  max-width: 450px;
}

.admin-card {
  max-width: 900px;
}

/* Títulos */
.section-title,
.buttons-header h2 {
  margin: 0 0 15px 0;
  font-size: 1.1rem;
  color: #444;
  border-bottom: 2px solid #f0f0f0;
  padding-bottom: 8px;
}

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

/* --- CONSOLE DE CONTROLE (JOYPAD + DADOS) --- */
.control-console {
  display: flex;
  flex-direction: column;
  gap: 15px;
  background: var(--bg-panel);
  padding: 15px;
  border-radius: 10px;
  border: 1px solid #ccc;
}

/* Container do Joypad */
.console-joypad-container {
  background: var(--bg-joypad);
  padding: 15px;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
}

.joypad-top-row {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  margin-bottom: 5px;
  padding-left: 5px;
}

.homing-btn-all {
  width: 40px;
  height: 30px;
  background: var(--color-warning);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 0 #8a7318;
  transition: transform 0.1s;
}

.homing-btn-all:active {
  transform: translateY(4px);
  box-shadow: none;
  background-color: #d4b532;
}

.homing-btn-all:hover {
  background-color: #ffca2c;
}

/* Grid Direcional */
.d-pad-grid {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(3, 50px);
  gap: 5px;
}

/* Botões do Joypad */
.d-btn {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 10px;
  background: linear-gradient(145deg, #fff, #dcdcdc);
  box-shadow: 3px 3px 6px #bebebe, -3px -3px 6px #fff;
  font-size: 20px;
  color: #444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.d-btn:active {
  background: #dcdcdc;
  box-shadow: inset 2px 2px 5px #bebebe;
}

/* Centro Decorativo Vazio */
.d-pad-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.d-pad-center::after {
  content: '';
  width: 12px;
  height: 12px;
  background-color: #ccc;
  border-radius: 50%;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Zoom */
.zoom-group {
  display: flex;
  gap: 15px;
  justify-content: center;
  width: 100%;
}

.d-btn.zoom-btn {
  width: 80px;
  height: 40px;
  font-size: 14px;
  font-weight: bold;
}

/* --- DASHBOARD DE DADOS --- */
.axis-row {
  background: white;
  padding: 10px;
  border-radius: 8px;
  border-left: 5px solid var(--color-muted);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.axis-row.moving {
  border-left-color: var(--color-danger);
  background-color: #fff0f5;
}

.axis-header-row {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 13px;
  text-transform: uppercase;
}

.axis-data-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.control-input {
  width: 60px;
  height: 25px;
  font-size: 12px;
}

.control-btn {
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
}

/* --- MEMÓRIAS --- */
#memory-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dynamic-button-wrapper {
  position: relative;
  flex: 1 1 45%;
}

.dynamic-button.mem {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 4px;
  background-color: var(--color-info);
  color: white;
  font-weight: bold;
  cursor: pointer;
}

.dynamic-button.mem:active {
  opacity: 0.8;
}

.button-actions {
  position: absolute;
  top: -8px;
  right: -8px;
  display: flex;
  gap: 5px;
}

.edit-button,
.remove-button {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.edit-button {
  background: var(--color-primary);
}

.remove-button {
  background: var(--color-danger);
}

/* --- Botão Protegido --- */
.control-button.memory.locked,
.dynamic-button.mem.locked {
  background-color: #e2e6ea;
  /* Cinza claro */
  color: #555;
  border: 1px solid #ccc;
}

/* --- Ícone de Cadeado --- */
.lock-icon {
  font-size: 10px;
  margin-right: 4px;
}

/* --- FOOTER --- */
#status-panel {
  text-align: center;
  margin-top: 20px;
  color: #777;
  font-size: 13px;
}

/* --- COMPONENTES GERAIS (Listas, Forms, Modal) --- */
.add-button,
.submit-button {
  background: var(--color-success);
  color: white;
  border: none;
  cursor: pointer;
}

.add-button {
  border-radius: 15px;
  padding: 4px 12px;
  font-size: 12px;
}

.submit-button {
  width: 100%;
  padding: 10px;
  border-radius: 4px;
  font-weight: bold;
}

.list-item {
  padding: 10px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
}

.status-indicator.online {
  background-color: var(--color-success);
}

.status-indicator.offline {
  background-color: var(--color-muted);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.modal-overlay.visible {
  display: flex;
}

.modal-container {
  background: white;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
}

.modal-close-button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

.form-input,
.form-select {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  box-sizing: border-box;
}