/* Reset dasar */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

/* Body */
body {
  background: url('arm_robo.jpg') no-repeat center center fixed;
  background-size: cover;
  color: white;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  padding-top: 30px;
  min-height: 100vh;
}

/* Judul */
h1 {
  font-size: 2rem;
  margin-bottom: 25px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

/* Dashboard grid - 4 motor */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  justify-items: center;
  width: 100%;
  max-width: 1100px;
}

/* Gauge container */
.gauge-container {
  background-color: rgba(42, 42, 64, 0.85);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  min-height: 240px;
  box-shadow: 0 4px 10px rgb(0, 0, 0);
}

.gauge-container h2 {
  margin: 0 0 5px 0;
  font-size: 1.1rem;
}

.motor-desc {
  margin: 8px 0 0 0;
  font-size: 0.85rem;
  color: #94a3b8;
  font-style: italic;
}

/* Warna gauge untuk setiap motor */
#motor1-container {
  border-top: 3px solid #8b5cf6;
}

#motor1-container canvas {
  --gauge-color: #8b5cf6; /* Ungu - Base */
}

#motor2-container {
  border-top: 3px solid #3b82f6;
}

#motor2-container canvas {
  --gauge-color: #3b82f6; /* Biru - Shoulder */
}

#motor3-container {
  border-top: 3px solid #22c55e;
}

#motor3-container canvas {
  --gauge-color: #22c55e; /* Hijau - Elbow */
}

#motor4-container {
  border-top: 3px solid #f97316;
}

#motor4-container canvas {
  --gauge-color: #f97316; /* Orange - Wrist */
}

canvas {
  width: 180px !important;
  height: 180px !important;
}

/* Control Panel */
.control-panel {
  margin: 25px 0 15px 0;
  width: 90%;
  max-width: 1100px;
}

.control-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-control {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.btn-home {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.btn-home:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-2px);
}

.btn-calibrate {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

.btn-calibrate:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  transform: translateY(-2px);
}

.btn-mode {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: white;
  min-width: 180px;
}

.btn-mode:hover {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  transform: translateY(-2px);
}

.btn-start {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
}

.btn-start:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-2px);
}

.btn-start:disabled {
  background: #64748b;
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-stop {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.btn-stop:hover:not(:disabled) {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: translateY(-2px);
}

.btn-stop:disabled {
  background: #64748b;
  cursor: not-allowed;
  opacity: 0.5;
}

/* Mode Indicator */
.mode-indicator {
  margin-top: 12px;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mode-label {
  font-size: 0.95rem;
  color: #94a3b8;
}

.mode-badge {
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.9rem;
}

.mode-badge.manual {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: white;
}

.mode-badge.auto {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
}

/* Calibration Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
}

.modal-content {
  background: linear-gradient(135deg, #1e293b, #334155);
  margin: 5% auto;
  padding: 30px;
  border: 2px solid #475569;
  border-radius: 16px;
  width: 90%;
  max-width: 700px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  color: white;
}

.modal-content h2 {
  margin: 0 0 10px 0;
  color: #f59e0b;
}

.modal-content p {
  color: #94a3b8;
  margin-bottom: 20px;
}

.calibration-points {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.point-section {
  background: rgba(0, 0, 0, 0.3);
  padding: 15px;
  border-radius: 10px;
  border: 1px solid #475569;
}

.point-section h3 {
  margin: 0 0 15px 0;
  font-size: 1.1rem;
  color: #3b82f6;
}

.modal-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 25px;
}

.btn-save {
  padding: 12px 30px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-save:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-2px);
}

.btn-cancel {
  padding: 12px 30px;
  background: linear-gradient(135deg, #64748b, #475569);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-cancel:hover {
  background: linear-gradient(135deg, #475569, #334155);
  transform: translateY(-2px);
}

/* Container untuk input dan koordinat */
.control-section {
  margin-top: 25px;
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  width: 90%;
  max-width: 1100px;
  flex-wrap: wrap;
}

/* Input Koordinat */
.input-section {
  background-color: rgba(0, 0, 0, 0.5);
  padding: 15px 20px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 300px;
  max-width: 450px;
}

.input-section h2 {
  margin: 0 0 10px 0;
  font-size: 1.2rem;
}

.input-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-section label {
  font-weight: bold;
}

.input-section input {
  width: 60%;
  padding: 8px;
  border: none;
  border-radius: 6px;
  text-align: center;
  font-size: 1rem;
}

button {
  margin-top: 10px;
  padding: 10px 20px;
  background-color: #007BFF;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s;
}

button:hover {
  background-color: #0056b3;
}

/* Koordinat sekarang */
.coordinates {
  background-color: rgba(0, 0, 0, 0.5);
  padding: 15px 20px;
  border-radius: 12px;
  font-size: 1.1rem;
  flex: 1;
  min-width: 300px;
  max-width: 450px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.coordinates h2 {
  margin: 0 0 10px 0;
  font-size: 1.2rem;
  color: #3b82f6;
}

.coord-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-size: 1rem;
}

.coord-label {
  font-weight: bold;
  color: #22c55e;
}

.coord-value {
  font-weight: bold;
  color: white;
}

/* ===== Responsive Tablet ===== */
@media (max-width: 1024px) {
  .dashboard {
    grid-template-columns: repeat(2, 1fr);
    grid-template-areas:
      "motor1 motor2"
      "motor3 motor4";
    gap: 15px;
  }
  #motor1-container { grid-area: motor1; }
  #motor2-container { grid-area: motor2; }
  #motor3-container { grid-area: motor3; }
  #motor4-container { grid-area: motor4; }

  h1 {
    font-size: 1.8rem;
  }
}

@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

  h1 {
    font-size: 1.6rem;
  }

  .gauge-container {
    min-width: 150px;
    min-height: 200px;
    padding: 10px;
  }
  
  canvas {
    width: 150px !important;
    height: 150px !important;
  }

  .control-section {
    flex-direction: column;
    align-items: center;
  }

  .input-section,
  .coordinates {
    max-width: 100%;
    width: 100%;
  }
}

/* ===== Responsive HP kecil ===== */
@media (max-width: 480px) {
  body {
    justify-content: flex-start;
    padding-top: 20px;
  }

  h1 {
    font-size: 1.3rem;
    margin-bottom: 20px;
  }

  .dashboard {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .gauge-container {
    min-width: 140px;
    min-height: 180px;
    padding: 8px;
  }

  .gauge-container h2 {
    font-size: 0.95rem;
  }

  .motor-desc {
    font-size: 0.75rem;
  }

  canvas {
    width: 130px !important;
    height: 130px !important;
  }

  .control-section {
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    width: 95%;
  }

  .input-section {
    padding: 12px;
    max-width: 100%;
    width: 100%;
  }

  .input-section input {
    font-size: 0.9rem;
  }

  .coordinates {
    max-width: 100%;
    width: 100%;
    padding: 12px;
  }

  .coord-item {
    font-size: 0.95rem;
  }
}